Fixed up collision boxes allowing custom colliders
This commit is contained in:
@ -137,7 +137,7 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
// player.addComponent<TransformComponent>(150*globalScale,80*globalScale,40,40,globalScale);
|
||||
player.addComponent<SpriteComponent>("player", SpriteComponent::spriteAnimation, "assets/textures/actors/firefighter.json");
|
||||
player.addComponent<KeyboardController>();
|
||||
player.addComponent<ColliderComponent>("player");
|
||||
player.addComponent<ColliderComponent>("player",8*globalScale,8*globalScale, true, 7*globalScale,36*globalScale);
|
||||
player.addGroup(groupPlayers);
|
||||
|
||||
puppy.addComponent<TransformComponent>(1024*globalScale,210*globalScale,36,30,globalScale);
|
||||
@ -188,13 +188,13 @@ void Game::update()
|
||||
if (Mix_PlayingMusic() == 0)
|
||||
{
|
||||
// std::cout << "Play Music Now" << std::endl;
|
||||
Mix_PlayMusic(assets->GetMusicTrack("simonZ"), -1);
|
||||
// Mix_PlayMusic(assets->GetMusicTrack("simonZ"), -1);
|
||||
}
|
||||
|
||||
if (Mix_PlayChannel(-1, Game::assets->GetSoundClip("bark1"),0) == 0)
|
||||
{
|
||||
Mix_PlayChannel(-1, Game::assets->GetSoundClip("bark1"),0);
|
||||
}
|
||||
// if (Mix_PlayChannel(-1, Game::assets->GetSoundClip("bark1"),0) == 0)
|
||||
// {
|
||||
// Mix_PlayChannel(-1, Game::assets->GetSoundClip("bark1"),0);
|
||||
// }
|
||||
|
||||
manager.refresh();
|
||||
manager.update();
|
||||
@ -210,8 +210,6 @@ void Game::update()
|
||||
}
|
||||
gravityOnPlayer = false;
|
||||
playerIsGrounded = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -242,7 +240,6 @@ void Game::update()
|
||||
camera.y = map->height-camera.h;
|
||||
}
|
||||
|
||||
|
||||
void Game::render()
|
||||
{
|
||||
SDL_RenderClear(renderer);
|
||||
@ -288,6 +285,20 @@ void Game::render()
|
||||
// destPt.x = 320.0*gScale;
|
||||
// destPt.y = 240.0*gScale;
|
||||
// drawLine(origPt,destPt,255,0,0);
|
||||
// Vector2D pt1, pt2, pt3, pt4;
|
||||
// pt1.x = 80.0*gScale;
|
||||
// pt1.y = 80.0*gScale;
|
||||
// pt2.x = 120.0*gScale;
|
||||
// pt2.y = 80.0*gScale;
|
||||
// pt3.x = 80.0*gScale;
|
||||
// pt3.y = 120.0*gScale;
|
||||
// pt4.x = 120.0*gScale;
|
||||
// pt4.y = 120.0*gScale;
|
||||
// Draw box with colors
|
||||
// drawLine(pt1,pt2,0,0,255);
|
||||
// drawLine(pt1,pt3,0,255,0);
|
||||
// drawLine(pt2,pt4,255,255,0);
|
||||
// drawLine(pt3,pt4,255,0,0);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
@ -307,8 +318,8 @@ void Game::printDebug(char* debugInfo)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
// void Game::drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blue)
|
||||
// {
|
||||
// SDL_SetRenderDrawColor(renderer, red, green, blue, 255);
|
||||
// SDL_RenderDrawLine(renderer, srcpt.x, srcpt.y, destpt.x, destpt.y);
|
||||
// }
|
||||
void Game::drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blue)
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, red, green, blue, 255);
|
||||
SDL_RenderDrawLine(renderer, srcpt.x, srcpt.y, destpt.x, destpt.y);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
void render();
|
||||
void clean();
|
||||
void printDebug(char* debugInfo);
|
||||
// void drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blue);
|
||||
static void drawLine(Vector2D srcpt, Vector2D destpt, int red, int green, int blue);
|
||||
bool running() { return isRunning; }
|
||||
// static void AddTile(int srcX, int srcY, int xpos, int ypos);
|
||||
static SDL_Renderer *renderer;
|
||||
|
Reference in New Issue
Block a user