test

Dependencies:   mbed FXOS8700CQ

Committer:
Neowless
Date:
Fri May 15 17:44:25 2020 +0000
Revision:
2:cc9d8ec2e1f4
Parent:
1:48b0bf0bcda8
Child:
3:31ff7b3e2005
test;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Neowless 1:48b0bf0bcda8 1 #include "Bitmap.h"
Neowless 1:48b0bf0bcda8 2 #include "N5110.h"
Neowless 1:48b0bf0bcda8 3 #include "Gamepad.h"
Neowless 1:48b0bf0bcda8 4 #include "mbed.h"
Neowless 1:48b0bf0bcda8 5 #include "FXOS8700CQ.h"
Neowless 2:cc9d8ec2e1f4 6 #include "chara.h"
Neowless 1:48b0bf0bcda8 7 #include "life.h"
Neowless 1:48b0bf0bcda8 8 #include "engine.h"
Neowless 1:48b0bf0bcda8 9 #include "N5110.h"
Neowless 1:48b0bf0bcda8 10 #include "Gamepad.h"
Neowless 1:48b0bf0bcda8 11 #include<iostream>
Neowless 1:48b0bf0bcda8 12
Neowless 1:48b0bf0bcda8 13 using namespace std;
Neowless 1:48b0bf0bcda8 14 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Neowless 1:48b0bf0bcda8 15 FXOS8700CQ device(I2C_SDA,I2C_SCL);
Neowless 1:48b0bf0bcda8 16 Gamepad pad;
Neowless 2:cc9d8ec2e1f4 17 chara p;
Neowless 1:48b0bf0bcda8 18 life lf;
Neowless 1:48b0bf0bcda8 19 engine eg;
Neowless 1:48b0bf0bcda8 20 bool n = true;
Neowless 2:cc9d8ec2e1f4 21 obs bo[20];
Neowless 1:48b0bf0bcda8 22 int bonum = 0;
Neowless 1:48b0bf0bcda8 23 int score = 0;
Neowless 1:48b0bf0bcda8 24 int m = 0;
Neowless 2:cc9d8ec2e1f4 25 float fps=15;
Neowless 1:48b0bf0bcda8 26
Neowless 1:48b0bf0bcda8 27 void init();
Neowless 1:48b0bf0bcda8 28 void welcome();
Neowless 1:48b0bf0bcda8 29 void screen();
Neowless 1:48b0bf0bcda8 30 void update();
Neowless 1:48b0bf0bcda8 31 void gameover();
Neowless 1:48b0bf0bcda8 32 void drawBitmap(int x, int y, int width, int height, int *data);
Neowless 2:cc9d8ec2e1f4 33 void setting();
Neowless 2:cc9d8ec2e1f4 34 void renderj(int x, int y);
Neowless 2:cc9d8ec2e1f4 35 void rendere(int x, int y);
Neowless 2:cc9d8ec2e1f4 36 void rendert(int x, int y);
Neowless 2:cc9d8ec2e1f4 37 void renderp(int x, int y);
Neowless 2:cc9d8ec2e1f4 38 void rendera(int x, int y);
Neowless 2:cc9d8ec2e1f4 39 void renderc(int x, int y);
Neowless 2:cc9d8ec2e1f4 40 void renderk(int x, int y);
Neowless 1:48b0bf0bcda8 41
Neowless 1:48b0bf0bcda8 42 int main()
Neowless 1:48b0bf0bcda8 43 {
Neowless 1:48b0bf0bcda8 44 while(1){
Neowless 1:48b0bf0bcda8 45 init();
Neowless 1:48b0bf0bcda8 46 welcome();
Neowless 2:cc9d8ec2e1f4 47 setting();
Neowless 2:cc9d8ec2e1f4 48
Neowless 1:48b0bf0bcda8 49 while(n){
Neowless 2:cc9d8ec2e1f4 50 if(m%19==0){
Neowless 2:cc9d8ec2e1f4 51 bo[bonum%20].y = eg.randomobs();
Neowless 1:48b0bf0bcda8 52 bo[bonum%20].x = 82;
Neowless 1:48b0bf0bcda8 53 bonum = bonum + 1;
Neowless 1:48b0bf0bcda8 54 }
Neowless 1:48b0bf0bcda8 55
Neowless 1:48b0bf0bcda8 56 lcd.clear();
Neowless 1:48b0bf0bcda8 57 screen();
Neowless 1:48b0bf0bcda8 58 update();
Neowless 1:48b0bf0bcda8 59 lcd.refresh();
Neowless 2:cc9d8ec2e1f4 60 cout<<fps<<endl;
Neowless 2:cc9d8ec2e1f4 61 wait(fps);
Neowless 1:48b0bf0bcda8 62 m = m + 1;
Neowless 2:cc9d8ec2e1f4 63
Neowless 1:48b0bf0bcda8 64 }
Neowless 1:48b0bf0bcda8 65 wait(1);
Neowless 1:48b0bf0bcda8 66 }
Neowless 1:48b0bf0bcda8 67 }
Neowless 1:48b0bf0bcda8 68
Neowless 1:48b0bf0bcda8 69 void init(){
Neowless 1:48b0bf0bcda8 70 device.init();
Neowless 1:48b0bf0bcda8 71 lcd.init();
Neowless 1:48b0bf0bcda8 72 pad.init();
Neowless 1:48b0bf0bcda8 73 p.init();
Neowless 1:48b0bf0bcda8 74 lf.init();
Neowless 1:48b0bf0bcda8 75 eg.init();
Neowless 1:48b0bf0bcda8 76 lcd.setContrast(0.5);
Neowless 1:48b0bf0bcda8 77 n = true;
Neowless 2:cc9d8ec2e1f4 78
Neowless 1:48b0bf0bcda8 79 bonum = 0;
Neowless 1:48b0bf0bcda8 80 score = 0;
Neowless 1:48b0bf0bcda8 81 m = 0;
Neowless 1:48b0bf0bcda8 82 for(int i = 0; i < 20; i++){
Neowless 1:48b0bf0bcda8 83 bo[i].x = -1;
Neowless 1:48b0bf0bcda8 84 bo[i].y = -1;
Neowless 2:cc9d8ec2e1f4 85 bo[i].width = 9;
Neowless 2:cc9d8ec2e1f4 86 bo[i].height = 5;
Neowless 2:cc9d8ec2e1f4 87 int data[45]= {
Neowless 2:cc9d8ec2e1f4 88 0,1,0,1,0,1,0,1,0,
Neowless 2:cc9d8ec2e1f4 89 1,0,1,0,1,0,1,0,1,
Neowless 2:cc9d8ec2e1f4 90 1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 91 1,0,1,0,1,0,1,0,1,
Neowless 2:cc9d8ec2e1f4 92 0,1,0,1,0,1,0,1,0
Neowless 2:cc9d8ec2e1f4 93
Neowless 2:cc9d8ec2e1f4 94
Neowless 1:48b0bf0bcda8 95 };
Neowless 2:cc9d8ec2e1f4 96
Neowless 1:48b0bf0bcda8 97 bo[i].data = data;
Neowless 1:48b0bf0bcda8 98 }
Neowless 1:48b0bf0bcda8 99 }
Neowless 1:48b0bf0bcda8 100
Neowless 2:cc9d8ec2e1f4 101 void renderj(int x,int y){
Neowless 2:cc9d8ec2e1f4 102 int j[153]={
Neowless 2:cc9d8ec2e1f4 103 1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 104 1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 105 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 106 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 107 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 108 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 109 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 110 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 111 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 112 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 113 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 114 0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 115 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 116 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 117 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 118 1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 119 1,1,1,1,1,1,1,1,1
Neowless 2:cc9d8ec2e1f4 120 };
Neowless 2:cc9d8ec2e1f4 121 Bitmap jj(j,17,9);
Neowless 2:cc9d8ec2e1f4 122 jj.render(lcd, x, y);
Neowless 2:cc9d8ec2e1f4 123 }
Neowless 2:cc9d8ec2e1f4 124
Neowless 2:cc9d8ec2e1f4 125 void rendere(int x,int y){
Neowless 2:cc9d8ec2e1f4 126 int e[136]={
Neowless 2:cc9d8ec2e1f4 127 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 128 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 129 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 130 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 131 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 132 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 133 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 134 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 135 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 136 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 137 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 138 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 139 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 140 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 141 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 142 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 143 1,1,1,1,1,1,1,1
Neowless 2:cc9d8ec2e1f4 144 };
Neowless 2:cc9d8ec2e1f4 145 Bitmap ee(e,17,8);
Neowless 2:cc9d8ec2e1f4 146 ee.render(lcd, x, y);
Neowless 2:cc9d8ec2e1f4 147 }
Neowless 2:cc9d8ec2e1f4 148
Neowless 2:cc9d8ec2e1f4 149 void rendert(int x,int y){
Neowless 2:cc9d8ec2e1f4 150 int t[170]={
Neowless 2:cc9d8ec2e1f4 151 1,1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 152 1,1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 153 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 154 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 155 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 156 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 157 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 158 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 159 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 160 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 161 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 162 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 163 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 164 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 165 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 166 0,0,0,0,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 167 0,0,0,0,1,1,0,0,0,0
Neowless 2:cc9d8ec2e1f4 168 };
Neowless 2:cc9d8ec2e1f4 169 Bitmap tt(t,17,10);
Neowless 2:cc9d8ec2e1f4 170 tt.render(lcd, x, y);
Neowless 2:cc9d8ec2e1f4 171 }
Neowless 2:cc9d8ec2e1f4 172
Neowless 2:cc9d8ec2e1f4 173 void renderp(int x,int y){
Neowless 2:cc9d8ec2e1f4 174 int p[153]={
Neowless 2:cc9d8ec2e1f4 175 1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 176 1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 177 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 178 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 179 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 180 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 181 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 182 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 183 1,1,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 184 1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 185 1,1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 186 1,1,0,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 187 1,1,0,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 188 1,1,0,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 189 1,1,0,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 190 1,1,0,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 191 1,1,0,0,0,0,0,0,0
Neowless 2:cc9d8ec2e1f4 192 };
Neowless 2:cc9d8ec2e1f4 193 Bitmap pp(p,17,9);
Neowless 2:cc9d8ec2e1f4 194 pp.render(lcd, x, y);
Neowless 2:cc9d8ec2e1f4 195 }
Neowless 2:cc9d8ec2e1f4 196
Neowless 2:cc9d8ec2e1f4 197 void rendera(int x,int y){
Neowless 2:cc9d8ec2e1f4 198 int a[136]={
Neowless 2:cc9d8ec2e1f4 199 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 200 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 201 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 202 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 203 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 204 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 205 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 206 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 207 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 208 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 209 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 210 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 211 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 212 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 213 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 214 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 215 1,1,0,0,0,0,1,1
Neowless 2:cc9d8ec2e1f4 216 };
Neowless 2:cc9d8ec2e1f4 217 Bitmap aa(a,17,8);
Neowless 2:cc9d8ec2e1f4 218 aa.render(lcd, x, y);
Neowless 2:cc9d8ec2e1f4 219 }
Neowless 2:cc9d8ec2e1f4 220
Neowless 2:cc9d8ec2e1f4 221 void renderc(int x,int y){
Neowless 2:cc9d8ec2e1f4 222 int c[136]={
Neowless 2:cc9d8ec2e1f4 223 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 224 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 225 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 226 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 227 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 228 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 229 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 230 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 231 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 232 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 233 1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 234 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 235 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 236 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 237 1,1,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 238 1,1,1,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 239 1,1,1,1,1,1,1,1
Neowless 2:cc9d8ec2e1f4 240 };
Neowless 2:cc9d8ec2e1f4 241 Bitmap cc(c,17,8);
Neowless 2:cc9d8ec2e1f4 242 cc.render(lcd, x, y);
Neowless 2:cc9d8ec2e1f4 243 }
Neowless 2:cc9d8ec2e1f4 244
Neowless 2:cc9d8ec2e1f4 245 void renderk(int x,int y){
Neowless 2:cc9d8ec2e1f4 246 int k[187]={
Neowless 2:cc9d8ec2e1f4 247 1,1,0,0,0,0,0,0,0,1,1,
Neowless 2:cc9d8ec2e1f4 248 1,1,0,0,0,0,0,0,1,1,1,
Neowless 2:cc9d8ec2e1f4 249 1,1,0,0,0,0,0,1,1,1,0,
Neowless 2:cc9d8ec2e1f4 250 1,1,0,0,0,0,1,1,1,0,0,
Neowless 2:cc9d8ec2e1f4 251 1,1,0,0,0,1,1,1,0,0,0,
Neowless 2:cc9d8ec2e1f4 252 1,1,0,0,1,1,1,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 253 1,1,0,1,1,1,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 254 1,1,1,1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 255 1,1,0,0,0,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 256 1,1,0,0,0,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 257 1,1,1,1,0,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 258 1,1,1,1,1,0,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 259 1,1,0,1,1,1,0,0,0,0,0,
Neowless 2:cc9d8ec2e1f4 260 1,1,0,0,1,1,1,1,0,0,0,
Neowless 2:cc9d8ec2e1f4 261 1,1,0,0,0,1,1,1,0,0,0,
Neowless 2:cc9d8ec2e1f4 262 1,1,0,0,0,0,1,1,1,1,1,
Neowless 2:cc9d8ec2e1f4 263 1,1,0,0,0,0,0,1,1,1,1
Neowless 2:cc9d8ec2e1f4 264 };
Neowless 2:cc9d8ec2e1f4 265 Bitmap kk(k,17,11);
Neowless 2:cc9d8ec2e1f4 266 kk.render(lcd, x, y);
Neowless 2:cc9d8ec2e1f4 267 }
Neowless 2:cc9d8ec2e1f4 268
Neowless 2:cc9d8ec2e1f4 269
Neowless 1:48b0bf0bcda8 270 void welcome(){
Neowless 1:48b0bf0bcda8 271 lcd.clear();
Neowless 2:cc9d8ec2e1f4 272 for(int i = 1;i<=60;i++){
Neowless 2:cc9d8ec2e1f4 273 lcd.clear();
Neowless 2:cc9d8ec2e1f4 274 int jy = 40-i;
Neowless 2:cc9d8ec2e1f4 275 if (jy<=0){
Neowless 2:cc9d8ec2e1f4 276 jy = 1;
Neowless 2:cc9d8ec2e1f4 277 }
Neowless 2:cc9d8ec2e1f4 278 int ey = 45-i;
Neowless 2:cc9d8ec2e1f4 279 if (ey<=0){
Neowless 2:cc9d8ec2e1f4 280 ey = 1;
Neowless 2:cc9d8ec2e1f4 281 }
Neowless 2:cc9d8ec2e1f4 282 int ty = 50-i;
Neowless 2:cc9d8ec2e1f4 283 if (ty<=0){
Neowless 2:cc9d8ec2e1f4 284 ty = 1;
Neowless 2:cc9d8ec2e1f4 285 }
Neowless 2:cc9d8ec2e1f4 286 int py = 50-i;
Neowless 2:cc9d8ec2e1f4 287 if (py<=0){
Neowless 2:cc9d8ec2e1f4 288 py = 1;
Neowless 2:cc9d8ec2e1f4 289 }
Neowless 2:cc9d8ec2e1f4 290 int ay = 52-i;
Neowless 2:cc9d8ec2e1f4 291 if (ay<=0){
Neowless 2:cc9d8ec2e1f4 292 ay = 1;
Neowless 2:cc9d8ec2e1f4 293 }
Neowless 2:cc9d8ec2e1f4 294 int cy = 54-i;
Neowless 2:cc9d8ec2e1f4 295 if (cy<=0){
Neowless 2:cc9d8ec2e1f4 296 cy = 1;
Neowless 2:cc9d8ec2e1f4 297 }
Neowless 2:cc9d8ec2e1f4 298 int ky = 56-i;
Neowless 2:cc9d8ec2e1f4 299 if (ky<=0){
Neowless 2:cc9d8ec2e1f4 300 ky = 1;
Neowless 2:cc9d8ec2e1f4 301 }
Neowless 2:cc9d8ec2e1f4 302
Neowless 2:cc9d8ec2e1f4 303 renderj(6,jy);
Neowless 2:cc9d8ec2e1f4 304 rendere(17,ey);
Neowless 2:cc9d8ec2e1f4 305 rendert(27,ty);
Neowless 2:cc9d8ec2e1f4 306 renderp(39,py);
Neowless 2:cc9d8ec2e1f4 307 rendera(50,ay);
Neowless 2:cc9d8ec2e1f4 308 renderc(60,cy);
Neowless 2:cc9d8ec2e1f4 309 renderk(70,ky);
Neowless 2:cc9d8ec2e1f4 310 wait(0.05);
Neowless 2:cc9d8ec2e1f4 311 lcd.refresh();
Neowless 2:cc9d8ec2e1f4 312 }
Neowless 2:cc9d8ec2e1f4 313 lcd.printString("PERSS START",6,5);
Neowless 2:cc9d8ec2e1f4 314
Neowless 1:48b0bf0bcda8 315 lcd.refresh();
Neowless 1:48b0bf0bcda8 316 while( pad.check_event(Gamepad::START_PRESSED) == false){
Neowless 1:48b0bf0bcda8 317 pad.leds_on();
Neowless 1:48b0bf0bcda8 318 wait(0.1);
Neowless 1:48b0bf0bcda8 319 pad.leds_off();
Neowless 1:48b0bf0bcda8 320 wait(0.1);
Neowless 2:cc9d8ec2e1f4 321
Neowless 2:cc9d8ec2e1f4 322 }
Neowless 2:cc9d8ec2e1f4 323 }
Neowless 2:cc9d8ec2e1f4 324
Neowless 2:cc9d8ec2e1f4 325 void setting(){
Neowless 2:cc9d8ec2e1f4 326 lcd.clear();
Neowless 2:cc9d8ec2e1f4 327 lcd.printString("SET DIFFICULTY",0,0);
Neowless 2:cc9d8ec2e1f4 328 lcd.printString("A EZ",0,2);
Neowless 2:cc9d8ec2e1f4 329 lcd.printString("B Default",0,3);
Neowless 2:cc9d8ec2e1f4 330 lcd.printString("X Difficult",0,4);
Neowless 2:cc9d8ec2e1f4 331 lcd.printString("Y NIGHTMARE",0,5);
Neowless 2:cc9d8ec2e1f4 332 lcd.refresh();
Neowless 2:cc9d8ec2e1f4 333 while(1){
Neowless 2:cc9d8ec2e1f4 334 if( pad.check_event(Gamepad::A_PRESSED) == true){
Neowless 2:cc9d8ec2e1f4 335 fps = 0.2;
Neowless 2:cc9d8ec2e1f4 336 break;
Neowless 2:cc9d8ec2e1f4 337 }
Neowless 2:cc9d8ec2e1f4 338 if( pad.check_event(Gamepad::B_PRESSED) == true){
Neowless 2:cc9d8ec2e1f4 339 fps = 0.1;
Neowless 2:cc9d8ec2e1f4 340 break;
Neowless 2:cc9d8ec2e1f4 341 }
Neowless 2:cc9d8ec2e1f4 342 if( pad.check_event(Gamepad::X_PRESSED) == true){
Neowless 2:cc9d8ec2e1f4 343 fps = 0.05;
Neowless 2:cc9d8ec2e1f4 344 break;
Neowless 2:cc9d8ec2e1f4 345 }
Neowless 2:cc9d8ec2e1f4 346 if( pad.check_event(Gamepad::Y_PRESSED) == true){
Neowless 2:cc9d8ec2e1f4 347 fps = 0.01;
Neowless 2:cc9d8ec2e1f4 348 break;
Neowless 2:cc9d8ec2e1f4 349 }
Neowless 2:cc9d8ec2e1f4 350 pad.leds_on();
Neowless 2:cc9d8ec2e1f4 351 wait(0.1);
Neowless 2:cc9d8ec2e1f4 352 pad.leds_off();
Neowless 2:cc9d8ec2e1f4 353 wait(0.1);
Neowless 2:cc9d8ec2e1f4 354
Neowless 1:48b0bf0bcda8 355 }
Neowless 1:48b0bf0bcda8 356 }
Neowless 1:48b0bf0bcda8 357
Neowless 1:48b0bf0bcda8 358 void screen(){
Neowless 1:48b0bf0bcda8 359 lcd.clear();
Neowless 1:48b0bf0bcda8 360 p.display(lcd);
Neowless 1:48b0bf0bcda8 361 lf.display(lcd);
Neowless 1:48b0bf0bcda8 362 for(int i = 0; i <20; i++){
Neowless 1:48b0bf0bcda8 363 if(bo[i].x >=0){
Neowless 1:48b0bf0bcda8 364 drawBitmap(bo[i].x, bo[i].y, bo[i].width, bo[i].height, bo[i].data);}
Neowless 1:48b0bf0bcda8 365 }
Neowless 1:48b0bf0bcda8 366 lcd.refresh();
Neowless 1:48b0bf0bcda8 367 }
Neowless 1:48b0bf0bcda8 368
Neowless 1:48b0bf0bcda8 369 void update(){
Neowless 1:48b0bf0bcda8 370 p.update(pad, device);
Neowless 1:48b0bf0bcda8 371 for(int i = 0; i<20; i++){
Neowless 1:48b0bf0bcda8 372 for(int j = 0; j < 20; j++){
Neowless 2:cc9d8ec2e1f4 373 events e = eg.evet_check(p, bo[i],pad);
Neowless 1:48b0bf0bcda8 374 if(e == DEAD){
Neowless 1:48b0bf0bcda8 375 lf.update();
Neowless 1:48b0bf0bcda8 376 bo[i].x = -1;
Neowless 1:48b0bf0bcda8 377 pad.tone(1000,0.2);
Neowless 1:48b0bf0bcda8 378 if(lf.liferest()==0){
Neowless 1:48b0bf0bcda8 379 gameover();
Neowless 1:48b0bf0bcda8 380 i = 20;
Neowless 1:48b0bf0bcda8 381 j = 20;
Neowless 1:48b0bf0bcda8 382 pad.tone(1000,0.5);
Neowless 1:48b0bf0bcda8 383 break;
Neowless 1:48b0bf0bcda8 384 }
Neowless 1:48b0bf0bcda8 385 }else if(e == ELMININATE){
Neowless 1:48b0bf0bcda8 386 bo[i].x = -1;
Neowless 1:48b0bf0bcda8 387 score = score + 5;
Neowless 1:48b0bf0bcda8 388 cout <<score<<endl;
Neowless 1:48b0bf0bcda8 389 }
Neowless 1:48b0bf0bcda8 390 }
Neowless 1:48b0bf0bcda8 391 }
Neowless 1:48b0bf0bcda8 392 for(int i = 0; i<20; i++){
Neowless 1:48b0bf0bcda8 393 if((bo[i].x >=0) && (bo[i].x<=84)){
Neowless 1:48b0bf0bcda8 394 bo[i].x = bo[i].x - 1;
Neowless 1:48b0bf0bcda8 395 }
Neowless 1:48b0bf0bcda8 396 }
Neowless 1:48b0bf0bcda8 397
Neowless 1:48b0bf0bcda8 398 }
Neowless 1:48b0bf0bcda8 399
Neowless 1:48b0bf0bcda8 400 void gameover(){
Neowless 1:48b0bf0bcda8 401 cout <<"game over"<< endl;
Neowless 1:48b0bf0bcda8 402 lcd.clear();
Neowless 1:48b0bf0bcda8 403 lcd.printString("GAMEOVER ",0,1);
Neowless 1:48b0bf0bcda8 404 lcd.printString("SCORE ",0,2);
Neowless 1:48b0bf0bcda8 405 char buffer1[14];
Neowless 1:48b0bf0bcda8 406 sprintf(buffer1,"%2d",score);
Neowless 1:48b0bf0bcda8 407 lcd.printString(buffer1,0,3);
Neowless 1:48b0bf0bcda8 408 lcd.printString(" Press A ",0,4);
Neowless 1:48b0bf0bcda8 409 lcd.refresh();
Neowless 1:48b0bf0bcda8 410 while ( pad.check_event(Gamepad::A_PRESSED) == false) {
Neowless 1:48b0bf0bcda8 411 pad.leds_on();
Neowless 1:48b0bf0bcda8 412 wait(0.1);
Neowless 1:48b0bf0bcda8 413 pad.leds_off();
Neowless 1:48b0bf0bcda8 414 wait(0.1);
Neowless 1:48b0bf0bcda8 415 }
Neowless 1:48b0bf0bcda8 416 n = false;
Neowless 1:48b0bf0bcda8 417 }
Neowless 1:48b0bf0bcda8 418
Neowless 1:48b0bf0bcda8 419 void drawBitmap(int x, int y, int width, int height, int *data){
Neowless 1:48b0bf0bcda8 420 Bitmap p(data, height, width);
Neowless 1:48b0bf0bcda8 421 p.render(lcd, x, y);
Neowless 1:48b0bf0bcda8 422 }
Neowless 1:48b0bf0bcda8 423