A. Program Description for Developers

Program Description:
Assumptions:

1. A tick is one iteration through the game’s main while loop (while (f==1){})

2. Cacti are moved once per tick, so cactus speed is a product of time slept and the amount moved per tick

3. A cactus’s x coordinate can be used as a timer, since the cactus x is changed the same amount for each tick

4. A tick rate where there is a sleep of less than 50 ms between redraws and recalculations will look fluid to a player

5. The tick rate can be used to track score, since score is related to time alive and tick rate is constant.

6. The player will never want to jump and duck at the same time (Proteus is not multi touch)

Important Variables:
Dinosaur:
Int y = stores how high the dinosaur currently is. Jumping increases then decreases this variable. Default is 0.
Int j = Keeps track of where the dino is in the jump cycle. 0=ready to jump, 1= on the way up, 2=on the way down.

Cactus:
Int x = stores the cactus’s position. Since this is constantly changing in a linear way, it is also used as a timer
Int type = stores which kind of cactus, or makes the cactus a ptero if type ==4
Int active = if 1, the cactus is drawn and can kill the dino. If 0, the cactus is invisible but cannot kill the dino

Functions:
Dinosaur
dinosaur(); = constructor function defaults to standard position, max y is 75
JumpDuck();= runs every time through the while loop. If the dino is jumping, this function makes it move along its path. Otherwise, if there is a touch on the left side of the screen, the dino’s y position goes down and so does its height, giving it a “ducking” appearance. If the touch is on the right side of the screen, the jump cycle begins.
Draw(); = draws the dinosaur at x coordinate 10, and dino.y

Cactus
DrawCactus(); = Draws the cactus/pterodactyl based on the cactus.type value and the x and y position
Move(); = moves the cactus at a constant rate to the left by decreasing the x value each time the function is run
Reset(); = Puts the cactus back at x=301 and sets it to active. Also sets cactus type to a random int between 0 and 2
CactusReady();= this function makes sure a cactus is inactive and adds a random element to when the cactus spawns, at least for the first few cacti
Test();= This function tests for collisions between the dino and any obstacles. It just checks to see if the dino’s x and y coordinates (x is constant 10) intersect with the cube that defines collision with the obstacle. If they do, it returns 1, which kills the main game loop