udpated SDL_GetTicks() to SDL_GetTicks64()

This commit is contained in:
2022-05-30 14:02:21 -04:00
parent 4aa7fe1692
commit 70402c5382
6 changed files with 53 additions and 23 deletions

View File

@ -14,6 +14,7 @@
#include "PlayerController.h"
#include "../assetmgr/AssetManager.h"
#include "ColliderComponent.h"
#include <cmath>
// #include "../game/Vector2D.h"
class KeyboardController : public Component
@ -79,19 +80,25 @@ public:
// printf("lastSafePos .x: %g .y: %g \n",transform->lastSafePos.x,transform->lastSafePos.y);
// Game::pTileX
// if(transform->position.x>0){
// ====== For Each Row ====
// for (int r=Game::pTileY-1;r<=Game::pTileY+1;r++){
// ====== For Each Tile (Column) =====
// for (int c=Game::pTileX;c>Game::pTileX-Game::camera.w;c--){
//
//
// }
// }
transform->velocity.x = -1;
// if(Game::playerIsGrounded){
int *borders;
borders = Game::predictCollisions();
int max = borders[0];
for (int b=0;b<3;b++){
if (borders[b]>max){
max = borders[b];
}
}
int desiredMovement = std::abs(-1*transform->speed*transform->scale);
int difference = transform->velocity.x-max*transform->scale;
// if(difference>desiredMovement){
transform->velocity.x = -1;
sprite->Play("Walk");
// }
sprite->spriteFlip = SDL_FLIP_NONE;
sprite->spriteFlip = SDL_FLIP_NONE;
// }else{
// // transform->velocity.x = -difference/desiredMovement;
// sprite->Play("Walk");
// sprite->spriteFlip = SDL_FLIP_NONE;
// }
}
break;

View File

@ -24,7 +24,7 @@ public:
int height = 40;
int width = 30;
int scale = 1;
int speed = 2;
int speed = 1;
TransformComponent()
{
@ -54,6 +54,16 @@ public:
speed = speed*sc;
}
TransformComponent(int x, int y, int w, int h, int sc, int spd)
{
position.x = x;
position.y = y;
width = w;
height = h;
scale = sc;
speed = spd*sc;
}
void init() override
{
velocity.Zero();