Creepy girl and her creepy blinking eye.

Shiyu Chen
Shiyu’s ITP blog
Published in
2 min readSep 17, 2018

How to exchange two different eyeballs by coding?

In this weekly assignment, I challenged myself to create variables and apply conditional statements on my code. I started thinking about how to exchange those two characters’ eyes in a reasonable speed by applying “if” statement. Special thanks to a second year student, Yang Yang, who inspired me the mindset of the programming.

There are three things I need to be clear with: the coordinate of starting point (x1, y1) and the ending point(x2, y2), and the speed/time of transition. If (x1 > x2), I want the girl’s eye moves to the place where the horse’ eye was. So I made two variable “eye 1 (girl’s eye)= {x1:280, y1:100}”and “eye2 (horse’s eye)= {x2:128,y2:200}” and coded “if x1 ≥ x2, x1 -=(x1-x2)/100; y1-=(y1-y2)/100” and set the speed to 100 frame so the eye could move smoothly. But it didn’t work at the very beginning because 1) I coded “x1” instead of “eye1.x1”. 2) I didn’t apply the “eye1.x1” into the X coordinate of eye1. So I changed to “var eye1 = {x:280, y:100}” and “eye2 = {x:128,y:200}” then code “if eye1.x ≥eye2.x, eye1.x-=(eye1.x-eye2.x)/100, eye1.y -=(eye1.y-eye2.y)/100” “if eye2.x≤eye1.x”, likewise. And it worked!

However, I found the eye 2 didn’t move to where the eye1 was because the code “if eye2.x ≤ eye1.x” didn’t execute as eye1.x already changed the position. So I made another variable “eye1ending” and “eye2ending” and set a exact value inside, then it became like this:

And it moves!

I also applied “Loop” to draw multiples triangles, “Random” to make the eyeball blink and “mouseX” to make the color changes. That was fun!

You may want to see the code here:

And! I downloaded an image from Google which should meet a beautiful story between a girl and a horse. (Not a creeeepy one!!)

You may see the source here

--

--