Processing Lab

The initial sketch we decided to attempt was one of a football player being chased by another player or multiple players that were moving at a constant speed toward a player controlled by the mouse.  We then found an example online of a dot moving toward the mouse with the position of it relative to a formula of the difference in the mouse position and the dot’s position.  It divided the difference of the two by a numeric in order to create a lag in the time that it took the dot to reach the mouse.  The trouble with the formula is that it moved relative to the difference, therefore it was faster when the mouse was farther away from the dot, and slower the closer it got.  We were looking for a constant speed vector toward the mouse rather than a varying speed in order to make it more realistic.  I tackled this issue by making a variable that made the divisor of speed greater the farther away the object as from the mouse so it would not be as fast from farther away from the mouse.

The next challenge faced was to make more than one dot move toward the mouse.  The draw function did not support more than one object to be drawn and moved the same way the example showed, so a  new ‘display’ and ‘move’ function had to be written for each object.  When more than dot was following the mouse, they would eventually blend together as one if their movements were dictated by the same algorithm, so another challenge I faced was to change the formula for each object to give it a unique movement toward the mouse while avoiding making it move too fast or too slow.

I then applied a background and imported pictures for the opposing players once I was able to get three dots to follow the mouse in an acceptable manner.  It was then I realized that I needed to have something happen when another player hit the player controlled by the mouse, so I created a condition that when the player was within a certain distance of the dot objects the background would change and display that you had been tackled.  I then created conditions for a similar background change when the perimeters of the field were breached by the player, as well as a different background change when the endzone was reached.

In order to have the game able to be restarted, a mouseClicked condition was added.  If the mouse was at a small enough x position, the game restarted with a ball coming toward the mouse from a random y position from where the opposing players are because I thought this simulated a kickoff in football more accurately.

This entry was posted in Uncategorized. Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s