####Intro Ellipses are easier to manipulate compared to triangles because they only have one set of cartesian co-ordinates. Here I introduce variables to represent co-ordinates of a triangle with the thought of doing more with my spaceship.

Here’s the program in action

####Triangle - spaceship

Old co-ordinates (mouse dependent)

Introducing new variables and co-ordinates for spaceship:

####Animation using p5 - if statements

- Read J. Kuiphoff’s Animation using p5.js.
- Felt animation using keyboard driven actions are closer to actual game play in Asteroids.
- In particular, Fluid Movements, which makes use of three new concepts

(i) dx > distance between actual position and intended position

(ii) targetX > intended destination of object

(iii) using var easing and if statements - An open source code is manipulated to introduce fluid movements. Here’s my version of it (keeping in view the new triangle variables),

#### Animation using p5 - keyPressed() Function

- The function keyPressed() let’s you assign codeblocks to events driven by key-strokes.
- I have defined the following targetX and targetY variables in relation to the triangle’s co-ordinates.
- numPixels is a variable which determines the distance by pixel a key stroke moves the spaceship (in my program, 10px)
- PROBLEM: I can only get the spaceship to move across one diagonal axis.
- PROBLEM: I can’t figure out how to put in action the RIGHT_ARROW and LEFT_ARROW actions.