Compare commits
No commits in common. "e4b8831e8d0bf1710bbebb384cd599b2f4f5011e" and "2e3d37385b6f3239f64651aefc79eda1e7a0b7ac" have entirely different histories.
e4b8831e8d
...
2e3d37385b
12 changed files with 66 additions and 93 deletions
File diff suppressed because one or more lines are too long
|
@ -1,9 +0,0 @@
|
||||||
GIMP Palette
|
|
||||||
Name: Avoid_bg
|
|
||||||
Columns: 0
|
|
||||||
#
|
|
||||||
248 248 248 Untitled
|
|
||||||
166 166 166 Untitled
|
|
||||||
30 142 20 Untitled
|
|
||||||
22 85 93 Untitled
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include "Screens.h"
|
#include "Screens.h"
|
||||||
#include "Controls.h"
|
#include "Controls.h"
|
||||||
#include "Textures.h"
|
|
||||||
|
|
||||||
void UpdateCreditsScreen(void)
|
void UpdateCreditsScreen(void)
|
||||||
{
|
{
|
||||||
|
@ -19,11 +18,15 @@ void UpdateCreditsScreen(void)
|
||||||
|
|
||||||
void DrawCreditsScreen(void)
|
void DrawCreditsScreen(void)
|
||||||
{
|
{
|
||||||
DrawTexture(background, 0, 0, DARKGRAY);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN);
|
||||||
DrawText("CREDITS", 290, 20, 50, BLUE);
|
|
||||||
|
DrawText("Avoid", 330, 20, 50, MAGENTA);
|
||||||
|
|
||||||
DrawText("Programming and Art by Return0ne", 10, 210, 20, BLUE);
|
DrawText("Programming and Art by Return0ne", 10, 210, 20, BLUE);
|
||||||
|
|
||||||
DrawText("Powered by raylib 4.0", 10, 240, 20, BLUE);
|
DrawText("Powered by raylib 4.0", 10, 240, 20, BLUE);
|
||||||
DrawText("A Canneddonuts project 2022", 10, 270, 40, BLUE);
|
|
||||||
DrawText(TextFormat("Build compiled on %s", __DATE__), 10, 310, 30, YELLOW);
|
DrawText("A Canneddonuts project 2022", 10, 270, 40, RED);
|
||||||
|
|
||||||
DrawText("Press 'ENTER' ", 10, 350, 20, WHITE);
|
DrawText("Press 'ENTER' ", 10, 350, 20, WHITE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ void UpdateGameoverScreen(void)
|
||||||
|
|
||||||
void DrawGameoverScreen(void)
|
void DrawGameoverScreen(void)
|
||||||
{
|
{
|
||||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE);
|
||||||
DrawText("GAMEOVER", 250, 20, 50, RED);
|
DrawText("GAMEOVER", 250, 20, 50, RED);
|
||||||
if (gameoverSelected == 0) DrawText("RETRY", 350, 200, 20, WHITE);
|
if (gameoverSelected == 0) DrawText("RETRY", 350, 200, 20, WHITE);
|
||||||
else DrawText("RETRY", 350, 200, 20, RED);
|
else DrawText("RETRY", 350, 200, 20, RED);
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "Controls.h"
|
#include "Controls.h"
|
||||||
#include "Gameplay.h"
|
#include "Gameplay.h"
|
||||||
#include "Score.h"
|
#include "Score.h"
|
||||||
#include "Textures.h"
|
|
||||||
|
|
||||||
int score = 0, bestscore = 0;
|
int score = 0, bestscore = 0;
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ void InitGameplayScreen(void)
|
||||||
(float) heart.sprite.width,
|
(float) heart.sprite.width,
|
||||||
(float) heart.sprite.height
|
(float) heart.sprite.height
|
||||||
};
|
};
|
||||||
heart.active = true;
|
heart.active = false;
|
||||||
|
|
||||||
ball.position = (Vector2){ 50, 50 };
|
ball.position = (Vector2){ 50, 50 };
|
||||||
ball.speed = (Vector2){ 400.0f, 300.0f };
|
ball.speed = (Vector2){ 400.0f, 300.0f };
|
||||||
|
@ -56,7 +55,7 @@ void InitGameplayScreen(void)
|
||||||
ball.active = true;
|
ball.active = true;
|
||||||
|
|
||||||
pause = 0;
|
pause = 0;
|
||||||
mute = true;
|
mute = 0;
|
||||||
DebugMode = 0;
|
DebugMode = 0;
|
||||||
pauseTimer = 0;
|
pauseTimer = 0;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +79,7 @@ void ResetGameplayScreen(void)
|
||||||
(float) heart.sprite.width,
|
(float) heart.sprite.width,
|
||||||
(float) heart.sprite.height
|
(float) heart.sprite.height
|
||||||
};
|
};
|
||||||
heart.active = true;
|
heart.active = false;
|
||||||
|
|
||||||
ball.position = (Vector2){ 50, 50 };
|
ball.position = (Vector2){ 50, 50 };
|
||||||
ball.radius = 20;
|
ball.radius = 20;
|
||||||
|
@ -115,7 +114,16 @@ void UpdateGameplayScreen(void)
|
||||||
|
|
||||||
heart.sprite_pos = (Vector2){ heart.hitbox.x, heart.hitbox.y };
|
heart.sprite_pos = (Vector2){ heart.hitbox.x, heart.hitbox.y };
|
||||||
|
|
||||||
if (score % 1000 == 0) heart.active = true;
|
if (score == 1000) heart.active = true;
|
||||||
|
if (score == 2000) heart.active = true;
|
||||||
|
if (score == 3000) heart.active = true;
|
||||||
|
if (score == 4000) heart.active = true;
|
||||||
|
if (score == 5000) heart.active = true;
|
||||||
|
if (score == 6000) heart.active = true;
|
||||||
|
if (score == 7000) heart.active = true;
|
||||||
|
if (score == 8000) heart.active = true;
|
||||||
|
if (score == 9000) heart.active = true;
|
||||||
|
if (score == 10000) heart.active = true;
|
||||||
|
|
||||||
// Player to da wallz collies
|
// Player to da wallz collies
|
||||||
if ((player.hitbox.x + player.hitbox.width) >= GetScreenWidth()) player.hitbox.x = GetScreenWidth() - player.hitbox.width;
|
if ((player.hitbox.x + player.hitbox.width) >= GetScreenWidth()) player.hitbox.x = GetScreenWidth() - player.hitbox.width;
|
||||||
|
@ -149,13 +157,12 @@ void UpdateGameplayScreen(void)
|
||||||
|
|
||||||
if (ball.active) {
|
if (ball.active) {
|
||||||
score++;
|
score++;
|
||||||
|
|
||||||
if (score >= bestscore) bestscore = score;
|
|
||||||
|
|
||||||
// movement of the ball
|
// movement of the ball
|
||||||
ball.position.x += GetFrameTime() * ball.speed.x;
|
ball.position.x += GetFrameTime() * ball.speed.x;
|
||||||
ball.position.y += GetFrameTime() * ball.speed.y;
|
ball.position.y += GetFrameTime() * ball.speed.y;
|
||||||
|
|
||||||
|
if (score >= bestscore) bestscore = score;
|
||||||
|
|
||||||
// Ballz to da wallz collies
|
// Ballz to da wallz collies
|
||||||
if ((ball.position.x >= (GetScreenWidth() - ball.radius)) || (ball.position.x <= ball.radius)) {
|
if ((ball.position.x >= (GetScreenWidth() - ball.radius)) || (ball.position.x <= ball.radius)) {
|
||||||
ball.speed.x *= -1.0f;
|
ball.speed.x *= -1.0f;
|
||||||
|
@ -181,7 +188,7 @@ void UpdateGameplayScreen(void)
|
||||||
|
|
||||||
void DrawGameplayScreen(void)
|
void DrawGameplayScreen(void)
|
||||||
{
|
{
|
||||||
DrawTexture(background, 0, 0, RAYWHITE);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK);
|
||||||
DrawFPS(10, 430);
|
DrawFPS(10, 430);
|
||||||
DrawText(TextFormat("HP: %i", player.hp), 10, 10, 20, RED);
|
DrawText(TextFormat("HP: %i", player.hp), 10, 10, 20, RED);
|
||||||
DrawText(TextFormat("SCORE: %i", score), 10, 30, 20, BLUE);
|
DrawText(TextFormat("SCORE: %i", score), 10, 30, 20, BLUE);
|
||||||
|
@ -194,7 +201,7 @@ void DrawGameplayScreen(void)
|
||||||
}
|
}
|
||||||
if (ball.active) DrawCircleV(ball.position, (float)ball.radius, ball.color);
|
if (ball.active) DrawCircleV(ball.position, (float)ball.radius, ball.color);
|
||||||
if (heart.active) DrawTexture(heart.sprite, heart.sprite_pos.x, heart.sprite_pos.y, RAYWHITE);
|
if (heart.active) DrawTexture(heart.sprite, heart.sprite_pos.x, heart.sprite_pos.y, RAYWHITE);
|
||||||
DrawTextureRec(player.sprite, player.frameRec, player.sprite_pos, RAYWHITE);
|
DrawTextureRec(player.sprite, player.frameRec, player.sprite_pos, WHITE);
|
||||||
if (pause && ((pauseTimer/30)%2)) DrawText("PAUSED", 330, 190, 30, PURPLE);
|
if (pause && ((pauseTimer/30)%2)) DrawText("PAUSED", 330, 190, 30, PURPLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,16 @@
|
||||||
#ifndef GAMEPLAY_HEADER
|
#ifndef GAMEPLAY_HEADER
|
||||||
#define GAMEPLAY_HEADER
|
#define GAMEPLAY_HEADER
|
||||||
|
|
||||||
struct Ball {
|
typedef struct Ball {
|
||||||
Vector2 position;
|
Vector2 position;
|
||||||
Vector2 speed;
|
Vector2 speed;
|
||||||
float radius;
|
float radius;
|
||||||
float growth;
|
float growth;
|
||||||
Color color;
|
Color color;
|
||||||
bool active;
|
bool active;
|
||||||
};
|
} Ball;
|
||||||
|
|
||||||
struct Player {
|
typedef struct Player {
|
||||||
Texture2D sprite;
|
Texture2D sprite;
|
||||||
float speed;
|
float speed;
|
||||||
int hp;
|
int hp;
|
||||||
|
@ -26,20 +26,20 @@ struct Player {
|
||||||
Vector2 sprite_pos;
|
Vector2 sprite_pos;
|
||||||
Rectangle frameRec;
|
Rectangle frameRec;
|
||||||
Rectangle hitbox;
|
Rectangle hitbox;
|
||||||
};
|
} Player;
|
||||||
|
|
||||||
struct Item {
|
typedef struct Item {
|
||||||
Texture2D sprite;
|
Texture2D sprite;
|
||||||
Vector2 sprite_pos;
|
Vector2 sprite_pos;
|
||||||
Rectangle hitbox;
|
Rectangle hitbox;
|
||||||
bool active;
|
bool active;
|
||||||
};
|
} Item;
|
||||||
|
|
||||||
struct Player player = { 0 };
|
|
||||||
struct Ball ball = { 0 };
|
|
||||||
struct Item heart = { 0 };
|
|
||||||
int pauseTimer;
|
int pauseTimer;
|
||||||
Sound fxbounce = { 0 };
|
Sound fxbounce = { 0 };
|
||||||
|
Player player = { 0 };
|
||||||
|
Ball ball = { 0 };
|
||||||
|
Item heart = { 0 };
|
||||||
bool pause;
|
bool pause;
|
||||||
bool mute;
|
bool mute;
|
||||||
bool DebugMode;
|
bool DebugMode;
|
||||||
|
|
10
src/Main.c
10
src/Main.c
|
@ -9,6 +9,8 @@
|
||||||
#include "../include/raylib.h"
|
#include "../include/raylib.h"
|
||||||
|
|
||||||
#include "Screens.h"
|
#include "Screens.h"
|
||||||
|
#include "Controls.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
#include <emscripten/emscripten.h>
|
#include <emscripten/emscripten.h>
|
||||||
|
@ -19,7 +21,7 @@ static const int screenWidth = 800;
|
||||||
static const int screenHeight = 450;
|
static const int screenHeight = 450;
|
||||||
|
|
||||||
GameScreen currentScreen = 0;
|
GameScreen currentScreen = 0;
|
||||||
Texture2D background = { 0 };
|
|
||||||
|
|
||||||
// Game functions
|
// Game functions
|
||||||
static void gameSetup(void);
|
static void gameSetup(void);
|
||||||
|
@ -59,7 +61,6 @@ void gameSetup(void)
|
||||||
currentScreen = TITLE;
|
currentScreen = TITLE;
|
||||||
|
|
||||||
InitGameplayScreen();
|
InitGameplayScreen();
|
||||||
InitTitleScreen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateGame(void)
|
void updateGame(void)
|
||||||
|
@ -67,7 +68,7 @@ void updateGame(void)
|
||||||
// code that runs as long as the program is running
|
// code that runs as long as the program is running
|
||||||
if ((IsKeyDown(KEY_LEFT_ALT)) && (IsKeyPressed(KEY_F))) ToggleFullscreen();
|
if ((IsKeyDown(KEY_LEFT_ALT)) && (IsKeyPressed(KEY_F))) ToggleFullscreen();
|
||||||
|
|
||||||
switch (currentScreen) {
|
switch(currentScreen) {
|
||||||
case TITLE: UpdateTitleScreen(); break;
|
case TITLE: UpdateTitleScreen(); break;
|
||||||
case GAMEPLAY: UpdateGameplayScreen(); break;
|
case GAMEPLAY: UpdateGameplayScreen(); break;
|
||||||
case GAMEOVER: UpdateGameoverScreen(); break;
|
case GAMEOVER: UpdateGameoverScreen(); break;
|
||||||
|
@ -83,7 +84,7 @@ void drawGame(void)
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
switch (currentScreen) {
|
switch(currentScreen) {
|
||||||
case TITLE: DrawTitleScreen(); break;
|
case TITLE: DrawTitleScreen(); break;
|
||||||
case GAMEPLAY: DrawGameplayScreen(); break;
|
case GAMEPLAY: DrawGameplayScreen(); break;
|
||||||
case GAMEOVER: DrawGameoverScreen(); break;
|
case GAMEOVER: DrawGameoverScreen(); break;
|
||||||
|
@ -103,5 +104,4 @@ void gameLoop(void)
|
||||||
void unloadGame(void)
|
void unloadGame(void)
|
||||||
{
|
{
|
||||||
UnloadGameplayScreen();
|
UnloadGameplayScreen();
|
||||||
UnloadTitleScreen();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,8 @@ extern GameScreen currentScreen;
|
||||||
|
|
||||||
void gameReset(void);
|
void gameReset(void);
|
||||||
|
|
||||||
void InitTitleScreen(void);
|
|
||||||
void UpdateTitleScreen(void);
|
void UpdateTitleScreen(void);
|
||||||
void DrawTitleScreen(void);
|
void DrawTitleScreen(void);
|
||||||
void UnloadTitleScreen(void);
|
|
||||||
|
|
||||||
|
|
||||||
void InitGameplayScreen(void);
|
void InitGameplayScreen(void);
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
/*
|
|
||||||
- Avoid ~ a game by Canneddonuts
|
|
||||||
- Filename ~ Textures.h
|
|
||||||
- Author ~ Return0ne
|
|
||||||
- 2022
|
|
||||||
- *no license*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TEXTURES_HEADER
|
|
||||||
#define TEXTURES_HEADER
|
|
||||||
|
|
||||||
extern Texture2D background;
|
|
||||||
|
|
||||||
#endif
|
|
27
src/Title.c
27
src/Title.c
|
@ -11,15 +11,9 @@
|
||||||
#include "Screens.h"
|
#include "Screens.h"
|
||||||
#include "Controls.h"
|
#include "Controls.h"
|
||||||
#include "Score.h"
|
#include "Score.h"
|
||||||
#include "Textures.h"
|
|
||||||
|
|
||||||
int titleSelected = 0;
|
int titleSelected = 0;
|
||||||
|
|
||||||
void InitTitleScreen(void)
|
|
||||||
{
|
|
||||||
background = LoadTexture("assets/gfx/background.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateTitleScreen(void)
|
void UpdateTitleScreen(void)
|
||||||
{
|
{
|
||||||
if (INPUT_UP_PRESSED) titleSelected++;
|
if (INPUT_UP_PRESSED) titleSelected++;
|
||||||
|
@ -34,15 +28,15 @@ void UpdateTitleScreen(void)
|
||||||
|
|
||||||
void DrawTitleScreen(void)
|
void DrawTitleScreen(void)
|
||||||
{
|
{
|
||||||
DrawTexture(background, 0, 0, GRAY);
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), ORANGE);
|
||||||
DrawText("Controls", 10, 10, 30, BLUE);
|
DrawText("Controls", 10, 10, 30, PURPLE);
|
||||||
DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, WHITE);
|
DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, WHITE);
|
||||||
DrawText("Press the arrow keys or 'DPAD' to move and 'X' to dash", 10, 40, 10, WHITE);
|
DrawText("Press the arrow keys or 'DPAD' to move and 'X' to dash", 10, 40, 10, RED);
|
||||||
DrawText("Press 'ENTER' or 'START' to pause", 10, 60, 10, WHITE);
|
DrawText("Press 'ENTER' or 'START' to pause", 10, 60, 10, RED);
|
||||||
DrawText("Press 'M' to mute", 10, 80, 10, WHITE);
|
DrawText("Press 'M' to mute", 10, 80, 10, RED);
|
||||||
DrawText("Press 'Left-ALT' + 'F' for full screen", 10, 100, 10, WHITE);
|
DrawText("Press 'Left-ALT' + 'F' for full screen", 10, 100, 10, RED);
|
||||||
DrawText("Press 'R' to restart", 10, 120, 10, WHITE);
|
DrawText("Press 'R' to restart", 10, 120, 10, RED);
|
||||||
DrawText("Press 'ENTER' or 'START' to select an option", 10, 140, 10, WHITE);
|
DrawText("Press 'ENTER' or 'START' to select an option", 10, 140, 10, RED);
|
||||||
DrawText("Avoid", 330, 20, 50, BLUE);
|
DrawText("Avoid", 330, 20, 50, BLUE);
|
||||||
if (titleSelected == 0) DrawText("PLAY", 360, 220, 20, WHITE);
|
if (titleSelected == 0) DrawText("PLAY", 360, 220, 20, WHITE);
|
||||||
else DrawText("PLAY", 360, 220, 20, BLUE);
|
else DrawText("PLAY", 360, 220, 20, BLUE);
|
||||||
|
@ -53,8 +47,3 @@ void DrawTitleScreen(void)
|
||||||
if (titleSelected == -2) DrawText("MORE GAMES", 320, 260, 20, WHITE);
|
if (titleSelected == -2) DrawText("MORE GAMES", 320, 260, 20, WHITE);
|
||||||
else DrawText("MORE GAMES", 320, 260, 20, BLUE);
|
else DrawText("MORE GAMES", 320, 260, 20, BLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnloadTitleScreen(void)
|
|
||||||
{
|
|
||||||
UnloadTexture(background);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue