[Added] Sprite animation for player, crosshair mouse, [Updated] Collision

This commit is contained in:
Ninjaws
2024-12-12 20:31:56 +01:00
parent 770d3e3c71
commit dbeb15ee60
11 changed files with 220 additions and 52 deletions
+3 -3
View File
@@ -35,7 +35,7 @@ MainScreen::MainScreen()
AudioService::getInstance().playMusic();
}
InputService::getInstance().setKeysToWatch({KEY_ENTER, KEY_W, KEY_S}, {MOUSE_BUTTON_LEFT});
InputService::getInstance().setKeysToWatch({KEY_ENTER, KEY_W, KEY_S}, {});
}
void MainScreen::logic()
@@ -44,7 +44,7 @@ void MainScreen::logic()
// std::cout << mouseD.y <<std::endl;
// if (mouseD.x != 0.0f && mouseD.y != 0.0f)
// {
mouseLogic();
// mouseLogic();
// }
keyboardLogic();
@@ -92,7 +92,7 @@ void MainScreen::keyboardLogic()
void MainScreen::clickLogic()
{
if (InputService::getInstance().isKeyPressed(KEY_ENTER) || InputService::getInstance().isMouseButtonPressed(MOUSE_BUTTON_LEFT))
if (InputService::getInstance().isKeyPressed(KEY_ENTER))
{
std::string selectedButton = buttons[hoveredButton].getText();
+2 -2
View File
@@ -29,13 +29,13 @@ TitleScreen::TitleScreen()
AudioService::getInstance().playMusic();
}
InputService::getInstance().setKeysToWatch({KEY_ENTER}, {MOUSE_BUTTON_LEFT});
InputService::getInstance().setKeysToWatch({KEY_ENTER}, {});
}
void TitleScreen::logic()
{
// std::cout << "Next screen!" << std::endl;
if (InputService::getInstance().isKeyPressed(KEY_ENTER) || InputService::getInstance().isMouseButtonPressed(MOUSE_BUTTON_LEFT))
if (InputService::getInstance().isKeyPressed(KEY_ENTER))
{
StateService::getInstance().setScreen(EScreen::MAIN);
}
+2 -2
View File
@@ -13,12 +13,12 @@ TutorialScreen::TutorialScreen() {
this->background = Background(EBackground::TUTORIAL);
InputService::getInstance().setKeysToWatch({KEY_ENTER}, {MOUSE_BUTTON_LEFT});
InputService::getInstance().setKeysToWatch({KEY_ENTER},{});
}
void TutorialScreen::logic()
{
if ( InputService::getInstance().isKeyPressed(KEY_ENTER) || InputService::getInstance().isMouseButtonPressed(MOUSE_BUTTON_LEFT))
if ( InputService::getInstance().isKeyPressed(KEY_ENTER))
{
StateService::getInstance().setScreen(EScreen::MAIN);
}
+1
View File
@@ -43,6 +43,7 @@ void AssetService::setAssets()
sprites[ESprite::HUD_HEART] = loadTexture("Textures/heart.png");
sprites[ESprite::HUD_HEART_EMPTY] = loadTexture("Textures/heart_empty.png");
sprites[ESprite::HUD_AMMO] = loadTexture("Textures/bullet_hud.png");
sprites[ESprite::CROSSHAIR] = loadTexture("Textures/crosshair_3.png");
}
Font AssetService::getFont(EFont font, int fontSize)
+4 -3
View File
@@ -45,10 +45,11 @@ void StateService::startGame()
{
// if(!instance)
// return;
InitAudioDevice();
// InitAudioDevice();
// InitWindow(640,544, "Jelly Rescue");
InitWindow(screenSize.x, screenSize.y, "Jelly Rescue");
SetTargetFPS(60);
SetTargetFPS(45);
HideCursor();
// #if defined(PLATFORM_WEB)
// emscripten_set_keypress_callback(EMSCRIPTEN_EVENT_TARGET_CANVAS, nullptr, 1, staticStep);
@@ -74,7 +75,7 @@ void StateService::startGame()
#endif
CloseWindow();
CloseAudioDevice();
// CloseAudioDevice();
}
void StateService::handleMusic()