Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Spikes.cpp
00001 #include "Spikes.h" 00002 00003 const int spike [5][5] = 00004 { 00005 {0,0,1,0,0}, 00006 {0,0,1,0,0}, 00007 {1,1,1,1,1}, 00008 {0,1,1,1,0}, 00009 {0,0,1,0,0}, 00010 }; 00011 00012 Spikes::Spikes() 00013 { 00014 00015 } 00016 00017 Spikes::~Spikes() 00018 { 00019 00020 } 00021 00022 void Spikes::init(){ 00023 _x = 0; 00024 _y = 0; 00025 _height = 5; 00026 _width = 5; 00027 00028 _speed = 3; 00029 } 00030 00031 00032 void Spikes::draw(N5110 &lcd) 00033 { 00034 // draw spike 00035 lcd.drawSprite(_x,_y,5,5,(int*)spike); 00036 00037 } 00038 00039 void Spikes::position(int x) 00040 { 00041 if (x == 1){ 00042 _x = rand() % 37 + 1; 00043 _y = 1; 00044 } 00045 if (x == 2){ 00046 _x = rand() % 37 + 42; 00047 _y = 1; 00048 } 00049 } 00050 00051 void Spikes::update() 00052 { 00053 _y = _y + 3; 00054 } 00055 00056 Vector2D Spikes::get_pos() { 00057 Vector2D p = {_x,_y}; 00058 return p; 00059 } 00060 00061 void Spikes::hit(Gamepad &pad) 00062 { 00063 pad.led(1,1); 00064 pad.led(4,1); 00065 } 00066 00067
Generated on Wed Jul 13 2022 05:56:35 by
1.7.2