Day Two- Using Defined Variables to Animate

Today in class we focused on variables.

“let” and “const” are in, and “var” is out. Noted.

Being able to establish a value for a variable creates a very helpful shorthand. Our assignment was to play around in the P5 editor with color and shapes but to do so with variables that we would then manipulate with operations.

I first coded a stagnant and simple beach scene.

I later was able to make my beach boll roll away by calling back my beach ball’s x location and increasing it by 3.

Because everything in “function (draw)” automatically loops, adding 3 to that value creates a consistent increase to my ball’s horizontal location, giving it the appearance of rolling.

Next I did this to my sun. However, I knew I wanted it to move diagonally, like a sunset so I changed both it’s X and Y coordinates.

Here’s a picture of my set sun.

Sadly, my beach ball had long since rolled off of my canvas when the above shot was taken.

I knew that I could make my sun disappear into my water by writing my sun’s code before the water and sand code. I like that, similar to photoshop, I can layer my variables.

I attempted to change the colors in a similar fashion, with the goal of making everything get darker gradually as my sun set, however because I don’t know how to control the change rate everything changed immediately.

It also did not loop and continue to change, it changed once and then stayed that color.

Hopefully I’ll be able to do this soon!

Please check out my little beach scene here.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with
Get started
<span>%d</span> bloggers like this: