ColliderComponent hidden prop
This commit is contained in:
@ -26,15 +26,14 @@ public:
|
||||
|
||||
int offsetX = 0;
|
||||
int offsetY = 0;
|
||||
|
||||
bool hidden = true;
|
||||
|
||||
TransformComponent* transform;
|
||||
|
||||
ColliderComponent(std::string t)
|
||||
{
|
||||
tag = t;
|
||||
// collider.x = 10;
|
||||
// collider.y = 52;
|
||||
// collider.w = collider.h = 12;
|
||||
}
|
||||
|
||||
ColliderComponent(std::string t, int xpos, int ypos, int size, int scale)
|
||||
@ -66,17 +65,6 @@ public:
|
||||
tex = TextureManager::LoadTexture("assets/ColTex.png");
|
||||
srcR = { 0, 0, 16, 16};
|
||||
destR = { collider.x, collider.y, collider.w, collider.h };
|
||||
// if(tag == "player"){
|
||||
// destR = { 18, 28, 24, 24 };
|
||||
// collider.w = 16;
|
||||
// collider.h = 16;
|
||||
// transform->height = 24;
|
||||
// transform->width = 24;
|
||||
// std::cout << "player collider init() ran" << std::endl;
|
||||
// std::cout << "destR.w: " << destR.w << std::endl;
|
||||
// std::cout << "destR.h: " << destR.h << std::endl;
|
||||
// }
|
||||
// Game::colliders.push_back(this);
|
||||
}
|
||||
|
||||
void update() override
|
||||
@ -85,10 +73,6 @@ public:
|
||||
{
|
||||
collider.x = static_cast<int>(transform->position.x+offsetX);
|
||||
collider.y = static_cast<int>(transform->position.y+offsetY);
|
||||
// collider.w = transform->width * transform->scale;
|
||||
// collider.h = transform->height * transform->scale;
|
||||
// collider.w = 12 * transform->scale;
|
||||
// collider.h = 12 * transform->scale;
|
||||
}
|
||||
destR.x = collider.x - Game::camera.x;
|
||||
destR.y = collider.y - Game::camera.y;
|
||||
@ -96,12 +80,15 @@ public:
|
||||
|
||||
void draw() override
|
||||
{
|
||||
if(tag == "terrain")
|
||||
{
|
||||
TextureManager::Draw(tex, srcR, destR, SDL_FLIP_NONE);
|
||||
// TextureManager::DrawCollider(destR);
|
||||
// if(tag == "terrain")
|
||||
// {
|
||||
// TextureManager::Draw(tex, srcR, destR, SDL_FLIP_NONE);
|
||||
// }
|
||||
if(hidden == false)
|
||||
{
|
||||
TextureManager::Draw(tex, srcR,destR,SDL_FLIP_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
@ -17,7 +17,4 @@
|
||||
#include "TileComponent.h"
|
||||
#include "UIFontComponent.h"
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* SRC_COMPONENTS_H_ */
|
||||
|
@ -90,16 +90,6 @@ public:
|
||||
{
|
||||
switch (Game::event.key.keysym.sym)
|
||||
{
|
||||
case SDLK_UP:
|
||||
// transform->velocity.y = 0;
|
||||
// sprite->Play("idle");
|
||||
// sprite->spriteFlip = SDL_FLIP_NONE;
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
// transform->velocity.y = 0;
|
||||
// sprite->Play("idle");
|
||||
// sprite->spriteFlip = SDL_FLIP_NONE;
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
|
||||
transform->velocity.x = 0;
|
||||
|
@ -24,7 +24,6 @@ public:
|
||||
{
|
||||
transform = &entity->getComponent<TransformComponent>();
|
||||
transform->velocity = velocity;
|
||||
// std::cout << transform->position << std::endl;
|
||||
}
|
||||
|
||||
void update() override
|
||||
|
@ -69,14 +69,10 @@ public:
|
||||
{
|
||||
spriteType = sType;
|
||||
if(sType == spriteAnimation)
|
||||
{
|
||||
// std::string bogusPath = "src/config/credits.json";
|
||||
// std::ifstream fin(bogusPath);
|
||||
|
||||
{
|
||||
std::ifstream fin(json);
|
||||
|
||||
if(fin.is_open()){
|
||||
// std::cout<<"file is open"<<std::endl;
|
||||
} else {
|
||||
std::cout<<"json file is NOT open"<<std::endl;
|
||||
}
|
||||
@ -84,7 +80,6 @@ public:
|
||||
if(fin.fail()){
|
||||
std::cout<<"json file open fail"<<std::endl;
|
||||
} else{
|
||||
// std::cout<<"json file open success"<<std::endl;
|
||||
}
|
||||
|
||||
std::ifstream jsonText(json);
|
||||
@ -94,35 +89,20 @@ public:
|
||||
cJSON * animJson = cJSON_Parse(aJson.c_str());
|
||||
cJSON * meta = cJSON_GetObjectItem(animJson, "meta");
|
||||
cJSON * frameTags = cJSON_GetObjectItem(meta,"frameTags");
|
||||
// printf("frameTags:\n%s\n",cJSON_Print(frameTags));
|
||||
int tagsCount = cJSON_GetArraySize(frameTags);
|
||||
// printf("number of tags: \n%d\n",tagsCount);
|
||||
// cJSON * arrItem = cJSON_GetArrayItem(frameTags,0);
|
||||
// cJSON * animItem = cJSON_GetArrayItem(frameTags, 0);
|
||||
// printf("Animation item: \n%s\n",cJSON_Print(animItem));
|
||||
// printf("arrItem: \n%s\n",cJSON_Print(arrItem));
|
||||
|
||||
for (int t = 0; t < tagsCount; t++)
|
||||
{
|
||||
// printf("Tag: \n%d\n",t);
|
||||
// printf("tag number: \n%d\n",t);
|
||||
cJSON * animItem = cJSON_GetArrayItem(frameTags,t);
|
||||
// printf("Animation item: \n%s\n",cJSON_Print(animItem));
|
||||
cJSON * nameJson = cJSON_GetObjectItem(animItem, "name");
|
||||
const char * name = cJSON_Print(nameJson);
|
||||
int fromFrame = cJSON_GetObjectItem(animItem, "from")->valueint;
|
||||
int toFrame = cJSON_GetObjectItem(animItem, "to")->valueint;
|
||||
Animation anim = Animation(fromFrame,toFrame,100);
|
||||
animations.emplace(name, anim);
|
||||
// printf("Adding animation named: %s fromFrame:%d toFrame:%d \n",name,fromFrame,toFrame);
|
||||
Play(name);
|
||||
}
|
||||
|
||||
// if(!animations.empty()){
|
||||
// printf("animations found!\n");
|
||||
// }else{
|
||||
// printf("No animations\n");
|
||||
// }
|
||||
// Play("idle");
|
||||
Animation idle = Animation(0,3,100);
|
||||
animations.emplace("Idle", idle);
|
||||
Animation walk = Animation(1,3,100);
|
||||
@ -140,7 +120,6 @@ public:
|
||||
{
|
||||
spriteType = sType;
|
||||
setTex(id);
|
||||
// text = isText;
|
||||
letter = fontLetter;
|
||||
letterWidth = letterW;
|
||||
letterHeight = letterH;
|
||||
|
@ -35,8 +35,6 @@ public:
|
||||
SDL_Rect srcRect, destRect;
|
||||
Vector2D position;
|
||||
|
||||
// UIFontComponent() = default;
|
||||
|
||||
UIFontComponent(std::string id, int letterW, int letterH, int xpos, int ypos, int scale)
|
||||
{
|
||||
texture = Game::assets->GetTexture(id);
|
||||
|
Reference in New Issue
Block a user