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.
Dependencies: mbed 4DGL-uLCD-SE PinDetect
ConcreteAsteroid3.cpp
00001 #include "uLCD_4DGL.h" 00002 #include "ConcreteAsteroid3.h" 00003 #include "AbsAst.h" 00004 #include <math.h> 00005 00006 extern int asteroid_sprite_3; 00007 extern uLCD_4DGL uLCD; 00008 00009 #define ASTEROID_HEIGHT 12 00010 #define ASTEROID_WIDTH 15 00011 #define SPRITE_MAX 15 00012 #define SCREEN_MAX 125 00013 #define SCREEN_MIN 1 00014 #define NUM_ASTEROIDS 4 00015 00016 ConcreteAsteroid3::ConcreteAsteroid3(){ 00017 //START IN RANDOM YPOS AND MAX XPOS 00018 xpos = SCREEN_MAX; 00019 ypos = (rand() % SCREEN_MAX ); 00020 //VELOCITY VECTOR, Y VECTOR IS -5 TO +5, X VECTOR IS -1 TO -11 00021 dx = (rand() % 10) - 11; 00022 dy = (rand() % 10 -5); 00023 } 00024 00025 void ConcreteAsteroid3::draw(){ 00026 uLCD.BLIT(xpos, ypos, ASTEROID_WIDTH, ASTEROID_HEIGHT, &asteroid_sprite_3); 00027 } 00028 00029 // MOVE BY ONE UNIT OF THE VELOCITY VECTOR 00030 void ConcreteAsteroid3::update(){ 00031 xpos= xpos + dx; 00032 ypos = ypos + dy; 00033 }
Generated on Fri Jul 15 2022 00:38:40 by
1.7.2