diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..75b1567 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp +*.o diff --git a/Makefile b/Makefile index 03c5c1c..6b770fb 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ COMPILER_FLAGS = -w LINKER_FLAGS = -lSDL2 -std=gnu++11 -OBJ_NAME = main.exe +OBJ_NAME = bin/main all: $(OBJS) diff --git a/bin/main b/bin/main new file mode 100755 index 0000000..a7aec38 Binary files /dev/null and b/bin/main differ diff --git a/block.cpp b/block.cpp index 573105a..39eacb6 100644 --- a/block.cpp +++ b/block.cpp @@ -6,8 +6,6 @@ void Block::print(int x, int y, int w, int h,SDL_Renderer* renderer){ szW = w; szH = h; - //std::cout< bX and aX < b2X){ - if(aY > bY and aY < b2Y) collision += 1; - if(a2Y > bY and a2Y < b2Y) collision += 2; - } - - if(a2X > bX and a2X < b2X){ - if(aY > bY and aY < b2Y) collision += 4; - if(a2Y > bY and a2Y < b2Y) collision += 8; - } - - //std::cout< speed) velocityX = speed; @@ -69,7 +71,7 @@ void Player::move(){ } else if(velocityX <= 1 or velocityX >= -1) velocityX = 0; - //Jump and gravity key logic + //Jump and gravity logic if(ground){ isRunning = false; if(currentKeyStates[SDL_SCANCODE_SPACE] and !topCollision){ @@ -83,6 +85,7 @@ void Player::move(){ if(isRunning == false) run = 1; } + //Get the position and update the velY with gravity velocityY -= gravity * dt; float x = velocityX * dt * run; float y = velocityY * dt; diff --git a/player.h b/player.h index 738a67a..8bfc399 100644 --- a/player.h +++ b/player.h @@ -13,7 +13,6 @@ class Entity; class Player: public Entity{ public: - //Player(/*int* collision*/); void print(); int check(SDL_Rect rectB); void init(int x, int y,int w, int h,SDL_Renderer** render); @@ -27,13 +26,10 @@ class Player: public Entity{ bool ground; bool topCollision; //int posX, posY; - //int cVelocity, oldVelX, oldVelY, newVelX, newVelY; float velocityX = 0; float velocityY = 0; bool isRunning = false; int oldPosX, oldPosY; - //int szW = 40; - //int szH = 40; }; #endif