a,d keys implemented and screen for 1080p

This commit is contained in:
Alan Youngblood 2021-12-30 13:42:55 -05:00
parent b9e9c04235
commit af393e8acb
7 changed files with 83 additions and 11 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
{
"GameName":"Beagle Rescue",
"WindowName":"Beagle Rescue",
"WindowSize":{"w":320,"h":240},
"WindowSize":{"w":640,"h":360},
"WindowFullScreen": 0,
"GlobalScale": 1
"GlobalScale": 3
}

View File

@ -78,6 +78,24 @@ public:
sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
}
break;
case SDLK_a:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.x = -1;
if(Game::playerIsGrounded){
sprite->Play("Walk");
}
sprite->spriteFlip = SDL_FLIP_NONE;
}
break;
case SDLK_d:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.x = 1;
if(Game::playerIsGrounded){
sprite->Play("Walk");
}
sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
}
break;
case SDLK_k:
if (!Game::debugCollisionBoxes)
{ Game::debugCollisionBoxes = true; }
@ -129,7 +147,7 @@ public:
}
}
break;
case SDLK_RIGHT:
case SDLK_RIGHT:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.x = 0;
sprite->Play("Idle");
@ -138,6 +156,25 @@ public:
}
}
break;
case SDLK_a:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.x = 0;
sprite->Play("Idle");
if (!Game::gravityOnPlayer){
Game::gravityOnPlayer = true;
// sprite->Play("Fall");
}
}
break;
case SDLK_d:
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
transform->velocity.x = 0;
sprite->Play("Idle");
if (!Game::gravityOnPlayer){
Game::gravityOnPlayer = true;
}
}
break;
case SDLK_k:
break;
case SDLK_j:
@ -151,13 +188,13 @@ public:
break;
case SDLK_i:
break;
case SDLK_d:
if (Game::debugMenu == false){
Game::debugMenu = true;}
else {
Game::debugMenu = false;
}
break;
// case SDLK_d:
// if (Game::debugMenu == false){
// Game::debugMenu = true;}
// else {
// Game::debugMenu = false;
// }
// break;
case SDLK_ESCAPE: // exit the game when Escape pressed
Game::isRunning = false;
break;

View File

@ -31,6 +31,7 @@ UINineSlice* scoreboard9Slice;
UINineSlice* debugBox;
UIText* debugStaticText;
UIText* debugdynamicText;
UIText* debugJumpText;
GameStateManager* Game::gsm = new GameStateManager();
@ -64,6 +65,16 @@ int last_time;
int current_time;
int diff_time;
std::string Game::BoolToString(bool b) {
std::string myString;
if (b) {
myString = "true";
} else {
myString = "false";
}
return myString;
}
Game::Game() {
// TODO Auto-generated constructor stub
@ -146,7 +157,9 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
UIText* debugStaticText4;
UIText* debugStaticText5;
UIText* debugStaticText6;
UIText* debugStaticText7;
UIText* debugStaticText7;
std::string debugStaticString = "Collision";
debugStaticText = new UIText(debugStaticString, "font", 0,0,8,12,1);
debugStaticText->ParseString(debugStaticString,220*globalScale,14*gScale,1,"debug",Game::groupUI_Layer3);
@ -169,6 +182,9 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
debugStaticText7 = new UIText(debugStaticString7, "font", 0,0,8,12,1);
debugStaticText7->ParseString(debugStaticString7,220*globalScale,74*gScale,1,"debug",Game::groupUI_Layer3);
debugJumpText = new UIText(Game::BoolToString(playerIsJumping), "font", 0,0,8,12,1);
debugJumpText->ParseString(Game::BoolToString(playerIsJumping),260*globalScale,44*gScale,1,"debugJumpText",Game::groupUI_Layer3);
// debug UI box
SDL_Rect debugBoxRect = SDL_Rect();
debugBoxRect.x = 220*globalScale;
@ -259,6 +275,15 @@ void Game::update()
// Mix_PlayChannel(-1, Game::assets->GetSoundClip("bark1"),0);
// }
// for (auto& letter : debugText)
// {
// if(letter->tag=="debugJumpText"){
// std::cout<<letter->tag<<std::endl;
// }
// }
// debugJumpText->ParseString(Game::BoolToString(playerIsJumping),260*gScale,44*gScale,1,"debugJumpText",Game::groupUI_Layer3);
manager.refresh();
manager.update();
@ -407,3 +432,4 @@ void Game::drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blu
SDL_SetRenderDrawColor(renderer, red, green, blue, 255);
SDL_RenderDrawLine(renderer, srcpt.x, srcpt.y, destpt.x, destpt.y);
}

View File

@ -45,6 +45,7 @@ public:
static SDL_Rect camera;
static AssetManager* assets;
static GameStateManager* gsm;
std::string BoolToString(bool b);
enum groupLabels : std::size_t
{
groupMap,

View File

@ -65,3 +65,9 @@ void UIText::AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrS
letter.setTag(tag);
letter.addGroup(groupLabel);
}
void UIText::RemoveAllLetters()
{
manager.getEntitiesByTag("");
}

View File

@ -26,6 +26,8 @@ public:
void AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrScale, Game::groupLabels groupLabel);
void ParseString(std::string inputText, int x, int y, int letterScale, std::string tag, Game::groupLabels group);
void RemoveAllLetters();
void UpdateString(std::string newInputText);
int scale;
};