platform-test/src/entity/block.cpp

40 lines
1.1 KiB
C++
Raw Normal View History

2017-04-29 18:43:17 +00:00
#include"block.h"
2017-07-27 17:57:08 +00:00
Block::Block(int x,int y,int w,int h,SDL_Renderer* render, Player* ply){
renderer = render; //Set the renderer
player = ply; //Set the player class to check
type = 1; //Set the entity type (1 = block)
2017-07-27 17:57:08 +00:00
rect = {x,y,w,h};
}
2017-07-27 17:57:08 +00:00
/*void Block::printAndCheck(int dimensions[], int cameraX){
//Set the block's rect's dimensions and position
rect = {dimensions[0],dimensions[1],dimensions[2],dimensions[3]}
2017-05-21 07:20:14 +00:00
//Check if it collides with the player
player->check(rect,type);
//Adjust de SDL_Rect x to follow the camera
rect.x = dimensions[0] - cameraX;
2017-05-21 07:20:14 +00:00
//Set render color and render the rectangle
2017-07-26 03:01:29 +00:00
SDL_SetRenderDrawColor(renderer,169,145,73,0xFF);
SDL_RenderFillRect(renderer,&rect);
}*/
2017-07-27 17:57:08 +00:00
void Block::printAndCheck(int cameraX){
//Check if it collides with the player
player->check(rect,type);
//Adjust de SDL_Rect x to follow the camera
rect.x -= cameraX;
//Set render color and render the rectangle
/*SDL_SetRenderDrawColor(renderer,0,0xFF,0,0xFF);
SDL_RenderDrawRect(renderer,&rect);*/
rect.x += cameraX;
}