diff --git a/assets-cg/Sprites/Players/player_ship1.png b/assets-cg/Sprites/Players/player_ship1.png new file mode 100644 index 0000000..b64a9e3 Binary files /dev/null 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 new file mode 100644 index 0000000..8c665d9 Binary files /dev/null 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 new file mode 100644 index 0000000..0e1fa33 Binary files /dev/null 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 new file mode 100644 index 0000000..586f5f0 Binary files /dev/null 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 new file mode 100644 index 0000000..749d5cb Binary files /dev/null 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 new file mode 100644 index 0000000..27c5e6c Binary files /dev/null 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 new file mode 100644 index 0000000..0c76452 Binary files /dev/null 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 new file mode 100644 index 0000000..524ee7d Binary files /dev/null and b/assets-cg/Sprites/Players/player_ship8.png differ diff --git a/assets-cg/Sprites/Rocks/asteroide1_12frames.ase b/assets-cg/Sprites/Rocks/asteroide1_12frames.ase new file mode 100644 index 0000000..e68c132 Binary files /dev/null and b/assets-cg/Sprites/Rocks/asteroide1_12frames.ase differ diff --git a/assets-cg/Sprites/Rocks/asteroide1_12frames.json b/assets-cg/Sprites/Rocks/asteroide1_12frames.json new file mode 100644 index 0000000..d1ec3ff --- /dev/null +++ b/assets-cg/Sprites/Rocks/asteroide1_12frames.json @@ -0,0 +1,112 @@ +{ "frames": { + "asteroide1_12frames 0.ase": { + "frame": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 1.ase": { + "frame": { "x": 32, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 2.ase": { + "frame": { "x": 64, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 3.ase": { + "frame": { "x": 96, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 4.ase": { + "frame": { "x": 128, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 5.ase": { + "frame": { "x": 160, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 6.ase": { + "frame": { "x": 192, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 7.ase": { + "frame": { "x": 224, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 8.ase": { + "frame": { "x": 256, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 9.ase": { + "frame": { "x": 288, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 10.ase": { + "frame": { "x": 320, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + }, + "asteroide1_12frames 11.ase": { + "frame": { "x": 352, "y": 0, "w": 32, "h": 32 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 }, + "sourceSize": { "w": 32, "h": 32 }, + "duration": 100 + } + }, + "meta": { + "app": "https://github.com/LibreSprite/LibreSprite/", + "version": "1.0", + "image": "/home/sylvain/Programmes/Casio/shmup/assets-cg/Sprites/Rocks/asteroide1_12frames.png", + "format": "RGBA8888", + "size": { "w": 384, "h": 32 }, + "scale": "1", + "frameTags": [ + ], + "layers": [ + { "name": "Layer 1", "opacity": 255, "blendMode": "normal" } + ] + } +} diff --git a/assets-cg/Sprites/Rocks/asteroide1_12frames.png b/assets-cg/Sprites/Rocks/asteroide1_12frames.png new file mode 100644 index 0000000..8718069 Binary files /dev/null and b/assets-cg/Sprites/Rocks/asteroide1_12frames.png differ diff --git a/src/collections.cpp b/src/collections.cpp index ef53570..5da89c2 100644 --- a/src/collections.cpp +++ b/src/collections.cpp @@ -18,26 +18,26 @@ void Create_Player_Shoot( uint8_t id ) if (id==0) { - Bullet *b = new Bullet( MyPlayer->x, MyPlayer->y-21, id ); + Bullet *b = new Bullet( (int) MyPlayer->x, (int) MyPlayer->y-21, id ); MyPlayerBullets.push_back( b ); } else if (id==1) { - Bullet *b1 = new Bullet( MyPlayer->x-17, MyPlayer->y, id ); + Bullet *b1 = new Bullet( (int) MyPlayer->x-17, (int) MyPlayer->y, id ); MyPlayerBullets.push_back( b1 ); - Bullet *b2 = new Bullet( MyPlayer->x+17, MyPlayer->y, id ); + Bullet *b2 = new Bullet( (int) MyPlayer->x+17, (int) MyPlayer->y, id ); MyPlayerBullets.push_back( b2 ); } else if (id==2) { - Bullet *b1 = new Bullet( MyPlayer->x, MyPlayer->y-21, id ); + Bullet *b1 = new Bullet( (int) MyPlayer->x, (int) MyPlayer->y-21, id ); MyPlayerBullets.push_back( b1 ); - Bullet *b2 = new Bullet( MyPlayer->x+17, MyPlayer->y, id ); + Bullet *b2 = new Bullet( (int) MyPlayer->x+17, (int) MyPlayer->y, id ); MyPlayerBullets.push_back( b2 ); - Bullet *b3 = new Bullet( MyPlayer->x-17, MyPlayer->y, id ); + Bullet *b3 = new Bullet( (int) MyPlayer->x-17, (int) MyPlayer->y, id ); MyPlayerBullets.push_back( b3 ); } } diff --git a/src/main.cpp b/src/main.cpp index 7dc7a34..04970a7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -217,7 +217,7 @@ static void render( void ) } -static void get_inputs( void ) +static void get_inputs( float dt ) { uint8_t speed = 4; uint32_t tempshoot = rtc_ticks(); @@ -261,19 +261,19 @@ static void get_inputs( void ) if(keydown(KEY_LEFT)) { - MyPlayer->Go_Left(); + MyPlayer->Go_Left( dt ); } if(keydown(KEY_RIGHT)) { - MyPlayer->Go_Right(); + MyPlayer->Go_Right( dt ); } if(keydown(KEY_UP)) { - MyPlayer->Go_Up(); + MyPlayer->Go_Up( dt ); } if(keydown(KEY_DOWN)) { - MyPlayer->Go_Down(); + MyPlayer->Go_Down( dt ); } @@ -384,7 +384,7 @@ int main(void) // all the stuff to be update should be put here // read inputs from the player - get_inputs( ); + get_inputs( elapsedTime ); // update as per the time spend to do the loop update( elapsedTime ); diff --git a/src/player.cpp b/src/player.cpp index e990b1c..2dccfa2 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -14,14 +14,14 @@ static int16_t cosTable[360], sinTable[360]; Player::Player( int16_t _x, int16_t _y, uint8_t _id ) { - x = _x; - y = _y; + x = libnum::num(_x); + y = libnum::num(_y); ID = _id; width = img_mainship1.width/2; height = img_mainship1.height/2; - speed = 2; + speed = 5; xmin = (int) x - width; xmax = (int) x + width; @@ -83,8 +83,8 @@ void Player::Render( void ) { int angle = (int) satAngle + u*incangle; angle = angle % 360; - int xsat = x + cosTable[angle]; - int ysat = y + sinTable[angle]; + int xsat = (int) x + cosTable[angle]; + int ysat = (int) y + sinTable[angle]; azrp_image_p8_effect(xsat-w, ysat-h, &img_Satellite_Lvl1, DIMAGE_NONE); } } @@ -150,38 +150,42 @@ bool Player::Shoot_OK( uint32_t tempshoot, uint8_t shootID ) else return false; } -void Player::Go_Left( void ) +void Player::Go_Left( float dt ) { if( x > width/2+speed ) { - x -= speed; + libnum::num a = libnum::num( dt / 60000.0f ); + x -= a * libnum::num( speed ); this->Update( 0.0f ); } } -void Player::Go_Right( void ) +void Player::Go_Right( float dt ) { if(x < azrp_width-width/2-speed) { - x += speed; + libnum::num a = libnum::num( dt / 60000.0f ); + x += a * libnum::num( speed ); this->Update( 0.0f ); } } -void Player::Go_Up( void ) +void Player::Go_Up( float dt ) { if(y > height/2+speed) { - y -= speed; + libnum::num a = libnum::num( dt / 60000.0f ); + y -= a * libnum::num( speed ); this->Update( 0.0f ); } } -void Player::Go_Down( void ) +void Player::Go_Down( float dt ) { if(y < azrp_height -height/2 -speed) { - y += speed; + libnum::num a = libnum::num( dt / 60000.0f ); + y += a * libnum::num( speed ); this->Update( 0.0f ); } } \ No newline at end of file diff --git a/src/player.h b/src/player.h index b04b001..4a67e49 100644 --- a/src/player.h +++ b/src/player.h @@ -27,12 +27,12 @@ class Player bool Shoot_OK( uint32_t tempshoot, uint8_t shootID ); - void Go_Left( void ); - void Go_Right( void ); - void Go_Up( void ); - void Go_Down( void ); + void Go_Left( float dt ); + void Go_Right( float dt ); + void Go_Up( float dt ); + void Go_Down( float dt ); - uint16_t x, y; // center position of the player + libnum::num x, y; // center position of the player 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) uint8_t ID;