Better collisions and entity handling

This commit is contained in:
Pòsweg 2017-05-21 09:20:14 +02:00
parent 61730209be
commit 84b87d1a67
1 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#include"block.h"
Block::Block(int x, int y, int w, int h,SDL_Renderer** render, Player* player){
Block::Block(int x, int y, int w, int h,SDL_Renderer** render, Player* player, int cameraX){
//set the rectangle dimensions
rect = {x,y,w,h};
@ -9,8 +9,19 @@ Block::Block(int x, int y, int w, int h,SDL_Renderer** render, Player* player){
posu = player;
type = 1;
//New SDL_Rect to make the objects follow the camera
SDL_Rect cameraFix = rect;
cameraFix.x -= cameraX;
//Set render color and render the rectangle
SDL_SetRenderDrawColor(*renderer,0,0xFF,0,0xFF);
SDL_RenderFillRect(*renderer,&cameraFix);
posu->check(rect,type);
}
/*
void Block::print(int cameraX){
//New SDL_Rect to make the objects follow the camera
SDL_Rect cameraFix = rect;
@ -21,4 +32,4 @@ void Block::print(int cameraX){
SDL_RenderFillRect(*renderer,&cameraFix);
posu->check(rect,type);
};
};*/