diff --git a/CMakeLists.txt b/CMakeLists.txt index 36a46e9..d97d52d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,15 @@ set(ASSETS_cg assets-cg/Sprites/Players/mainship1.png assets-cg/Sprites/Players/Satellite_Lvl1.png + assets-cg/Sprites/Players/player_ship1.png + assets-cg/Sprites/Players/player_ship2.png + assets-cg/Sprites/Players/player_ship3.png + assets-cg/Sprites/Players/player_ship4.png + assets-cg/Sprites/Players/player_ship5.png + assets-cg/Sprites/Players/player_ship6.png + assets-cg/Sprites/Players/player_ship7.png + assets-cg/Sprites/Players/player_ship8.png + assets-cg/Sprites/Enemies/Lifebar.png assets-cg/Sprites/Enemies/mainship2.png @@ -79,8 +88,9 @@ set(ASSETS_cg assets-cg/Sprites/Boss/BossGun.png assets-cg/Levels/tileset.png + assets-cg/Levels/Level1.json assets-cg/Levels/Level2.json -# assets-cg/Levels/Tileset_Space.json + # assets-cg/Levels/Tileset_Space.json # ... ) diff --git a/TODO.txt b/TODO.txt index 2e8d2d1..1f0dc44 100644 --- a/TODO.txt +++ b/TODO.txt @@ -12,6 +12,7 @@ - animer des éléments du décors (clignotements, sprites animés, ...) - interaction avec le décors (collisions possibles avec certaines tiles) qui imposent donc de suivre un "chemin" dans le niveau - [DONE] multiple layers de tiles pour avoir des niveaux plus beaux +- implémenter des vitesses de défilement variables pour les décors de fond. ## Partie mouvement : @@ -29,6 +30,7 @@ - [DONE] implémenter un système de bonus (points, upgrade tir/satellites/... ) - implémenter un système d'amélioration de compétence de tirs (bullet -> mega bullet -> laser -> mega laser -> bomb -> etc.) - implémenter un système d'animation du vaisseau (réacteurs par exemple) +- implémenter un système de boost des munitions si on garde le doigt appuyé sur la touche de laser ## Scenario @@ -58,6 +60,8 @@ o boss 3 : "Gun Crab" o boss 4 : "Demoniac Snake" o boss 5 : "Space Octopus" + o ... + o boss of the boss "Zgrog Master" - création de séquences avec les boss (différentes phases) - créations de différentes armes - [DONE - CAN BE IMPROVED] créations de différents bonus @@ -84,10 +88,14 @@ ## Histoire (à peaufiner) En tant de Space Marshall, votre rôle est de faire respecter -la loi intergalactique et de punir les contrevenants. -Votre périmètre se situe dans le Grand Amas de RUZA-25f/s +la loi intergalactique et de punir les contrevenants afin d'assurer +la paix et le bon vivre ensemble des différentes civilisations aliens +vivant dans votre zone de l'espace à surveiller. +Votre périmètre englobe le Grand Amas de RUZA-25f/s dans ons entièreté et armé de votre vaisseau, vous devez aider les civilisations locales en pourchassant et anéantissant les hordes de Zgrog. -Cette race alien robotique a pour but de coloniser les planètes -et les stations orbitales géantes pour faire disparaître tout -vie organique. \ No newline at end of file +Cette race alien robotique s'est donné pour but de coloniser les planètes +et les stations orbitales géantes afin d'y faire disparaître toute +vie organique. +C'est donc un combat sans relâche que de traquer et de détruire cet +envahisseur dénué d'âme. \ No newline at end of file diff --git a/assets-cg/Sprites/Boss/Boss2.png b/assets-cg/Sprites/Boss/Boss2.png new file mode 100644 index 0000000..acf5832 Binary files /dev/null and b/assets-cg/Sprites/Boss/Boss2.png differ diff --git a/assets-cg/Sprites/Boss/Boss3.png b/assets-cg/Sprites/Boss/Boss3.png new file mode 100644 index 0000000..f3cfaac Binary files /dev/null and b/assets-cg/Sprites/Boss/Boss3.png differ diff --git a/assets-cg/Sprites/Boss/Boss4.png b/assets-cg/Sprites/Boss/Boss4.png new file mode 100644 index 0000000..988ec8c Binary files /dev/null and b/assets-cg/Sprites/Boss/Boss4.png differ diff --git a/assets-cg/Sprites/Boss/Boss5.png b/assets-cg/Sprites/Boss/Boss5.png new file mode 100644 index 0000000..9213537 Binary files /dev/null and b/assets-cg/Sprites/Boss/Boss5.png differ diff --git a/assets-cg/Sprites/Boss/Boss6.png b/assets-cg/Sprites/Boss/Boss6.png new file mode 100644 index 0000000..5484e61 Binary files /dev/null and b/assets-cg/Sprites/Boss/Boss6.png differ diff --git a/assets-cg/Sprites/Boss/Boss7.png b/assets-cg/Sprites/Boss/Boss7.png new file mode 100644 index 0000000..fe19064 Binary files /dev/null and b/assets-cg/Sprites/Boss/Boss7.png differ diff --git a/assets-cg/Sprites/Boss/Boss8.png b/assets-cg/Sprites/Boss/Boss8.png new file mode 100644 index 0000000..ea70307 Binary files /dev/null and b/assets-cg/Sprites/Boss/Boss8.png differ diff --git a/assets-cg/Sprites/Enemies/Enemy_Blue_Lvl1.png b/assets-cg/Sprites/Enemies/Enemy_Blue_Lvl1.png index ef03f9f..cf3110e 100644 Binary files a/assets-cg/Sprites/Enemies/Enemy_Blue_Lvl1.png and b/assets-cg/Sprites/Enemies/Enemy_Blue_Lvl1.png differ diff --git a/assets-cg/Sprites/Enemies/Enemy_Red_Lvl1.png b/assets-cg/Sprites/Enemies/Enemy_Red_Lvl1.png index 290f94d..1ae9a41 100644 Binary files a/assets-cg/Sprites/Enemies/Enemy_Red_Lvl1.png and b/assets-cg/Sprites/Enemies/Enemy_Red_Lvl1.png differ diff --git a/assets-cg/Sprites/Players/player_ship1.png b/assets-cg/Sprites/Players/player_ship1.png index b64a9e3..73b0d92 100644 Binary files a/assets-cg/Sprites/Players/player_ship1.png and b/assets-cg/Sprites/Players/player_ship1.png differ diff --git a/assets-cg/Sprites/Players/player_ship2.png b/assets-cg/Sprites/Players/player_ship2.png index 8c665d9..f4e4520 100644 Binary files a/assets-cg/Sprites/Players/player_ship2.png and b/assets-cg/Sprites/Players/player_ship2.png differ diff --git a/assets-cg/Sprites/Players/player_ship3.png b/assets-cg/Sprites/Players/player_ship3.png index 0e1fa33..803e000 100644 Binary files a/assets-cg/Sprites/Players/player_ship3.png and b/assets-cg/Sprites/Players/player_ship3.png differ diff --git a/assets-cg/Sprites/Players/player_ship4.png b/assets-cg/Sprites/Players/player_ship4.png index 586f5f0..7768721 100644 Binary files a/assets-cg/Sprites/Players/player_ship4.png and b/assets-cg/Sprites/Players/player_ship4.png differ diff --git a/assets-cg/Sprites/Players/player_ship5.png b/assets-cg/Sprites/Players/player_ship5.png index 749d5cb..4426e75 100644 Binary files a/assets-cg/Sprites/Players/player_ship5.png and b/assets-cg/Sprites/Players/player_ship5.png differ diff --git a/assets-cg/Sprites/Players/player_ship6.png b/assets-cg/Sprites/Players/player_ship6.png index 27c5e6c..ee824d6 100644 Binary files a/assets-cg/Sprites/Players/player_ship6.png and b/assets-cg/Sprites/Players/player_ship6.png differ diff --git a/assets-cg/Sprites/Players/player_ship7.png b/assets-cg/Sprites/Players/player_ship7.png index 0c76452..41e6096 100644 Binary files a/assets-cg/Sprites/Players/player_ship7.png and b/assets-cg/Sprites/Players/player_ship7.png differ diff --git a/assets-cg/Sprites/Players/player_ship8.png b/assets-cg/Sprites/Players/player_ship8.png index 524ee7d..69610ad 100644 Binary files a/assets-cg/Sprites/Players/player_ship8.png and b/assets-cg/Sprites/Players/player_ship8.png differ diff --git a/src/background.cpp b/src/background.cpp index b40091f..28b390a 100644 --- a/src/background.cpp +++ b/src/background.cpp @@ -8,13 +8,14 @@ #include - +extern struct Map map_Level1; extern struct Map map_Level2; - +Map *map_Level; Background::Background( ) { - + map_Level = &map_Level1; + speed = libnum::num(1.0); } Background::~Background( ) @@ -29,18 +30,18 @@ void Background::Render( void ) int y0 = (int) ylevel; int yshifttile = (int) (16*ylevel.frac()); - for(int u=0; unblayers;u++) for(int i=0; i<=25; i++) { for(int j=0; j<=14; j++) { - uint16_t index = (j+y0) * map_Level2.w + (x0+i) % map_Level2.w; - uint16_t currentTile = map_Level2.layers[u][ index ]; + uint16_t index = (j+y0) * map_Level->w + (x0+i) % map_Level->w; + uint16_t currentTile = map_Level->layers[u][ index ]; if (currentTile!=0) { - uint16_t xtile = ((currentTile % map_Level2.tileset_size)-1) * 16; - uint16_t ytile = (currentTile / map_Level2.tileset_size) * 16; - azrp_subimage_p8( i*16-xshifttile, j*16-yshifttile, map_Level2.tileset, xtile, ytile, 16, 16, DIMAGE_NONE ); + uint16_t xtile = ((currentTile % map_Level->tileset_size)-1) * 16; + uint16_t ytile = (currentTile / map_Level->tileset_size) * 16; + azrp_subimage_p8( i*16-xshifttile, j*16-yshifttile, map_Level->tileset, xtile, ytile, 16, 16, DIMAGE_NONE ); } } } @@ -51,17 +52,17 @@ void Background::Render( void ) uint16_t tilemap[25*14]={0}; - for(int u=0; unblayers;u++) { for(int j=0; j<14; j++) { for(int i=0; i<=25; i++) { - uint16_t index = j * map_Level2.w + (x0+i) % map_Level2.w; - tilemap[25*j+i]= cmap_Level2.layers[u][ index ]; + uint16_t index = j * map_Level->w + (x0+i) % map_Level->w; + tilemap[25*j+i]= cmap_Level->layers[u][ index ]; } } - azrp_tilesmap( shifttile, tilemap, map_Level2.tileset, map_Level2.tileset_size); + azrp_tilesmap( shifttile, tilemap, map_Level->tileset, map_Level->tileset_size); } */ } @@ -69,7 +70,13 @@ void Background::Render( void ) void Background::Update( float dt ) { libnum::num a = libnum::num( dt / 90000.0f); //18000.0f ); - xlevel += a; + xlevel += speed*a; +} + + +void Background::SetSpeed(libnum::num s) +{ + speed = s; } @@ -82,7 +89,7 @@ void Background::IncYCoordinate( libnum::num y ) { ylevel += y ; if (ylevel<0) ylevel=libnum::num(0); - if (ylevel>map_Level2.h-14) ylevel=libnum::num(map_Level2.h-14); + if (ylevel>map_Level->h-14) ylevel=libnum::num(map_Level->h-14); } diff --git a/src/background.h b/src/background.h index 4ec151e..3621b72 100644 --- a/src/background.h +++ b/src/background.h @@ -38,8 +38,11 @@ class Background int GetXCoordinate( void ); int GetYCoordinate( void ); + void SetSpeed( libnum::num s ); + private: libnum::num xlevel, ylevel; + libnum::num speed; }; diff --git a/src/bonus.cpp b/src/bonus.cpp index 82c9f3a..84a94c2 100644 --- a/src/bonus.cpp +++ b/src/bonus.cpp @@ -37,6 +37,7 @@ Bonus::Bonus( int16_t _x, int16_t _y, uint8_t _id ) currentframe = libnum::num(0); + accumulatedTime = 0.0f; } Bonus::~Bonus() @@ -61,7 +62,7 @@ void Bonus::Update( float dt ) } else { - pathToFollow->CalculatePosition( dt, speed, true, &x, &y ); + pathToFollow->CalculatePosition( &accumulatedTime, dt, speed, true, &x, &y ); } xmin = (int) x - width; diff --git a/src/bonus.h b/src/bonus.h index 0d805d8..36b4683 100644 --- a/src/bonus.h +++ b/src/bonus.h @@ -32,7 +32,9 @@ class Bonus private: int8_t dirx, diry; - libnum::num currentframe; + libnum::num currentframe; + + float accumulatedTime; }; diff --git a/src/boss.cpp b/src/boss.cpp index c98187e..2e25ff7 100644 --- a/src/boss.cpp +++ b/src/boss.cpp @@ -154,6 +154,7 @@ Boss::Boss( int16_t _x, int16_t _y, uint8_t _id ) Guns[i].toberemoved = false; } + accumulatedTime = 0.0f; /* FOR DEBUGGING */ // gint_world_switch( GINT_CALL( savedata ) ); @@ -171,7 +172,7 @@ void Boss::Update( float dt ) if (hasTrajectory) { - pathToFollow->CalculatePosition( dt, speed, true, &x, &y ); + pathToFollow->CalculatePosition( &accumulatedTime, dt, speed, true, &x, &y ); } xmin = (int) x - width; diff --git a/src/boss.h b/src/boss.h index be773f2..b4ab5e6 100644 --- a/src/boss.h +++ b/src/boss.h @@ -60,6 +60,8 @@ class Boss uint32_t lastshoot0 = 0; uint32_t lastshoot1 = 0; + float accumulatedTime; + bool Shoot_OK( uint32_t tempshoot, uint8_t shootID ); }; diff --git a/src/collections.cpp b/src/collections.cpp index ed23578..7b23a1e 100644 --- a/src/collections.cpp +++ b/src/collections.cpp @@ -87,10 +87,26 @@ void Create_Enemies( void ) MyTrajectory->AddPoint( F ); MyTrajectory->AddPoint( G ); + Enemy* e5 = new Enemy( 348, 112, 2); e5->hasTrajectory = true; e5->pathToFollow = MyTrajectory; + e5->Set_Accumulated_Time(0.0f); + + Enemy* e6 = new Enemy( 348, 112, 2); + e6->hasTrajectory = true; + e6->pathToFollow = MyTrajectory; + e6->Set_Accumulated_Time(-1.0f); + + Enemy* e7 = new Enemy( 348, 112, 2); + e7->hasTrajectory = true; + e7->pathToFollow = MyTrajectory; + e7->Set_Accumulated_Time(-2.0f); + + MyEnemies.push_back( e5 ); + MyEnemies.push_back( e6 ); + MyEnemies.push_back( e7 ); } diff --git a/src/enemy.cpp b/src/enemy.cpp index 9a0914c..cd399e5 100644 --- a/src/enemy.cpp +++ b/src/enemy.cpp @@ -55,6 +55,8 @@ Enemy::Enemy( int16_t _x, int16_t _y, uint8_t _id ) toberemoved = false; lastshottime = 0; + + accumulatedTime = 0.0f; } Enemy::~Enemy() @@ -76,7 +78,7 @@ void Enemy::Update( float dt ) } else { - pathToFollow->CalculatePosition( dt, speed, true, &x, &y ); + pathToFollow->CalculatePosition( &accumulatedTime, dt, speed, true, &x, &y ); } xmin = (int) x - width; @@ -87,7 +89,7 @@ void Enemy::Update( float dt ) uint32_t tempshoot = rtc_ticks(); - if (Shoot_OK( tempshoot )) + if (Shoot_OK( tempshoot, 0 )) { if ( ID==0 ) { @@ -153,14 +155,19 @@ bool Enemy::Test_Impact( Bullet *projectile ) else return false; } -void Enemy::Set_Speed_Vector( uint8_t _sp, uint8_t _xd, uint8_t _yd) +void Enemy::Set_Speed_Vector( uint8_t _sp, uint8_t _xd, uint8_t _yd ) { speed = _sp; dirx = _xd; diry = _yd; } -bool Enemy::Shoot_OK( uint32_t tempshoot ) +void Enemy::Set_Accumulated_Time( float value ) +{ + accumulatedTime = value; +} + +bool Enemy::Shoot_OK( uint32_t tempshoot, uint8_t shootID ) { if(tempshoot-lastshottime>15) { diff --git a/src/enemy.h b/src/enemy.h index ced5fb9..79a9300 100644 --- a/src/enemy.h +++ b/src/enemy.h @@ -24,6 +24,8 @@ class Enemy bool Test_Impact( Bullet *projectile ); void Set_Speed_Vector( uint8_t _sp, uint8_t _xd, uint8_t _yd); + void Set_Accumulated_Time( float value ); + libnum::num x, y; // center position of the ennemy uint8_t width, height; // width and height -for the hitbox int16_t xmin, xmax, ymin, ymax; // square hitbox (to speed up the bullet impact calculations) @@ -39,8 +41,9 @@ class Enemy int8_t dirx, diry; // vector of the current direction of the ennemy (TODO : to implement more complex displacement pattern) uint32_t lastshottime; + float accumulatedTime; - bool Shoot_OK( uint32_t tempshoot ); + bool Shoot_OK( uint32_t tempshoot, uint8_t shootID ); }; diff --git a/src/main.cpp b/src/main.cpp index 1f0a2b5..ae9ec6e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -350,6 +350,11 @@ static void get_inputs( float dt ) if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_F2)) {texttodraw=1;} if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_F3)) {texttodraw=2;} if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_F4)) {texttodraw=3;} + if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_F5)) + { + drawback = !drawback; + drawstars = ! drawstars; + } if(MyKeyboard.IsKeyPressed(MYKEY_SHIFT) && MyKeyboard.IsKeyPressedEvent(MYKEY_F6)) { azrp_starfield_close( ); @@ -474,20 +479,18 @@ int main(void) __printf_enable_fixed(); azrp_config_scale(SCALE_PIXEL); - //azrp_shader_clear_configure(); - //azrp_shader_image_rgb16_configure(); - //azrp_shader_image_p8_configure(); - //azrp_shader_image_p4_configure(); + #if(USB) azrp_hook_set_prefrag(hook_prefrag); #endif azrp_starfield_init( 250 ); - //Create_Enemies( ); + Create_Enemies( ); MyPlayer = new Player( azrp_width/4, azrp_height/2, 0); +/* MyBoss = new Boss( 3*azrp_width/4, azrp_height/2, 0); @@ -510,7 +513,7 @@ int main(void) MyBoss->hasTrajectory = true; MyBoss->pathToFollow = MyTrajectory; - +*/ /* #if(DBGCRSH) diff --git a/src/player.cpp b/src/player.cpp index 36b19dc..621037a 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -10,19 +10,31 @@ extern bopti_image_t img_Lifebar; -extern bopti_image_t img_mainship1; +extern bopti_image_t *img_mainship1; + +extern bopti_image_t img_player_ship1; +extern bopti_image_t img_player_ship2; +extern bopti_image_t img_player_ship3; +extern bopti_image_t img_player_ship4; +extern bopti_image_t img_player_ship5; +extern bopti_image_t img_player_ship6; +extern bopti_image_t img_player_ship7; +extern bopti_image_t img_player_ship8; + extern bopti_image_t img_Satellite_Lvl1; extern Background MyBackground; Player::Player( int16_t _x, int16_t _y, uint8_t _id ) { + img_mainship1 = &img_player_ship7; + x = libnum::num(_x); y = libnum::num(_y); ID = _id; - width = img_mainship1.width/2; - height = img_mainship1.height/2; + width = img_mainship1->width/2; + height = img_mainship1->height/2; speed = 10; xmin = (int) x - width; @@ -68,7 +80,7 @@ void Player::Render( void ) { azrp_subimage_p8_effect( (int) x - img_Lifebar.width/2, ymin - 10, &img_Lifebar, 0, 0, img_Lifebar.width, 7, DIMAGE_NONE ); - if (ID==0) azrp_image_p8_effect(xmin, ymin, &img_mainship1, DIMAGE_NONE); + if (ID==0) azrp_image_p8_effect(xmin, ymin, img_mainship1, DIMAGE_NONE); int w = img_Satellite_Lvl1.width/2; int h = img_Satellite_Lvl1.height/2; diff --git a/src/trajectory.cpp b/src/trajectory.cpp index 5dab5a4..f68a9d9 100644 --- a/src/trajectory.cpp +++ b/src/trajectory.cpp @@ -4,7 +4,7 @@ Trajectory::Trajectory( ) { - accumulatedTime = 0.0f; + //accumulatedTime = 0.0f; } @@ -23,25 +23,26 @@ void Trajectory::AddPoint( Point2D *p ) } -void Trajectory::CalculatePosition( float time, uint16_t speed, bool looped, libnum::num *xreturn, libnum::num *yreturn ) +void Trajectory::CalculatePosition( float *accumulatedTime, float time, uint16_t speed, bool looped, libnum::num *xreturn, libnum::num *yreturn ) { - accumulatedTime += speed * time / 2000000.0f; - if (accumulatedTime>ControlPoints.size()) accumulatedTime-=ControlPoints.size(); + *accumulatedTime += speed * time / 2000000.0f; + if (*accumulatedTime>ControlPoints.size()) *accumulatedTime-=ControlPoints.size(); + if (*accumulatedTime<0) *accumulatedTime+=ControlPoints.size(); - libnum::num t = libnum::num( accumulatedTime - (int) accumulatedTime ); + libnum::num t = libnum::num( *accumulatedTime - (int) *accumulatedTime ); int p0, p1, p2, p3; if (!looped) { - p1 = (int) accumulatedTime + 1; + p1 = (int) *accumulatedTime + 1; p2 = p1 + 1; p3 = p2 + 1; p0 = p1 - 1; } else { - p1 = (int) accumulatedTime; + p1 = (int) *accumulatedTime; p2 = (p1 + 1) % ControlPoints.size(); p3 = (p2 + 1) % ControlPoints.size(); p0 = p1 >= 1 ? p1 - 1 : ControlPoints.size() - 1; diff --git a/src/trajectory.h b/src/trajectory.h index e367a6d..d8b141d 100644 --- a/src/trajectory.h +++ b/src/trajectory.h @@ -16,11 +16,11 @@ class Trajectory ~Trajectory( ); void AddPoint( Point2D *p ); - void CalculatePosition( float time, uint16_t speed, bool looped, libnum::num *xreturn, libnum::num *yreturn ); + void CalculatePosition( float *accumulatedTime, float time, uint16_t speed, bool looped, libnum::num *xreturn, libnum::num *yreturn ); std::vector ControlPoints; bool isLoop; - float accumulatedTime; + //float accumulatedTime; };