Flappy Bird game on mbed with a micro LCD screen, class D amp, speaker, SD card reader/writer, 5-button navigation switch, and potentiometer speed control
Dependencies: 4DGL-uLCD-SE PinDetect SDFileSystem mbed-rtos mbed
bird.cpp
00001 #include "bird.h" 00002 00003 Bird::Bird(){ 00004 x = 16; // the bird starts 16 pixels from the left side of the screen 00005 y = 64; // the bird starts 64 pixels from the top of the screen 00006 } 00007 00008 int Bird::getOldY() { 00009 return oldY; 00010 } 00011 00012 int Bird::getX(){ 00013 return x; 00014 } 00015 00016 int Bird::getY(){ 00017 return y; 00018 } 00019 00020 int Bird::getWidth(){ 00021 return width; 00022 } 00023 00024 int Bird::getHeight(){ 00025 return height; 00026 } 00027 00028 void Bird::move(directionType direction){ 00029 oldY = y; // store old y position 00030 switch (direction){ 00031 case DIRECTION_UP: // the player pressed up 00032 y -= moveDistance; // the bird moves up by a constant distance 00033 break; 00034 case DIRECTION_DOWN: // the player pressed down 00035 y += moveDistance; // the bird moves down by a constant distance 00036 break; 00037 } 00038 }
Generated on Tue Jul 19 2022 06:40:37 by 1.7.2