corrected player movement speed + addition of some sprites

This commit is contained in:
Sylvain PILLOT 2023-01-22 23:20:16 +01:00
parent 7d007e366e
commit 6f5f06bfd0
15 changed files with 146 additions and 30 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

View File

@ -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" }
]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -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 );
}
}

View File

@ -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 );

View File

@ -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 );
}
}

View File

@ -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;