fixed text bugs

This commit is contained in:
Return0ne 2022-08-31 15:15:32 -04:00
parent 334c890bb3
commit bd7108936d
9 changed files with 25 additions and 44 deletions

View file

@ -6,7 +6,7 @@ A dumb raylib test which you can play [here](https://canneddonuts.itch.io/avoid-
- a tutorial
## Note
This games code more specifically 'Main.c' is a retyped version of this [repo](https://github.com/raysan5/raylib-game-template) which is code under the zlib license.
This game's code more specifically 'Main.c' is a retyped version of this [repo](https://github.com/raysan5/raylib-game-template) which is code under the zlib license.
## Preview
![Alt Text](./doc-assets/preview.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

View file

@ -33,7 +33,7 @@ void UpdateEndingScreen(void)
void DrawEndingScreen(void)
{
DrawTexture(background, 0, 0, GOLD);
DrawTextEx(ZadoBold, "THANK YOU SO MUCH FOR PLAYING!!!", (Vector2){ 10, 10 }, 45, 2, GOLD);
DrawText("THANK YOU SO MUCH FOR PLAYING!!!", 10, 10, 40, GOLD);
DrawTextEx(ZadoBold, "Canneddonuts 2022", (Vector2){ 380, 400 }, 40, 2, WHITE);
DrawTextEx(ZadoBold, "Press 'ENTER'", (Vector2){ 5, 400 }, 40, 2, WHITE);
}

View file

@ -43,12 +43,12 @@ void UpdateGameoverScreen(void)
void DrawGameoverScreen(void)
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK);
DrawTextEx(ZadoBold, "GAME OVER", (Vector2){ 190, 0 }, 80, 3, RED);
if (gameoverSelected == 0) DrawTextEx(ZadoBold, "RETRY", (Vector2){ 350, 200 }, 30, 2, WHITE);
else DrawTextEx(ZadoBold, "RETRY", (Vector2){ 350, 200 }, 30, 2, RED);
DrawText("GAME OVER", 170, 10, 80, RED);
if (gameoverSelected == 0) DrawTextEx(ZadoBold, "RETRY", (Vector2){ 340, 200 }, 40, 2, WHITE);
else DrawTextEx(ZadoBold, "RETRY", (Vector2){ 340, 200 }, 40, 2, RED);
if (gameoverSelected == -1) DrawTextEx(ZadoBold, "TITLE", (Vector2){ 355, 240 }, 30, 2, WHITE);
else DrawTextEx(ZadoBold, "TITLE", (Vector2){ 355, 240 }, 30, 2, RED);
if (gameoverSelected == -1) DrawTextEx(ZadoBold, "TITLE", (Vector2){ 345, 250 }, 40, 2, WHITE);
else DrawTextEx(ZadoBold, "TITLE", (Vector2){ 345, 250 }, 40, 2, RED);
}
int FinishGameoverScreen(void)

View file

@ -68,7 +68,6 @@ void InitGameplayScreen(void)
enemy.currentframe = 0;
enemy.hp = 5;
//enemy.speed = 2.0f;
enemy.speed = 200.0f;
if (GI_callcount < 1) {
enemy.frameRec = (Rectangle) {
@ -127,20 +126,10 @@ void InitGameplayScreen(void)
pauseTimer = 0;
score = 0;
scoreTimer = 0;
ewc = 0;
GI_callcount++;
}
void SetEnemyLevel(void)
{
switch (level) {
case LEVEL1: enemy.speed = 200.0f; break;
case LEVEL2: enemy.speed = 400.0f; break;
case LEVEL3: enemy.speed = 600.0f; break;
}
}
void DamageActor(struct Actor *actor)
{
if (!actor->in) {
@ -248,11 +237,12 @@ void UpdateGameplayScreen(void)
if (IsKeyPressed(KEY_D)) DebugMode = !DebugMode;
if (IsKeyPressed(KEY_NINE)) ammo = 99;
if (IsKeyPressed(KEY_ZERO)) ammo = 0;
if (IsKeyPressed(KEY_G)) finishfromGameplayScreen = 1;
if (IsKeyPressed(KEY_R)) finishfromGameplayScreen = 2;
if (IsKeyPressed(KEY_W)) finishfromGameplayScreen = 3;
// call gameover when killed
if (player.hp <= 0) { StopMusicStream(Gameplaysong); finishfromGameplayScreen = 1; }
if (player.hp < 1) { StopMusicStream(Gameplaysong); finishfromGameplayScreen = 1; }
// Red feather logic
for (int i = 0; i < MAX_SHOOTS; i++) {
@ -285,7 +275,7 @@ void UpdateGameplayScreen(void)
case 0: player.hp++; break;
case 1: ammo++; break;
}
PlaySoundMulti(fxfeather);
if (!mute) PlaySoundMulti(fxfeather);
ResetFeather();
}
feather.hitbox.x -= 300.0f * GetFrameTime();
@ -293,16 +283,11 @@ void UpdateGameplayScreen(void)
// Enemy logic
if (level < 3) {
/* if (((enemy.hitbox.y + enemy.hitbox.height) >= (float)GetScreenHeight()
|| (enemy.hitbox.y <= 0))) enemy.speed *= -1.0f; */
// if ((int) globalTimer % 50 == 0)
enemy.hitbox.y = GetRandomValue(0, GetScreenHeight() - enemy_sprite.height);
// enemy.hitbox.y += enemy.speed * GetFrameTime();
if ((int)globalTimer % 40 == 0) enemy.hitbox.y = GetRandomValue(0, GetScreenHeight() - enemy_sprite.height);
if (CheckCollisionRecs(player.hitbox, enemy.hitbox)) DamageActor(&player);
if (enemy.hp < 1) { level++; enemy.hp = 5; SetEnemyLevel(); }
if (enemy.hp < 1) { level++; enemy.hp = 5; }
}
// Firework logic
@ -352,9 +337,6 @@ void DrawGameplayScreen(void)
for (int i = 0; i < MAX_SHOOTS; i++) {
DrawRectangleLines(shoot[i].hitbox.x, shoot[i].hitbox.y, shoot[i].hitbox.width, shoot[i].hitbox.height, GREEN);
}
/*for (int i = 0; i < 2; i++) {
DrawRectangleLines(EnemyBounds[i].x, EnemyBounds[i].y, EnemyBounds[i].width, EnemyBounds[i].height, WHITE);
}*/
DrawText(TextFormat("enemy.hitbox.y: %f", enemy.hitbox.y), 10, 200, 20, GREEN);
DrawText(TextFormat("enemy.speed: %f", enemy.speed), 10, 220, 20, GREEN);
DrawText(TextFormat("globalTimer: %f", globalTimer), 10, 240, 20, GREEN);
@ -362,7 +344,7 @@ void DrawGameplayScreen(void)
DrawText(TextFormat("player.iframetimer: %f", player.iframetimer), 10, 280, 20, GREEN);
DrawText(TextFormat("player.in: %d", player.in), 10, 300, 20, GREEN);
DrawText(TextFormat("feather.active: %d", feather.active), 10, 320, 20, GREEN);
//DrawText(TextFormat("GetTime(): %f", GetTime()), 10, 320, 20, GREEN);
DrawText(TextFormat("GetTime(): %f", GetTime()), 10, 340, 20, GREEN);
}
if (feather.active) DrawTexture(feather_sprite, feather.sprite_pos.x, feather.sprite_pos.y, feather.color);
DrawTextureRec(enemy_sprite, enemy.frameRec, enemy.sprite_pos, enemy.color);

View file

@ -52,7 +52,6 @@ struct Item feather = { 0 };
Sound fxfeather = { 0 };
bool pause;
bool DebugMode;
bool ewc;
int ammo = 0;
int GI_callcount = 0;

View file

@ -18,13 +18,13 @@ int titleSelected = 0, finishfromTitleScreen = 0;
void DrawScore(void)
{
if (bestscore >= 10000)
DrawTextEx(ZadoBold, TextFormat("BEST: %i", bestscore), (Vector2){ 580, 0 }, 30, 2, (Color){ 222, 181, 0, 255 });
DrawText(TextFormat("BEST: %i", bestscore), 580, 0, 30, (Color){ 222, 181, 0, 255 });
else if (bestscore >= 5000)
DrawTextEx(ZadoBold, TextFormat("BEST: %i", bestscore), (Vector2){ 580, 0 }, 30, 2, (Color){ 149, 148, 147, 255 });
DrawText(TextFormat("BEST: %i", bestscore), 580, 0, 30, (Color){ 149, 148, 147, 255 });
else if (bestscore >= 1000)
DrawTextEx(ZadoBold, TextFormat("BEST: %i", bestscore), (Vector2){ 580, 0 }, 30, 2, (Color){ 138, 72, 4, 255 });
DrawText(TextFormat("BEST: %i", bestscore), 580, 0, 30,(Color){ 138, 72, 4, 255 });
else
DrawTextEx(ZadoBold, TextFormat("BEST: %i", bestscore), (Vector2){ 580, 0 }, 30, 2, BLUE);
DrawText(TextFormat("BEST: %i", bestscore), 580, 0, 30, BLUE);
}
@ -49,15 +49,15 @@ void DrawTitleScreen(void)
{
DrawTexture(background, 0, 0, GRAY);
DrawTextEx(ZadoBold, "Avoid", (Vector2){ 300, 0 }, 80, 5, BLUE);
// DrawText("Controls", 10, 10, 30, BLUE);
DrawText("Controls", 5, 10, 30, BLUE);
DrawScore();
/* DrawText("Press the arrow keys or 'DPAD' to move and 'X' to dash", 10, 40, 10, WHITE);
DrawText("Press 'ENTER' or 'START' to pause", 10, 60, 10, WHITE);
DrawText("Press 'M' to mute", 10, 80, 10, WHITE);
DrawText("Press 'Left-ALT' + 'F' for full screen", 10, 100, 10, WHITE);
DrawText("Press 'R' to restart", 10, 120, 10, WHITE);
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("Press the arrow keys or 'DPAD' to move and 'X' to dash", 5, 40, 10, WHITE);
DrawText("Press 'ENTER' or 'START' to pause", 5, 60, 10, WHITE);
DrawText("Press 'M' to mute", 5, 80, 10, WHITE);
DrawText("Press 'Left-ALT' + 'F' for full screen", 5, 100, 10, WHITE);
DrawText("Press 'R' to restart", 5, 120, 10, WHITE);
DrawText("Press 'ENTER' or 'START' to select an option", 5, 140, 10, WHITE);
DrawText("Press 'X' or 'A' on a gamepad to shoot", 5, 160, 10, WHITE);
// DrawText("Ver: 0.1", 680, 420, 30, WHITE);
if (titleSelected == 0) DrawTextEx(ZadoBold,"PLAY", (Vector2){ 360, 220 }, 30, 2, WHITE);
else DrawTextEx(ZadoBold,"PLAY", (Vector2){ 360, 220 }, 30, 2, BLUE);