-
Notifications
You must be signed in to change notification settings - Fork 1
/
tog.pseudo
98 lines (91 loc) · 4.41 KB
/
tog.pseudo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
void DisplayStartScreen() {
DisplayTitleAndBackground;
PlayThemeMusic;
int XPositionDinosaur = RightEdge;
int DinosaurFigure = 1; /* There are 4 dinosaur figures according to what position the Dinosaur’s feet are in */
while (FireButtonNotPressed) {
while (DinosaurFigure <= 4) {
DisplayDinosaur(DinosaurFigure, XPositionDinosaur);
DinosaurFigure++;
XPositionDinosaur -= 5;
if ((FireButtonNotPressed) && (XPositionDinosaur <= LeftEdge)) XPositionDinosaur = RightEdge; }
Dinosaurfigure = 1; }
StopThemeMusic;
return; }
void GamePlay() {
DisplayStoryBackground;
While (FireButtonNotPressed)
for (int StoryLine = 0; StoryLine <= LastLineOfStory; StoryLine++) DisplayStoryLine(StoryLine);
DisplayStandardGameBackground;
int Level = 1;
int Score = 0;
int Lives = 3;
int XPositionPlayer = LeftEdge;
int XPositionDinosaur = RightEdge;
int DinosaurFigure = 1;
int PlayerFigure = 2; /* There are 3 player figures according to if the player is standing still (PlayerFigure = 2), moving to the left
(PlayerFigure = 1), or moving to the right (PlayerFigure = 3). */
bool PlayerAlive = TRUE;
bool DinosaurAlive = TRUE;
DisplayPlayer(XPositionPlayer, PlayerFigure);
while ((Level < MaxLevel) && (Lives > 0)) {
while ((DinosaurAlive) && (PlayerAlive)) {
if (NoJoystickMovement) || (JoystickUp) || (JoystickDown)) {
PlayerAlive = (XPositionPlayer < (XPositionDinosaur - MarginOfError));
if (DinosaurFigure <= 4) {
DisplayDinosaur(XPositionDinosaur, DinosaurFigure);
DinosaurFigure++;
XPositionDinosaur -= 5;
if (NoJoystickMovement) Wait(Level);
else if (Level < (MaxLevel – 2)) Wait(Level + 2);
else Wait(MaxLevel); }
else DinosaurFigure = 1; }
else if ((JoystickLeft) || (JoystickDiagUpLeft) || (JoystickDiagDownLeft)) {
PlayerAlive = (XPositionPlayer < (XPositionDinosaur - MarginOfError));
int InitPlayerPosition = XPlayerPosition;
int FinalPlayerPosition = XPlayerPosition – 5;
if (FinalPlayerPosition < LeftEdge) FinalPlayerPosition = LeftEdge;
PlayerFigure = 1; /* Facing left */
while (XPositionPlayer > FinalPlayerPosition) {
XPositionPlayer--;
DisplayPlayer(PlayerFigure, XPlayPOsition); }
}
if ((JoystickRight) || (JoystickDiagUpRight) || (JoystickDiagDownRight)) {
PlayerAlive = (XPositionPlayer < (XPositionDinosaur - MarginOfError));
int InitPlayerPosition = XPlayerPosition;
int FinalPlayerPosition = XPlayerPosition + 5;
PlayerFigure = 3; /* Facing right */
while (XPositionPlayer < FinalPlayerPosition) {
XPositionPlayer++;
DisplayPlayer(PlayerFigure, XPlayPOsition); }
}
else if (FireButtonPressed) {
int YPositionSpear = Ground;
int XPositionSpear = XPositionPlayer;
bool DinoHit = FALSE;
bool SpearFigure = FALSE; /* There are 2 spear figures, one for shooting up at 45 deg angle and one for going
straight down */
for (int YPositionSpear = Ground; YPositionSprear > TopOfScreen; YPositionSpear-- {
XPositionSpear++;
DisplaySpear(SpearFigure, XPositionSpear, YPositionSpear); }
SpearFigure = TRUE; /* Switch to falling spear */
For (int YPositionSpear = TopOfScreen; YPositionSpear < Ground; YPositionSpear++)
DisplaySpear(SpearFigure, XPositionSpear, YPositionSpear);
DinoAlive = !(Abs(XPositionSpear – XpositionDinosaur) <= 7); }
}
if (PlayerAlive) { /* Dinosaur dead */
KillDinosaur;
Score += 100;
Level++;
GoNewLevel; }
else { /* Player dead */
KillPlayer;
Lives--; }
}
if (Level == MaxLevel) ShowEndGameGraphics;
return; }
main() {
while(1) {
DisplayStartScreen();
GamePlay(); }
}