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){
|
2017-06-17 16:02:03 +00:00
|
|
|
renderer = render; //Set the renderer
|
|
|
|
player = ply; //Set the player class to check
|
2017-04-30 16:23:47 +00:00
|
|
|
|
2017-06-17 16:02:03 +00:00
|
|
|
type = 1; //Set the entity type (1 = block)
|
2017-07-27 17:57:08 +00:00
|
|
|
|
|
|
|
rect = {x,y,w,h};
|
2017-06-17 16:02:03 +00:00
|
|
|
};
|
2017-05-05 14:19:44 +00:00
|
|
|
|
2017-07-27 17:57:08 +00:00
|
|
|
/*void Block::printAndCheck(int dimensions[], int cameraX){
|
2017-06-17 16:02:03 +00:00
|
|
|
//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
|
|
|
|
2017-06-17 16:02:03 +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);
|
2017-06-17 16:02:03 +00:00
|
|
|
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;
|
2017-06-17 16:02:03 +00:00
|
|
|
};
|