Firefighter better animations added
This commit is contained in:
parent
697ab6f8fc
commit
3481c20e4f
BIN
assets/textures/actors/firefighter-idle.gif
Normal file
BIN
assets/textures/actors/firefighter-idle.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
assets/textures/actors/firefighter-walk.gif
Normal file
BIN
assets/textures/actors/firefighter-walk.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
Binary file not shown.
@ -28,7 +28,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "3",
|
"filename": "3",
|
||||||
"frame": { "x": 66, "y": 0, "w": 22, "h": 42 },
|
"frame": { "x": 0, "y": 42, "w": 22, "h": 42 },
|
||||||
"rotated": false,
|
"rotated": false,
|
||||||
"trimmed": false,
|
"trimmed": false,
|
||||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
||||||
@ -37,7 +37,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "4",
|
"filename": "4",
|
||||||
"frame": { "x": 88, "y": 0, "w": 22, "h": 42 },
|
"frame": { "x": 22, "y": 42, "w": 22, "h": 42 },
|
||||||
"rotated": false,
|
"rotated": false,
|
||||||
"trimmed": false,
|
"trimmed": false,
|
||||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
||||||
@ -46,7 +46,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "5",
|
"filename": "5",
|
||||||
"frame": { "x": 110, "y": 0, "w": 22, "h": 42 },
|
"frame": { "x": 44, "y": 42, "w": 22, "h": 42 },
|
||||||
"rotated": false,
|
"rotated": false,
|
||||||
"trimmed": false,
|
"trimmed": false,
|
||||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
||||||
@ -55,7 +55,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "6",
|
"filename": "6",
|
||||||
"frame": { "x": 132, "y": 0, "w": 22, "h": 42 },
|
"frame": { "x": 0, "y": 84, "w": 22, "h": 42 },
|
||||||
"rotated": false,
|
"rotated": false,
|
||||||
"trimmed": false,
|
"trimmed": false,
|
||||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
||||||
@ -64,7 +64,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "7",
|
"filename": "7",
|
||||||
"frame": { "x": 154, "y": 0, "w": 22, "h": 42 },
|
"frame": { "x": 22, "y": 84, "w": 22, "h": 42 },
|
||||||
"rotated": false,
|
"rotated": false,
|
||||||
"trimmed": false,
|
"trimmed": false,
|
||||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
||||||
@ -73,7 +73,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filename": "8",
|
"filename": "8",
|
||||||
"frame": { "x": 176, "y": 0, "w": 22, "h": 42 },
|
"frame": { "x": 44, "y": 84, "w": 22, "h": 42 },
|
||||||
"rotated": false,
|
"rotated": false,
|
||||||
"trimmed": false,
|
"trimmed": false,
|
||||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
"spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 42 },
|
||||||
@ -86,11 +86,13 @@
|
|||||||
"version": "1.2.25-x64",
|
"version": "1.2.25-x64",
|
||||||
"image": "firefighter.png",
|
"image": "firefighter.png",
|
||||||
"format": "RGBA8888",
|
"format": "RGBA8888",
|
||||||
"size": { "w": 198, "h": 42 },
|
"size": { "w": 66, "h": 126 },
|
||||||
"scale": "1",
|
"scale": "1",
|
||||||
"frameTags": [
|
"frameTags": [
|
||||||
{ "name": "idle", "from": 0, "to": 2, "direction": "forward" },
|
{ "name": "idle", "from": 0, "to": 2, "direction": "forward" },
|
||||||
{ "name": "walk", "from": 3, "to": 8, "direction": "forward" }
|
{ "name": "walk", "from": 3, "to": 5, "direction": "forward" },
|
||||||
|
{ "name": "jump", "from": 6, "to": 6, "direction": "forward" },
|
||||||
|
{ "name": "fall", "from": 7, "to": 7, "direction": "forward" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
@ -11,6 +11,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "SDL2/SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
#include "Components.h"
|
#include "Components.h"
|
||||||
|
#include "ECS.h"
|
||||||
#include "../assetmgr/TextureManager.h"
|
#include "../assetmgr/TextureManager.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -72,19 +73,19 @@ public:
|
|||||||
|
|
||||||
void update() override
|
void update() override
|
||||||
{
|
{
|
||||||
// if(tag != "terrain")
|
if(tag != "terrain")
|
||||||
// {
|
{
|
||||||
// collider.x = static_cast<int>(transform->position.x)+9;
|
collider.x = static_cast<int>(transform->position.x);
|
||||||
// collider.y = static_cast<int>(transform->position.y)+28;
|
collider.y = static_cast<int>(transform->position.y);
|
||||||
//// collider.w = transform->width * transform->scale;
|
collider.w = transform->width * transform->scale;
|
||||||
//// collider.h = transform->height * transform->scale;
|
collider.h = transform->height * transform->scale;
|
||||||
// collider.w = 12 * transform->scale;
|
// collider.w = 12 * transform->scale;
|
||||||
// collider.h = 12 * transform->scale;
|
// collider.h = 12 * transform->scale;
|
||||||
//
|
//
|
||||||
//// std::cout << "collider.w: " << collider.w << std::endl;
|
// std::cout << "collider.w: " << collider.w << std::endl;
|
||||||
//// std::cout << "collider.h: " << collider.h << std::endl;
|
// std::cout << "collider.h: " << collider.h << std::endl;
|
||||||
//// std::cout << "tag: " << tag << std::endl;
|
// std::cout << "tag: " << tag << std::endl;
|
||||||
// }
|
}
|
||||||
destR.x = collider.x - Game::camera.x;
|
destR.x = collider.x - Game::camera.x;
|
||||||
destR.y = collider.y - Game::camera.y;
|
destR.y = collider.y - Game::camera.y;
|
||||||
// std::cout << "tag: " << tag << std::endl;
|
// std::cout << "tag: " << tag << std::endl;
|
||||||
|
@ -34,39 +34,39 @@ public:
|
|||||||
switch (Game::event.key.keysym.sym)
|
switch (Game::event.key.keysym.sym)
|
||||||
{
|
{
|
||||||
case SDLK_UP:
|
case SDLK_UP:
|
||||||
transform->velocity.y = -1;
|
// transform->velocity.y = -1;
|
||||||
// sprite->Play("WalkNorth");
|
// sprite->Play("WalkNorth");
|
||||||
if (transform->velocity.x < 0)
|
// if (transform->velocity.x < 0)
|
||||||
{
|
// {
|
||||||
// sprite->Play("WalkNW");
|
// sprite->Play("WalkNW");
|
||||||
}
|
// }
|
||||||
if (transform->velocity.x > 0)
|
// if (transform->velocity.x > 0)
|
||||||
{
|
// {
|
||||||
// sprite->Play("WalkNW");
|
// sprite->Play("WalkNW");
|
||||||
// sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
|
// sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
|
||||||
}
|
// }
|
||||||
break;
|
break;
|
||||||
case SDLK_DOWN:
|
case SDLK_DOWN:
|
||||||
transform->velocity.y = 1;
|
// transform->velocity.y = 1;
|
||||||
// sprite->Play("WalkSouth");
|
// sprite->Play("WalkSouth");
|
||||||
if (transform->velocity.x < 0)
|
// if (transform->velocity.x < 0)
|
||||||
{
|
// {
|
||||||
// sprite->Play("WalkSW");
|
// sprite->Play("WalkSW");
|
||||||
}
|
// }
|
||||||
if (transform->velocity.x > 0)
|
// if (transform->velocity.x > 0)
|
||||||
{
|
// {
|
||||||
// sprite->Play("WalkSW");
|
// sprite->Play("WalkSW");
|
||||||
// sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
|
// sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
|
||||||
}
|
// }
|
||||||
break;
|
break;
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
transform->velocity.x = -1;
|
transform->velocity.x = -1;
|
||||||
// sprite->Play("Walk");
|
sprite->Play("Walk");
|
||||||
sprite->spriteFlip = SDL_FLIP_NONE;
|
sprite->spriteFlip = SDL_FLIP_NONE;
|
||||||
break;
|
break;
|
||||||
case SDLK_RIGHT:
|
case SDLK_RIGHT:
|
||||||
transform->velocity.x = 1;
|
transform->velocity.x = 1;
|
||||||
// sprite->Play("Walk");
|
sprite->Play("Walk");
|
||||||
sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
|
sprite->spriteFlip = SDL_FLIP_HORIZONTAL;
|
||||||
break;
|
break;
|
||||||
case SDLK_k:
|
case SDLK_k:
|
||||||
@ -77,6 +77,9 @@ public:
|
|||||||
{
|
{
|
||||||
Mix_PlayChannel(-1, Game::assets->GetSoundClip("bwoop"),0);
|
Mix_PlayChannel(-1, Game::assets->GetSoundClip("bwoop"),0);
|
||||||
}
|
}
|
||||||
|
Game::gravityOnPlayer = true;
|
||||||
|
sprite->Play("Jump");
|
||||||
|
transform->velocity.y = -1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -99,11 +102,11 @@ public:
|
|||||||
break;
|
break;
|
||||||
case SDLK_LEFT:
|
case SDLK_LEFT:
|
||||||
transform->velocity.x = 0;
|
transform->velocity.x = 0;
|
||||||
// sprite->Play("idle");
|
sprite->Play("Idle");
|
||||||
break;
|
break;
|
||||||
case SDLK_RIGHT:
|
case SDLK_RIGHT:
|
||||||
transform->velocity.x = 0;
|
transform->velocity.x = 0;
|
||||||
// sprite->Play("idle");
|
sprite->Play("Idle");
|
||||||
break;
|
break;
|
||||||
case SDLK_k:
|
case SDLK_k:
|
||||||
if (Game::debugCollisionBoxes)
|
if (Game::debugCollisionBoxes)
|
||||||
@ -111,6 +114,11 @@ public:
|
|||||||
else
|
else
|
||||||
{Game::debugCollisionBoxes = true; }
|
{Game::debugCollisionBoxes = true; }
|
||||||
break;
|
break;
|
||||||
|
case SDLK_j:
|
||||||
|
transform->velocity.y = 0;
|
||||||
|
sprite->Play("Fall");
|
||||||
|
Game::gravityOnPlayer = true;
|
||||||
|
break;
|
||||||
case SDLK_ESCAPE: // exit the game when Escape pressed
|
case SDLK_ESCAPE: // exit the game when Escape pressed
|
||||||
Game::isRunning = false;
|
Game::isRunning = false;
|
||||||
break;
|
break;
|
||||||
|
@ -106,10 +106,16 @@ public:
|
|||||||
// printf("No animations\n");
|
// printf("No animations\n");
|
||||||
// }
|
// }
|
||||||
// Play("idle");
|
// Play("idle");
|
||||||
}
|
Animation idle = Animation(0,3,100);
|
||||||
Animation Idle = Animation(0,2,100);
|
animations.emplace("Idle", idle);
|
||||||
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");
|
Play("Idle");
|
||||||
|
}
|
||||||
setTex(id);
|
setTex(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +47,8 @@ auto& uiInfo(manager.addEntity());
|
|||||||
|
|
||||||
bool Game::debugCollisionBoxes = false;
|
bool Game::debugCollisionBoxes = false;
|
||||||
|
|
||||||
|
bool Game::gravityOnPlayer = true;
|
||||||
|
|
||||||
int gScale = 0;
|
int gScale = 0;
|
||||||
|
|
||||||
Game::Game() {
|
Game::Game() {
|
||||||
@ -108,7 +110,7 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
|||||||
SDL_Rect myDestRect = SDL_Rect();
|
SDL_Rect myDestRect = SDL_Rect();
|
||||||
myDestRect.x = 12;
|
myDestRect.x = 12;
|
||||||
myDestRect.y = 8;
|
myDestRect.y = 8;
|
||||||
myDestRect.w = 140;
|
myDestRect.w = 120;
|
||||||
myDestRect.h = 40;
|
myDestRect.h = 40;
|
||||||
my9Slice = new UINineSlice("textBox");
|
my9Slice = new UINineSlice("textBox");
|
||||||
my9Slice->MakeSlices("textBox",32,32,14,17,14,17,myDestRect,globalScale);
|
my9Slice->MakeSlices("textBox",32,32,14,17,14,17,myDestRect,globalScale);
|
||||||
@ -179,10 +181,21 @@ void Game::update()
|
|||||||
SDL_Rect cCol = c->getComponent<ColliderComponent>().collider;
|
SDL_Rect cCol = c->getComponent<ColliderComponent>().collider;
|
||||||
if(Collision::AABB(cCol, playerCol))
|
if(Collision::AABB(cCol, playerCol))
|
||||||
{
|
{
|
||||||
player.getComponent<TransformComponent>().position = playerPos;
|
// printf("Collision detected!\n");
|
||||||
|
// player.getComponent<TransformComponent>().position = playerPos;
|
||||||
|
gravityOnPlayer = false;
|
||||||
|
// player.getComponent<SpriteComponent>().Play("Idle");
|
||||||
}
|
}
|
||||||
|
// while(Collision::AABB(cCol, playerCol))
|
||||||
|
// {
|
||||||
|
// gravityOnPlayer = false;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gravity
|
||||||
|
if (gravityOnPlayer){
|
||||||
|
player.getComponent<TransformComponent>().position.y += 5;
|
||||||
|
}
|
||||||
// for(auto& p: projectiles)
|
// for(auto& p: projectiles)
|
||||||
// {
|
// {
|
||||||
// if(Collision::AABB(player.getComponent<ColliderComponent>().collider, p->getComponent<ColliderComponent>().collider))
|
// if(Collision::AABB(player.getComponent<ColliderComponent>().collider, p->getComponent<ColliderComponent>().collider))
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
// static std::vector<ColliderComponent*> colliders;
|
// static std::vector<ColliderComponent*> colliders;
|
||||||
static bool isRunning;
|
static bool isRunning;
|
||||||
static bool debugCollisionBoxes;
|
static bool debugCollisionBoxes;
|
||||||
|
static bool gravityOnPlayer;
|
||||||
static SDL_Rect camera;
|
static SDL_Rect camera;
|
||||||
static AssetManager* assets;
|
static AssetManager* assets;
|
||||||
enum groupLabels : std::size_t
|
enum groupLabels : std::size_t
|
||||||
|
Loading…
Reference in New Issue
Block a user