Skip to content
Snippets Groups Projects
Commit 7356e686 authored by Lenny Siol's avatar Lenny Siol
Browse files

Update: Ship class, make ship unable to leave the screen

parent 54803b88
No related branches found
No related tags found
2 merge requests!19Finish polishing,!18Feature: Polish
......@@ -6,9 +6,8 @@
1614862706 source:/home/lenny/Desktop/Boxelware/Code/Space-Shooter_Game/src/main.cpp
"Menu/Menu.h"
1614863858 source:/home/lenny/Desktop/Boxelware/Code/Space-Shooter_Game/src/Entities/Ship/Ship.cpp
1614865659 source:/home/lenny/Desktop/Boxelware/Code/Space-Shooter_Game/src/Entities/Ship/Ship.cpp
"Ship.h"
"../../Rendering/TextureManager.h"
<iostream>
1614865224 /home/lenny/Desktop/Boxelware/Code/Space-Shooter_Game/src/Entities/Ship/Ship.h
......@@ -61,7 +60,7 @@
1614864800 /home/lenny/Desktop/Boxelware/Code/Space-Shooter_Game/src/Entities/Missile/Missile.h
"../Entity.h"
1614863377 source:/home/lenny/Desktop/Boxelware/Code/Space-Shooter_Game/src/Entities/Enemy/Enemy.cpp
1614865224 source:/home/lenny/Desktop/Boxelware/Code/Space-Shooter_Game/src/Entities/Enemy/Enemy.cpp
"Enemy.h"
1614865224 /home/lenny/Desktop/Boxelware/Code/Space-Shooter_Game/src/Entities/Enemy/Enemy.h
......
......@@ -27,20 +27,20 @@ void Ship::update()
void Ship::handleControls(const Uint8 *keyboard_state)
{
if(keyboard_state[SDL_SCANCODE_W] && !keyboard_state[SDL_SCANCODE_S])
if(keyboard_state[SDL_SCANCODE_W] && !keyboard_state[SDL_SCANCODE_S] && destionation.y > 0)
{
destionation.y -= speed;
}
else if(keyboard_state[SDL_SCANCODE_S] && !keyboard_state[SDL_SCANCODE_W])
else if(keyboard_state[SDL_SCANCODE_S] && !keyboard_state[SDL_SCANCODE_W] && destionation.y < game->getHeight()-32)
{
destionation.y += speed;
}
if(keyboard_state[SDL_SCANCODE_A] && !keyboard_state[SDL_SCANCODE_D])
if(keyboard_state[SDL_SCANCODE_A] && !keyboard_state[SDL_SCANCODE_D] && destionation.x > 0)
{
destionation.x -= speed;
}
else if(keyboard_state[SDL_SCANCODE_D] && !keyboard_state[SDL_SCANCODE_A])
else if(keyboard_state[SDL_SCANCODE_D] && !keyboard_state[SDL_SCANCODE_A] && destionation.x < game->getWidth()-32)
{
destionation.x += speed;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment