enemy hurt sprite and shorter feather wait times

This commit is contained in:
Return0ne 2022-07-15 12:59:37 -04:00
parent 21915fc0df
commit 851a13ce0d
8 changed files with 63 additions and 89 deletions

View file

@ -1 +1 @@
{"modelVersion":2,"piskel":{"name":"cat","description":"","fps":12,"height":50,"width":50,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":1,\"chunks\":[{\"layout\":[[0]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAqUlEQVRoge3UMQ6AMAxD0e7c/7rAhlgoTXCDET+SJ4TSlxJaO9W6LFsv7aUKn+UOUo1Jn2MEUgF63D8CmYWR9O68dGQWSDrEEYgadNVr2qc1AxO9efVfa6hZtM/IkOTLnm2mGJAU4pA0JDqx5OFqlx0IECBAgAD5LcQtQNwihWT3RrFvZZDsMyBAgACpgWQDBIhZgLgFiFuAuAWIW4C4BYhbgLjlH5Av1w4h7f0lPcROigAAAABJRU5ErkJggg==\"}]}"],"hiddenFrames":[""]}}
{"modelVersion":2,"piskel":{"name":"cat","description":"","fps":12,"height":50,"width":50,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":2,\"chunks\":[{\"layout\":[[0],[1]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAyCAYAAACqNX6+AAABiklEQVR4nO3VS44CMQwE0Oy5/3WHWc0ItSDxp5wU7orkDR0S288NY7ysn8fjOYtxaDHlsnWtQHY3giWPY8sCsqMhp++nWR6QqqYwDATNmhT/H1XNYRgGumUBGWCYT3cJZCz/ROEo3jexCsT7dm4bDuPlpqZ57xkGbFaQMhTH5aGmIaBRDUAglKNUJFkVrHWiLJaJDucEB4sp/8liHxZzsp5m3R0EhtIdZBcGDKUzyG4MCIpAyFC6gpzESKF0BJnd8eme657XfbNnq3sEYgBZNRu1J/SmdAOxTr8lUN93oXQC8dxlbSTq+xAQtkDUEoFAnXErkEwTPRjZ824Bkm2eFyV7HhQkOlWZaewGMkVBgkSfZUAiDVx9vuu8diDRc5hCIIQhELIQCFkIhCxgING4O8g193Yg34bzLn+BEID85f21r/07EG8diIHKDtm1jjYgkToEIhCBWEEyezz7BCIQgQhEIOdDIGSxC6T6LIEIRCACIchPIA3raFPI6dwE0rSONoWczg0GonV+/QItl3L0EqklsAAAAABJRU5ErkJggg==\"}]}"],"hiddenFrames":[""]}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 453 B

View file

@ -17,46 +17,65 @@
int score = 0, bestscore = 0;
void LoadGamplayScreen(void)
{
fxhit = LoadSound("assets/sfx/hit.wav");
player_sprite = LoadTexture("assets/gfx/player.png");
enemy_sprite = LoadTexture("assets/gfx/enemy.png");
fxfeather = LoadSound("assets/sfx/feather.wav");
feather_sprite = LoadTexture("assets/gfx/feather.png");
attack_sprite = LoadTexture("assets/gfx/attack.png");
firework_sprite = LoadTexture("assets/gfx/firework.png");
fxboom = LoadSound("assets/sfx/boom.wav");
}
void InitGameplayScreen(void)
{
SetMasterVolume(0.5);
fxhit = LoadSound("assets/sfx/hit.wav");
player_sprite = LoadTexture("assets/gfx/player.png");
player.currentframe = 0;
player.speed = 300.0f;
player.hp = PLAYER_HP;
if (GI_callcount < 1) {
player.frameRec = (Rectangle) {
player.hitbox.x,
player.hitbox.y,
(float) player_sprite.width/3,
(float) player_sprite.height
};
}
player.hitbox = (Rectangle) {
0,
100,
(float) player_sprite.width/3,
(float) player_sprite.height/2 + 5
(float) player_sprite.height/2 +5
};
player_iframeTimer = 0;
player_in = false;
player.color = RAYWHITE;
player_flashtimer = 0;
enemy_sprite = LoadTexture("assets/gfx/enemy.png");
enemy.currentframe = 0;
enemy.speed = 2.0f;
enemy.hp = 30;
if (GI_callcount < 1) {
enemy.frameRec = (Rectangle) {
enemy.hitbox.x,
enemy.hitbox.y,
(float) enemy_sprite.width/2,
(float) enemy_sprite.height
};
}
enemy.hitbox = (Rectangle) {
690,
10,
(float) enemy_sprite.width,
(float) enemy_sprite.width/2,
(float) enemy_sprite.height
};
enemy.color = RAYWHITE;
enemy_hurt = false;
fxfeather = LoadSound("assets/sfx/feather.wav");
feather_sprite = LoadTexture("assets/gfx/feather.png");
feather.hitbox = (Rectangle) {
GetRandomValue(0, GetScreenWidth() - feather_sprite.width),
GetRandomValue(0, GetScreenHeight() - feather_sprite.height),
@ -67,7 +86,6 @@ void InitGameplayScreen(void)
feather.power = 0;
firework_sprite = LoadTexture("assets/gfx/firework.png");
for (int i = 0; i < MAX_FIREWORKS; i++) {
fireworks[i].speed.x = 300.0f;
fireworks[i].active = 0;
@ -80,8 +98,6 @@ void InitGameplayScreen(void)
fireworks[i].color = RAYWHITE;
}
attack_sprite = LoadTexture("assets/gfx/attack.png");
fxboom = LoadSound("assets/sfx/boom.wav");
for (int i = 0; i < MAX_SHOOTS; i++) {
shoot[i].hitbox = (Rectangle) {
player.hitbox.x,
@ -97,75 +113,11 @@ void InitGameplayScreen(void)
ammo = 0;
pause = 0;
mute = false;
DebugMode = 0;
pauseTimer = 0;
}
void ResetGameplayScreen(void)
{
// code to reset all variables without reloading assets
player.currentframe = 0;
player.speed = 300.0f;
player.hp = PLAYER_HP;
player.hitbox = (Rectangle) {
0,
100,
(float) player_sprite.width/3,
(float) player_sprite.height/2 + 5
};
player_iframeTimer = 0;
player_in = false;
player.color = RAYWHITE;
player_flashtimer = 0;
enemy.currentframe = 0;
enemy.speed = 2.0f;
enemy.hp = 30;
enemy.hitbox = (Rectangle) {
690,
10,
(float) enemy_sprite.width,
(float) enemy_sprite.height
};
feather.hitbox = (Rectangle) {
GetRandomValue(0, GetScreenWidth() - feather_sprite.width),
GetRandomValue(0, GetScreenHeight() - feather_sprite.height),
(float) feather_sprite.width,
(float) feather_sprite.height
};
feather.active = true;
feather.power = 0;
for (int i = 0; i < MAX_FIREWORKS; i++) {
fireworks[i].speed.x = 300.0f;
fireworks[i].active = 0;
fireworks[i].hitbox = (Rectangle) {
630,
GetRandomValue(0, GetScreenHeight()),
(float) firework_sprite.width/2 + 10,
(float) firework_sprite.height
};
}
for (int i = 0; i < MAX_SHOOTS; i++) {
shoot[i].hitbox = (Rectangle) {
player.hitbox.x,
player.hitbox.y,
(float) attack_sprite.width,
(float) attack_sprite.height
};
shoot[i].speed.x = 7;
shoot[i].speed.y = 0;
shoot[i].active = false;
shoot[i].color = RED;
}
ammo = 0;
DebugMode = 0;
pauseTimer = 0;
score = 0;
GI_callcount++;
}
void DamagePlayer(void)
@ -190,6 +142,15 @@ void UpdateiFrameTimer(void)
player_iframeTimer = 0;
}
} else player.color = RAYWHITE;
if (enemy_hurt) {
enemy_frametimer++;
enemy.currentframe = 1;
if (enemy_frametimer >= 60) {
enemy_hurt = false;
enemy_frametimer = 0;
}
} else enemy.currentframe = 0;
}
void UpdateGameplayScreen(void)
@ -227,6 +188,8 @@ void UpdateGameplayScreen(void)
feather.sprite_pos = (Vector2){ feather.hitbox.x, feather.hitbox.y };
enemy.sprite_pos = (Vector2){ enemy.hitbox.x, enemy.hitbox.y };
enemy.frameRec.x = (float)enemy.currentframe*(float)enemy_sprite.width/2;
player_flashtimer++;
@ -239,7 +202,7 @@ void UpdateGameplayScreen(void)
}
if (score % 1000 == 0) feather.active = true;
if (score % 500 == 0) feather.active = true;
// Player to da wallz collies
if ((player.hitbox.x + player.hitbox.width) >= GetScreenWidth()) player.hitbox.x = GetScreenWidth() - player.hitbox.width;
@ -254,6 +217,8 @@ void UpdateGameplayScreen(void)
if (IsKeyPressed(KEY_NINE)) ammo = 99;
if (IsKeyPressed(KEY_ZERO)) ammo = 0;
if (IsKeyPressed(KEY_R)) {
gameReset();
currentScreen = TITLE;
@ -271,6 +236,7 @@ void UpdateGameplayScreen(void)
if (CheckCollisionRecs(shoot[i].hitbox, enemy.hitbox) && shoot[i].active) {
// enemy.hp--;
enemy_hurt = true;
score += 300;
if (!mute) PlaySoundMulti(fxboom);
shoot[i].active = false;
@ -361,7 +327,7 @@ void DrawGameplayScreen(void)
DrawText(TextFormat("player_in: %d", player_in), 10, 320, 20, GREEN);
}
if (feather.active) DrawTexture(feather_sprite, feather.sprite_pos.x, feather.sprite_pos.y, feather.color);
DrawTexture(enemy_sprite, enemy.sprite_pos.x, enemy.sprite_pos.y, enemy.color);
DrawTextureRec(enemy_sprite, enemy.frameRec, enemy.sprite_pos, enemy.color);
for (int i = 0; i < MAX_FIREWORKS; i++) {
DrawTexture(firework_sprite, fireworks[i].sprite_pos.x, fireworks[i].sprite_pos.y, fireworks[i].color);
}
@ -374,7 +340,8 @@ void DrawGameplayScreen(void)
DrawTexture(feather_sprite, 70, 0, RED);
DrawText(TextFormat("= %i", ammo), 100, 30, 20, RED);
// DrawText(TextFormat("ENEMY HP: %i", enemy.hp), GetScreenWidth() - 150, 10, 20, RED);
DrawText(TextFormat("SCORE: %i", score), 10, 65, 20, BLUE);
if (score >= 10000) DrawText(TextFormat("SCORE: %i", score), 10, 65, 20, (Color){ 222, 181, 0, 255 });
else DrawText(TextFormat("SCORE: %i", score), 10, 65, 20, BLUE);
if (pause && ((pauseTimer/30)%2)) DrawText("PAUSED", 330, 190, 30, WHITE);
}
@ -392,6 +359,6 @@ void UnloadGameplayScreen()
void gameReset(void)
{
ResetGameplayScreen();
InitGameplayScreen();
InitGameoverScreen();
}

View file

@ -48,9 +48,12 @@ Sound fxhit = { 0 };
Sound fxfeather = { 0 };
Sound fxboom = { 0 };
bool pause;
bool mute;
bool mute = false;
bool player_in;
bool enemy_hurt;
int ammo = 0;
int GI_callcount = 0;
bool DebugMode;

View file

@ -64,6 +64,7 @@ void gameSetup(void)
// asset loading & setting of variable values
currentScreen = TITLE;
LoadGamplayScreen();
InitGameplayScreen();
InitTitleScreen();
}

View file

@ -25,7 +25,8 @@ void InitGameplayScreen(void);
void UpdateGameplayScreen(void);
void DrawGameplayScreen(void);
void UnloadGameplayScreen(void);
void ResetGameplayScreen(void);
void LoadGamplayScreen(void);
void UpdateCreditsScreen(void);
void DrawCreditsScreen(void);

View file

@ -12,5 +12,6 @@
int pauseTimer;
int player_iframeTimer;
int player_flashtimer;
int enemy_frametimer;
#endif

View file

@ -57,6 +57,7 @@ void DrawTitleScreen(void)
DrawText("Press 'ENTER' or 'START' to select an option", 10, 140, 10, WHITE);
DrawText("Press 'X' or 'A' on a gamepad to shoot", 10, 160, 10, WHITE);
DrawText("Avoid", 330, 20, 50, BLUE);
// DrawText("Ver: 0.1", 680, 420, 30, WHITE);
if (titleSelected == 0) DrawText("PLAY", 360, 220, 20, WHITE);
else DrawText("PLAY", 360, 220, 20, BLUE);