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"
|
||||
|
||||
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);
|
||||
};
|
||||
};*/
|
||||
|
|
Loading…
Reference in New Issue