added dash mechanic

This commit is contained in:
Return0ne 2022-05-29 12:02:30 -04:00
parent f178ca3ae1
commit d40c51a4db
3 changed files with 21 additions and 10 deletions

View file

@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"birbis3","description":"","fps":1,"height":70,"width":70,"layers":["{\"name\":\"Layer 1\",\"opacity\":1,\"frameCount\":3,\"chunks\":[{\"layout\":[[0],[1],[2]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANIAAABGCAYAAAC5bsoXAAADj0lEQVR4nO2YTW7jMAxGtexter25UA4zq56nwACeRdDCcWRbPxRJie8BAgZtJxLJ70VxUgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABW2lDb364ZnGenn3wD6mEtSsNJOFESyYvvcZlungdm+X5dEexyIUipSysh0/J1ET0RwkKPsWq4gROoWKfdziZ50oyPEcyESIhWv/M3TJdKf7d92t9oaqpSTff2IhEgtIh3X4ZYqYnqRWmVqxoEYiNQv0plMbz2yxCIvNTJNVxwiDRHp6iOduUiWmSmVadoCEWn4jZTeRdPHQWZyvXhmBpFuEcmAtSQCIqXXv9HFeU5kJDIuFJHkREp5aWxFcpqT108uiIRINyLtf17bE5Fv7Zzm5E0kERyIgUgyH+0ke9ItkuOcIFLl+rul7Kpqj7UkwksmNHdNs5996Rtuay7cFo1Ii4jkYO6tIvXJ5KBgRFpEJAczl8hImOIRqX3JvQPPn6OzfLT1xUFBiGQnkphMDuYtKVJ9XxwUhEi2IuV6UvWNnYNZS0tUnxUHRQ1bAlgHX0ukY2iKRbKe8WCRymVyUBQi+RCp+uOM9XwRCZGsVkopiYhkPVuBbCASInWJdBWiEJnZwTMSInWJdBaiEJk5gEiI1CVSLkQh8nICX38jUrNI4bJyAyIh0liRrGfpKBNrNwiREAmR/DbNOvhuRHKYlcfXx/b4+kCkkiZVNwqRxolUyO/cFtmnm5cwB9p7j3XwZxNJa25e8lEEIiFSLdxGGRBpDZH2vRzZT82ZechGMdFF8nAGCY4ijapHW6Jp5oJI9meQICdSrqaeOrmNLkAk+zNIUSJTa53afZpuJohkfwZJrmTqqVO7R9PNJLJIWg/oFpwJ1VKn1W001UyiiqT1cG6JhEgW/ZlyHl7CbLn3dEMrRFKkUWf0smc3XsJste+UQ6ugp1bL22i6maws0tm3VlEk+qFXpJFn87CnCBFEOn5rFUmiPaU1W/Vo6tlEEUnieWFmSmu26NESs4kq0oj9PFJae+5vNPplta84EUUasZdXSuq/+v2ovtWcSXLfYawsUm6faQYjQO1tVPI6WmeS3ncolu/YmvtGvJWka5Z4nZbzuJ/X1fODxsG1944m04h6pURq+T9u5xVNpNyeo/bxwEq1uq7h7sFS+2aw2HvEHl6IUqcZNQ+fIwZx9boatxMBAxGiiwQgQmlILUQavTfAFf8BsIa/63/h/PcAAAAASUVORK5CYII=\"}]}"],"hiddenFrames":[null]}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 609 B

After

Width:  |  Height:  |  Size: 969 B

View file

@ -1,10 +1,11 @@
/*
- Avoid a game by Canneddonuts
- Avoid ~ a game by Canneddonuts
- Filename ~ Main.c
- Author ~ Return0ne
- 2022
- *no license*
*/
#include "../include/raylib.h"
#if defined(PLATFORM_WEB)
@ -30,11 +31,12 @@ typedef struct Ball {
typedef struct Player {
Texture2D sprite;
float speed;
int hp;
int currentframe;
Vector2 sprite_pos;
Rectangle frameRec;
Rectangle hitbox;
int hp;
} Player;
// Game variables
@ -91,11 +93,12 @@ void gameSetup(void)
player.sprite = LoadTexture("assets/gfx/player.png");
player.currentframe = 0;
player.speed = 300.0f;
player.hp = 30;
player.frameRec = (Rectangle) {
0.0f,
0.0f,
(float) player.sprite.width/2,
(float) player.sprite.width/3,
(float) player.sprite.height
};
player.hitbox = (Rectangle) {
@ -143,13 +146,19 @@ void updateGame(void)
if (!pause) {
// Controls
if (IsKeyDown(KEY_LEFT)) player.hitbox.x -= GetFrameTime() * 300.0f;
if (IsKeyDown(KEY_RIGHT)) player.hitbox.x += GetFrameTime() * 300.0f;
if (IsKeyDown(KEY_UP)) player.hitbox.y -= GetFrameTime() * 300.0f;
if (IsKeyDown(KEY_DOWN)) player.hitbox.y += GetFrameTime() * 300.0f;
if (IsKeyDown(KEY_LEFT)) player.hitbox.x -= GetFrameTime() * player.speed;
if (IsKeyDown(KEY_RIGHT)) player.hitbox.x += GetFrameTime() * player.speed;
if (IsKeyDown(KEY_UP)) player.hitbox.y -= GetFrameTime() * player.speed;
if (IsKeyDown(KEY_DOWN)) player.hitbox.y += GetFrameTime() * player.speed;
if (IsKeyDown(KEY_X)) {
// player.speed *= 2;
player.speed = 600.0f;
if (player.currentframe != 1) player.currentframe = 2;
} else player.speed = 300.0f;
player.sprite_pos = (Vector2){ player.hitbox.x, player.hitbox.y };
player.frameRec.x = (float)player.currentframe*(float)player.sprite.width/2;
player.frameRec.x = (float)player.currentframe*(float)player.sprite.width/3;
// Player to da wallz collies
if ((player.hitbox.x + player.hitbox.width) >= GetScreenWidth()) player.hitbox.x = GetScreenWidth() - player.hitbox.width;
@ -174,7 +183,7 @@ void updateGame(void)
if (ball.active) {
score++;
// moveiement of the balls
// movement of the ball
ball.position.x += GetFrameTime() * ball.speed.x;
ball.position.y += GetFrameTime() * ball.speed.y;
@ -232,7 +241,7 @@ void drawGame(void)
DrawRectangle(0, 0, screenWidth, screenHeight, ORANGE);
DrawText("Controls", 10, 10, 30, PURPLE);
DrawText(TextFormat("BEST: %i", bestscore), 600, 0, 30, WHITE);
DrawText("Press the arrow keys to move", 10, 40, 10, RED);
DrawText("Press the arrow keys to move and 'X' to dash", 10, 40, 10, RED);
DrawText("Press 'ENTER' to pause", 10, 60, 10, RED);
DrawText("Press 'M' to mute", 10, 80, 10, RED);
DrawText("Press 'Left-ALT' + 'F' for full screen", 10, 100, 10, RED);
@ -290,6 +299,7 @@ void gameReset(void)
{
// code to reset all variables without reloading assets
player.currentframe = 0;
player.speed = 300.0f;
player.hp = 30;
player.hitbox = (Rectangle) {
GetScreenWidth()/2.0f - 30,