Pongyroids Project Documentation
Pongyroids Project Documentation
Sumar D. Kudeep
[email protected]
pongyRoids
Developer documentation
Contents
Defining & understanding phase...........................................................................................................2
Program overview.............................................................................................................................2
Client requirements...........................................................................................................................2
Core functionality (required).........................................................................................................2
Extended functionality (not initially required)...............................................................................2
Planning & design phase........................................................................................................................3
Screen design.....................................................................................................................................3
Data dictionary..................................................................................................................................3
Structure chart..................................................................................................................................4
Algorithm design...............................................................................................................................5
pongyRoids....................................................................................................................................5
setup()...........................................................................................................................................6
newLevel().....................................................................................................................................6
draw()............................................................................................................................................7
keyPressed()..................................................................................................................................7
keyReleased()................................................................................................................................7
mousePressed().............................................................................................................................8
addBall()........................................................................................................................................8
moveBat()......................................................................................................................................9
moveBalls()....................................................................................................................................9
removeBall(balls, index)..............................................................................................................10
Implementing phase............................................................................................................................11
Testing & evaluating phase..................................................................................................................11
Maintaining phase...............................................................................................................................11
Extended functionality (not initially required).............................................................................11
1|Page
Defining & understanding phase
Program overview
pongyRoids is a fast-paced multi-controlled pong and asteroids - inspired game developed to help
practise some useful programming techniques and deconstruct a variety of project documentation
methods
Client requirements
The client for this project has specified a set of core functionality as well as extended functionality.
They require all core functionality before release, but would love us to consider features from the
extended functionality as well. The basic requirements list is given below:
Context diagram
<work in progress>
2|Page
DataFlowDiagram
<work in progress>
Screen design
Data dictionary
3|Page
Structure chart
4|Page
Algorithm design
pongyRoids
BEGIN pongyRoids
setup()
REPEAT
draw()
keyPressed()
END IF
keyReleased()
END IF
mousePressed()
END IF
END
5|Page
setup()
setup() runs once when the program starts. We should create a bat for the player in setup and call a
procedure to reset global variables ready for a new level (this same subprogram can be called later
whenever the player’s round ends).
BEGIN setup()
bat=new bat()
newLevel()
END
newLevel()
newLevel() will be called from setup() when the game starts, but also after a round ends so is useful
as a separate procedure
BEGIN newLevel()
REM reset bat and ball data ready for a new level
startTime=millis()
score=0
END
6|Page
draw()
Note that the plan for this draw loop asks you to call the moveBat() and moveBalls() subprograms.
If these don’t exist yet, you can either create empty stubs for them, or comment out the relevant
lines of code – and then remember to uncomment them as soon as you create the subprograms.
BEGIN draw() {
REM infinite loop runs until the player closes the program
IF (millis()-startTime<30000) THEN
moveBat()
moveBalls()
ELSE
noLoop()
END IF
END
Instead of changing the bat’s x position directly when a keypress is detected, it might be smoother to
set the player’s bat speed when a keypress is detected. When a key is released, we can set the
relevant speed field back to 0. This lets the player move the bat diagonally and change directions.
keyPressed() keyReleased()
7|Page
mousePressed()
When the user presses the mouse, we should generate a new ball and add it to the array of balls.
mousePressed() is one of Processing’s special event-driven procedures like keyPressed.
BEGIN mousePressed()
IF (millis()-startTime<30000) THEN
ELSE
newLevel()
loop()
END IF
END
addBall()
addBall() will be called whenever the user presses the mouse to add a ball to the balls array.
An IPO chart and data dictionary for it are shown below.
balls=(ball[])append(balls, b)
return balls
END
8|Page
moveBat()
BEGIN moveBat()
REM move the bat
Increment the bat’s x value by its xSpeed
Increment the bat’s y value by its xSpeed
IF (bat.x+bat.w>width) bat.x=bat.x-bat.xSpeed
IF (bat.y+bat.h>height) bat.y=bat.y-bat.ySpeed
Show the bat at its x, y position using its width and height
END
moveBalls()
BEGIN moveBalls()
REM move all the balls
FOR i=0 to balls.length-1
balls[i].x = balls[i].x+balls[i].xSpeed
balls[i].y = balls[i].y+balls[i].ySpeed
circle(balls[i].x, balls[i].y, balls[i].radius*2)
IF balls[i] is touching a side THEN
balls[i].xSpeed = balls[i].xSpeed * -1
END IF
IF balls[i] is touching the top THEN
balls[i].ySpeed = balls[i].ySpeed * -1
END IF
IF (touchingBat(balls[i])) THEN
balls[i].ySpeed = balls[i].ySpeed * -1
Increment score
END
IF (offScreen(balls[i]))
balls = remooveBall(balls, i)
Decrement score
END
END
END
9|Page
removeBall(balls, index)
10 | P a g e
Implementing phase
<work in progress>
Maintaining phase
Once you’ve managed to implement and successfully test the core required functionality, maintain
your game to include more features. Tips for some of these features are shown below.
11 | P a g e