Asteroids for MBED game with Bluetooth LE UART Friend Controller, uLCD, speaker, and uSD.
Dependencies: 4DGL-uLCD-SE mbed-rtos mbed
Asteroids for MBED game with Bluetooth LE UART Friend Controller
Diff: main.cpp
- Revision:
- 2:332ca4f1a3e3
- Parent:
- 1:0328ad927150
- Child:
- 3:14a2729625f6
--- a/main.cpp Sat Mar 12 01:23:40 2016 +0000 +++ b/main.cpp Sat Mar 12 01:52:01 2016 +0000 @@ -4,9 +4,12 @@ #include <math.h> #include <list> using namespace std; - +//constants +#define ACCEL = .5 +#define ROTTA = .2 +//devices DigitalOut myled(LED1); -uLCD_4DGL uLCD(p28,p27,p29); +uLCD_4DGL ulcd(p28,p27,p29); class Movement { @@ -21,6 +24,7 @@ Movement(double xp,double yp,double xv,double yv,double a,double r,double w); void move(); void accelerate(); + void }; @@ -40,20 +44,27 @@ { x_pos += x_vel; y_pos += y_vel; - + if(x_pos < 0 || x_pos > 144 && x_pos < 0 || x_pos > 144) { + if(wrap) { + x_pos = 144(1 - ceil(x_pos/144)) + x_pos; + y_pos = 144(1 - ceil(y_pos/144)) + y_pos; + } else { + } + } + } void Movement::accelerate() { - x_vel += cos(angle); - y_vel += sin(angle); - if(sqrt(pow(x_vel,2) + pow(y_vel,2)) > 10){ + x_vel += ACCEL * cos(angle); + y_vel += ACCEL * sin(angle); + if(sqrt(pow(x_vel,2) + pow(y_vel,2)) > 10) { x_vel = x_vel * 10 / sqrt(pow(x_vel,2) + pow(y_vel,2)); y_vel = y_vel * 10 / sqrt(pow(x_vel,2) + pow(y_vel,2)); } } - +//collisions bool collision(Movement p1, Movement p2) { int rad = p1.hit_rad + p2.hit_rad; @@ -61,12 +72,14 @@ return dist < rad; } -void calc_collisions(){ +void calc_collisions(Movement player, list<Movement> asteroids, list<Movement> bullets) +{ } -void draw_objs(Movement player, list<Movement> asteroids, list<Movement> bullets){ - -} +//drawing +void draw_objs(Movement player, list<Movement> asteroids, list<Movement> bullets) +{ +} int main() {