Stick_Runner

Dependencies:   FXOS8700CQ Gamepad N5110 SDFileSystem mbed

Committer:
el15ss
Date:
Fri Apr 28 16:30:47 2017 +0000
Revision:
1:db9ff66f67c8
Parent:
0:12cfe63faa6a
Child:
2:98a41609c827
Need to add accelerometer functonality

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el15ss 0:12cfe63faa6a 1 #include "Gems.h"
el15ss 0:12cfe63faa6a 2
el15ss 0:12cfe63faa6a 3 Gems::Gems()
el15ss 0:12cfe63faa6a 4 {
el15ss 0:12cfe63faa6a 5
el15ss 0:12cfe63faa6a 6 }
el15ss 0:12cfe63faa6a 7
el15ss 0:12cfe63faa6a 8 Gems::~Gems()
el15ss 0:12cfe63faa6a 9 {
el15ss 0:12cfe63faa6a 10
el15ss 0:12cfe63faa6a 11 }
el15ss 0:12cfe63faa6a 12
el15ss 0:12cfe63faa6a 13 void Gems::init()
el15ss 0:12cfe63faa6a 14 {
el15ss 1:db9ff66f67c8 15 gemPosX = rand() % 84;
el15ss 1:db9ff66f67c8 16 gemPosY = rand() % 42-42;
el15ss 1:db9ff66f67c8 17
el15ss 1:db9ff66f67c8 18 gStatus = true;
el15ss 1:db9ff66f67c8 19
el15ss 0:12cfe63faa6a 20 }
el15ss 0:12cfe63faa6a 21
el15ss 0:12cfe63faa6a 22 void Gems::draw(N5110 &lcd)
el15ss 0:12cfe63faa6a 23 {
el15ss 0:12cfe63faa6a 24 // draw Gemss in screen buffer.
el15ss 1:db9ff66f67c8 25 //lcd.drawRect(gemPosX-4,gemPosY-3,3,3,FILL_BLACK);
el15ss 1:db9ff66f67c8 26 //lcd.drawLine(gemPosX-3, gemPosY-3,gemPosX-3,gemPosY+1,1);
el15ss 0:12cfe63faa6a 27
el15ss 1:db9ff66f67c8 28 //lcd.drawCircle(gemPosX,gemPosY,2,FILL_BLACK);
el15ss 1:db9ff66f67c8 29 lcd.setPixel(gemPosX,gemPosY);
el15ss 1:db9ff66f67c8 30 lcd.setPixel(gemPosX+1,gemPosY);
el15ss 1:db9ff66f67c8 31 lcd.setPixel(gemPosX-1,gemPosY);
el15ss 1:db9ff66f67c8 32 lcd.setPixel(gemPosX,gemPosY+1);
el15ss 1:db9ff66f67c8 33 lcd.setPixel(gemPosX,gemPosY-1);
el15ss 0:12cfe63faa6a 34
el15ss 0:12cfe63faa6a 35
el15ss 0:12cfe63faa6a 36
el15ss 0:12cfe63faa6a 37
el15ss 0:12cfe63faa6a 38 }
el15ss 0:12cfe63faa6a 39
el15ss 1:db9ff66f67c8 40 void Gems::gemStatus(Vector2D p)
el15ss 0:12cfe63faa6a 41 {
el15ss 1:db9ff66f67c8 42 if(((gemPosX>p.x-5)&&(gemPosX<p.x+5))&&(gemPosY>p.y))
el15ss 1:db9ff66f67c8 43 {
el15ss 1:db9ff66f67c8 44 //counter++;
el15ss 1:db9ff66f67c8 45 gStatus = false;
el15ss 1:db9ff66f67c8 46 }
el15ss 1:db9ff66f67c8 47
el15ss 1:db9ff66f67c8 48
el15ss 1:db9ff66f67c8 49
el15ss 0:12cfe63faa6a 50
el15ss 1:db9ff66f67c8 51 if(gemPosY > HEIGHT)
el15ss 1:db9ff66f67c8 52 {
el15ss 1:db9ff66f67c8 53 gStatus = false;
el15ss 1:db9ff66f67c8 54 }
el15ss 0:12cfe63faa6a 55 }
el15ss 0:12cfe63faa6a 56
el15ss 1:db9ff66f67c8 57 int Gems::gemScore()
el15ss 0:12cfe63faa6a 58 {
el15ss 1:db9ff66f67c8 59 //return counter;
el15ss 0:12cfe63faa6a 60 }
el15ss 0:12cfe63faa6a 61
el15ss 1:db9ff66f67c8 62 void Gems::updateGems()
el15ss 0:12cfe63faa6a 63 {
el15ss 1:db9ff66f67c8 64 gemPosY =gemPosY+2;
el15ss 1:db9ff66f67c8 65
el15ss 0:12cfe63faa6a 66 }
el15ss 0:12cfe63faa6a 67
el15ss 0:12cfe63faa6a 68
el15ss 0:12cfe63faa6a 69
el15ss 1:db9ff66f67c8 70 Vector2D Gems::getGemPos()
el15ss 1:db9ff66f67c8 71 {
el15ss 1:db9ff66f67c8 72 Vector2D p = {gemPosX,gemPosY};
el15ss 0:12cfe63faa6a 73 return p;
el15ss 0:12cfe63faa6a 74 }
el15ss 1:db9ff66f67c8 75
el15ss 1:db9ff66f67c8 76 bool Gems::getGemStatus()
el15ss 1:db9ff66f67c8 77 {
el15ss 1:db9ff66f67c8 78 return gStatus;
el15ss 0:12cfe63faa6a 79
el15ss 0:12cfe63faa6a 80 }
el15ss 0:12cfe63faa6a 81
el15ss 0:12cfe63faa6a 82