Firefighter better animations added
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
#include <string>
|
||||
#include "SDL2/SDL.h"
|
||||
#include "Components.h"
|
||||
#include "ECS.h"
|
||||
#include "../assetmgr/TextureManager.h"
|
||||
#include <iostream>
|
||||
|
||||
@ -72,19 +73,19 @@ public:
|
||||
|
||||
void update() override
|
||||
{
|
||||
// if(tag != "terrain")
|
||||
// {
|
||||
// collider.x = static_cast<int>(transform->position.x)+9;
|
||||
// collider.y = static_cast<int>(transform->position.y)+28;
|
||||
//// collider.w = transform->width * transform->scale;
|
||||
//// collider.h = transform->height * transform->scale;
|
||||
// collider.w = 12 * transform->scale;
|
||||
// collider.h = 12 * transform->scale;
|
||||
if(tag != "terrain")
|
||||
{
|
||||
collider.x = static_cast<int>(transform->position.x);
|
||||
collider.y = static_cast<int>(transform->position.y);
|
||||
collider.w = transform->width * transform->scale;
|
||||
collider.h = transform->height * transform->scale;
|
||||
// collider.w = 12 * transform->scale;
|
||||
// collider.h = 12 * transform->scale;
|
||||
//
|
||||
//// std::cout << "collider.w: " << collider.w << std::endl;
|
||||
//// std::cout << "collider.h: " << collider.h << std::endl;
|
||||
//// std::cout << "tag: " << tag << std::endl;
|
||||
// }
|
||||
// std::cout << "collider.w: " << collider.w << std::endl;
|
||||
// std::cout << "collider.h: " << collider.h << std::endl;
|
||||
// std::cout << "tag: " << tag << std::endl;
|
||||
}
|
||||
destR.x = collider.x - Game::camera.x;
|
||||
destR.y = collider.y - Game::camera.y;
|
||||
// std::cout << "tag: " << tag << std::endl;
|
||||
|
@ -34,39 +34,39 @@ public:
|
||||
switch (Game::event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_UP:
|
||||
transform->velocity.y = -1;
|
||||
// transform->velocity.y = -1;
|
||||
// sprite->Play("WalkNorth");
|
||||
if (transform->velocity.x < 0)
|
||||
{
|
||||
// if (transform->velocity.x < 0)
|
||||
// {
|
||||
// sprite->Play("WalkNW");
|
||||
}
|
||||
if (transform->velocity.x > 0)
|
||||
{
|
||||
// }
|
||||
// if (transform->velocity.x > 0)
|
||||
// {
|
||||
// sprite->Play("WalkNW");
|
||||
// sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
|
||||
}
|
||||
// }
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
transform->velocity.y = 1;
|
||||
// transform->velocity.y = 1;
|
||||
// sprite->Play("WalkSouth");
|
||||
if (transform->velocity.x < 0)
|
||||
{
|
||||
// if (transform->velocity.x < 0)
|
||||
// {
|
||||
// sprite->Play("WalkSW");
|
||||
}
|
||||
if (transform->velocity.x > 0)
|
||||
{
|
||||
// }
|
||||
// if (transform->velocity.x > 0)
|
||||
// {
|
||||
// sprite->Play("WalkSW");
|
||||
// sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
|
||||
}
|
||||
// }
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
transform->velocity.x = -1;
|
||||
// sprite->Play("Walk");
|
||||
sprite->Play("Walk");
|
||||
sprite->spriteFlip = SDL_FLIP_NONE;
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
transform->velocity.x = 1;
|
||||
// sprite->Play("Walk");
|
||||
sprite->Play("Walk");
|
||||
sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
|
||||
break;
|
||||
case SDLK_k:
|
||||
@ -77,6 +77,9 @@ public:
|
||||
{
|
||||
Mix_PlayChannel(-1, Game::assets->GetSoundClip("bwoop"),0);
|
||||
}
|
||||
Game::gravityOnPlayer = true;
|
||||
sprite->Play("Jump");
|
||||
transform->velocity.y = -1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -99,11 +102,11 @@ public:
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
transform->velocity.x = 0;
|
||||
// sprite->Play("idle");
|
||||
sprite->Play("Idle");
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
transform->velocity.x = 0;
|
||||
// sprite->Play("idle");
|
||||
sprite->Play("Idle");
|
||||
break;
|
||||
case SDLK_k:
|
||||
if (Game::debugCollisionBoxes)
|
||||
@ -111,6 +114,11 @@ public:
|
||||
else
|
||||
{Game::debugCollisionBoxes = true; }
|
||||
break;
|
||||
case SDLK_j:
|
||||
transform->velocity.y = 0;
|
||||
sprite->Play("Fall");
|
||||
Game::gravityOnPlayer = true;
|
||||
break;
|
||||
case SDLK_ESCAPE: // exit the game when Escape pressed
|
||||
Game::isRunning = false;
|
||||
break;
|
||||
|
@ -106,10 +106,16 @@ public:
|
||||
// printf("No animations\n");
|
||||
// }
|
||||
// Play("idle");
|
||||
}
|
||||
Animation Idle = Animation(0,2,100);
|
||||
animations.emplace("Idle", Idle);
|
||||
Animation idle = Animation(0,3,100);
|
||||
animations.emplace("Idle", idle);
|
||||
Animation walk = Animation(1,3,100);
|
||||
animations.emplace("Walk", walk);
|
||||
Animation jump = Animation(2,1,100);
|
||||
animations.emplace("Jump", jump);
|
||||
Animation fall = Animation(2,2,100);
|
||||
animations.emplace("Fall",fall);
|
||||
Play("Idle");
|
||||
}
|
||||
setTex(id);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user