Better collisions and entity handling
This commit is contained in:
parent
61730209be
commit
84b87d1a67
15
block.cpp
15
block.cpp
|
@ -1,6 +1,6 @@
|
||||||
#include"block.h"
|
#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
|
//set the rectangle dimensions
|
||||||
rect = {x,y,w,h};
|
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;
|
posu = player;
|
||||||
type = 1;
|
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){
|
void Block::print(int cameraX){
|
||||||
//New SDL_Rect to make the objects follow the camera
|
//New SDL_Rect to make the objects follow the camera
|
||||||
SDL_Rect cameraFix = rect;
|
SDL_Rect cameraFix = rect;
|
||||||
|
@ -21,4 +32,4 @@ void Block::print(int cameraX){
|
||||||
SDL_RenderFillRect(*renderer,&cameraFix);
|
SDL_RenderFillRect(*renderer,&cameraFix);
|
||||||
|
|
||||||
posu->check(rect,type);
|
posu->check(rect,type);
|
||||||
};
|
};*/
|
||||||
|
|
Loading…
Reference in New Issue