Doxygen comments added

Dependencies:   mbed Gamepad N5110

Committer:
rafeh
Date:
Tue Apr 23 17:09:28 2019 +0000
Revision:
3:5409b50b01b0
Parent:
2:9f5714571c41
Child:
4:e98b22e5d5e8
updated classes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rafeh 0:43364ffd7cf6 1 /*
rafeh 0:43364ffd7cf6 2 ELEC2645 Embedded Systems Project
rafeh 0:43364ffd7cf6 3 School of Electronic & Electrical Engineering
rafeh 0:43364ffd7cf6 4 University of Leeds
rafeh 0:43364ffd7cf6 5 Name: Rafeh Ishtiaq
rafeh 0:43364ffd7cf6 6 Username: el17ri
rafeh 0:43364ffd7cf6 7 Student ID Number: 201062291
rafeh 0:43364ffd7cf6 8 Date: 20/03/2019
rafeh 0:43364ffd7cf6 9 */
rafeh 0:43364ffd7cf6 10
rafeh 0:43364ffd7cf6 11 #include "mbed.h"
rafeh 0:43364ffd7cf6 12 #include "N5110.h"
rafeh 0:43364ffd7cf6 13 #include "Gamepad.h"
rafeh 3:5409b50b01b0 14 #include "Pipes.h"
rafeh 3:5409b50b01b0 15 //#include "Bird.h"
rafeh 0:43364ffd7cf6 16
rafeh 0:43364ffd7cf6 17 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
rafeh 0:43364ffd7cf6 18 Gamepad pad;
rafeh 3:5409b50b01b0 19 //Bird bird;
rafeh 3:5409b50b01b0 20 Pipes pipes;
rafeh 3:5409b50b01b0 21
rafeh 3:5409b50b01b0 22 const int intro [40][40] =
rafeh 1:beceda7046fb 23 {
rafeh 1:beceda7046fb 24 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
rafeh 1:beceda7046fb 25 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
rafeh 1:beceda7046fb 26 0,0,0,0,0,0,0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,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
rafeh 1:beceda7046fb 58 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
rafeh 1:beceda7046fb 59 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
rafeh 1:beceda7046fb 60 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
rafeh 1:beceda7046fb 61 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
rafeh 1:beceda7046fb 62 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
rafeh 1:beceda7046fb 63 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
rafeh 0:43364ffd7cf6 64
rafeh 1:beceda7046fb 65 };
rafeh 0:43364ffd7cf6 66
rafeh 3:5409b50b01b0 67 const int moving [6][6] =
rafeh 2:9f5714571c41 68 {
rafeh 3:5409b50b01b0 69 0,0,1,1,0,0,
rafeh 3:5409b50b01b0 70 0,1,0,1,1,0,
rafeh 3:5409b50b01b0 71 1,0,1,1,1,1,
rafeh 3:5409b50b01b0 72 1,1,1,1,1,0,
rafeh 3:5409b50b01b0 73 0,1,1,1,1,0,
rafeh 3:5409b50b01b0 74 0,0,0,0,0,0,
rafeh 2:9f5714571c41 75
rafeh 2:9f5714571c41 76 };
rafeh 2:9f5714571c41 77
rafeh 0:43364ffd7cf6 78 void welcome();
rafeh 2:9f5714571c41 79 void start(int xaxis,int yaxis);
rafeh 3:5409b50b01b0 80 //void pipes(int pipex,int height);
rafeh 3:5409b50b01b0 81
rafeh 3:5409b50b01b0 82 int xaxis=25;
rafeh 3:5409b50b01b0 83 int yaxis=20;
rafeh 3:5409b50b01b0 84
rafeh 0:43364ffd7cf6 85 int main() {
rafeh 0:43364ffd7cf6 86 lcd.init();
rafeh 0:43364ffd7cf6 87 pad.init();
rafeh 0:43364ffd7cf6 88 lcd.clear();
rafeh 1:beceda7046fb 89 lcd.setContrast(0.5);
rafeh 1:beceda7046fb 90 welcome();
rafeh 2:9f5714571c41 91 if (pad.check_event(Gamepad::START_PRESSED) == false) {
rafeh 2:9f5714571c41 92 lcd.clear();
rafeh 2:9f5714571c41 93
rafeh 3:5409b50b01b0 94 int xvalue=84;
rafeh 3:5409b50b01b0 95 int height = rand() % (20 + 1 - 2) + 2;
rafeh 3:5409b50b01b0 96 int score = 0;
rafeh 3:5409b50b01b0 97 char scoredisplay[3];
rafeh 2:9f5714571c41 98 while(1) {
rafeh 3:5409b50b01b0 99 lcd.drawRect(0,45,84,3,FILL_BLACK);
rafeh 3:5409b50b01b0 100
rafeh 3:5409b50b01b0 101 //lcd.drawRect(xvalue,0,5,height,FILL_BLACK);
rafeh 3:5409b50b01b0 102 //lcd.drawRect(xvalue,(height+20),5,(84-(height+20)),FILL_BLACK);
rafeh 3:5409b50b01b0 103 //pipes.init(xvalue,height);
rafeh 3:5409b50b01b0 104 pipes.init(xvalue,height);
rafeh 3:5409b50b01b0 105 pipes.draw(lcd);
rafeh 3:5409b50b01b0 106 xvalue=xvalue-1;
rafeh 3:5409b50b01b0 107 sprintf(scoredisplay,"%d",score);
rafeh 3:5409b50b01b0 108 lcd.printString(scoredisplay,60,0);
rafeh 3:5409b50b01b0 109
rafeh 3:5409b50b01b0 110 if(xvalue<20 && xvalue>17) {
rafeh 3:5409b50b01b0 111 score=score+1;
rafeh 3:5409b50b01b0 112 }
rafeh 3:5409b50b01b0 113
rafeh 3:5409b50b01b0 114
rafeh 3:5409b50b01b0 115 if(xvalue<1) {
rafeh 3:5409b50b01b0 116 height=rand() % (20 + 1 - 2) + 2;
rafeh 3:5409b50b01b0 117 xvalue=84;
rafeh 3:5409b50b01b0 118 }
rafeh 3:5409b50b01b0 119
rafeh 3:5409b50b01b0 120 //pipes(xvalue,height);
rafeh 3:5409b50b01b0 121 //bird.init(xaxis,yaxis);
rafeh 3:5409b50b01b0 122 //bird.draw(lcd);
rafeh 3:5409b50b01b0 123 lcd.drawSprite(xaxis,yaxis,6,6,(int*)moving);
rafeh 2:9f5714571c41 124 yaxis=yaxis+2;
rafeh 2:9f5714571c41 125 if (pad.check_event(Gamepad::A_PRESSED) == true) {
rafeh 2:9f5714571c41 126 yaxis=yaxis-16;
rafeh 2:9f5714571c41 127 }
rafeh 3:5409b50b01b0 128 wait(0.075);
rafeh 3:5409b50b01b0 129 xvalue=xvalue-1;
rafeh 2:9f5714571c41 130 //wait(0.1);
rafeh 2:9f5714571c41 131 lcd.refresh();
rafeh 2:9f5714571c41 132 lcd.clear();
rafeh 2:9f5714571c41 133 }
rafeh 2:9f5714571c41 134 }
rafeh 3:5409b50b01b0 135
rafeh 3:5409b50b01b0 136
rafeh 2:9f5714571c41 137 }
rafeh 0:43364ffd7cf6 138
rafeh 2:9f5714571c41 139
rafeh 0:43364ffd7cf6 140
rafeh 0:43364ffd7cf6 141 void welcome() {
rafeh 3:5409b50b01b0 142 lcd.drawSprite(0,0,40,40,(int*)intro);
rafeh 1:beceda7046fb 143 lcd.printString(" Flappy ",40,0);
rafeh 1:beceda7046fb 144 lcd.printString(" Bird ",40,1);
rafeh 1:beceda7046fb 145 lcd.printString(" Press ",40,3);
rafeh 1:beceda7046fb 146 lcd.printString(" Start ",40,4);
rafeh 1:beceda7046fb 147 lcd.refresh();
rafeh 1:beceda7046fb 148 while ( pad.check_event(Gamepad::START_PRESSED) == false) {
rafeh 1:beceda7046fb 149 pad.leds_on();
rafeh 1:beceda7046fb 150 wait(0.1);
rafeh 1:beceda7046fb 151 pad.leds_off();
rafeh 1:beceda7046fb 152 wait(0.1);
rafeh 1:beceda7046fb 153 }
rafeh 2:9f5714571c41 154 }
rafeh 1:beceda7046fb 155
rafeh 2:9f5714571c41 156 void start(int xaxis,int yaxis) {
rafeh 3:5409b50b01b0 157 lcd.drawRect(0,45,84,3,FILL_BLACK);
rafeh 3:5409b50b01b0 158 int height = rand() % (20 + 1 - 2) + 2;
rafeh 3:5409b50b01b0 159 lcd.drawRect(40,0,5,height,FILL_BLACK);
rafeh 3:5409b50b01b0 160 lcd.drawSprite(xaxis,yaxis,9,9,(int*)moving);
rafeh 3:5409b50b01b0 161 yaxis=yaxis+2;
rafeh 3:5409b50b01b0 162 if (pad.check_event(Gamepad::A_PRESSED) == true) {
rafeh 3:5409b50b01b0 163 yaxis=yaxis-16;
rafeh 3:5409b50b01b0 164 }
rafeh 3:5409b50b01b0 165 wait(0.05);
rafeh 3:5409b50b01b0 166 //wait(0.1);
rafeh 3:5409b50b01b0 167 lcd.refresh();
rafeh 3:5409b50b01b0 168 lcd.clear();
rafeh 0:43364ffd7cf6 169
rafeh 3:5409b50b01b0 170 }
rafeh 3:5409b50b01b0 171
rafeh 3:5409b50b01b0 172
rafeh 3:5409b50b01b0 173
rafeh 3:5409b50b01b0 174