Commit 22d2f058 authored by Max Kobelt's avatar Max Kobelt
Browse files

Add smooth laser canon movement

parent b0b2af53
......@@ -7,6 +7,8 @@
#include <stdlib.h>
#include <stdbool.h>
#define LASER_CANON_SPEED 2
extern const int GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT, FRAME_RATE;
Projectile *playerProj;
......@@ -27,15 +29,15 @@ void calcGame() {
int key = GetKeyPressed();
// Control the laserCanon with left- and rightarrow
if (IsKeyPressed(KEY_LEFT)) {
if (laserCanonPos.x > 0) {
laserCanonPos.x -= laserCanonSize;
}
} else if (IsKeyPressed(KEY_RIGHT)) {
if (laserCanonPos.x < GAME_SCREEN_WIDTH - laserCanonSize) {
laserCanonPos.x += laserCanonSize;
}
if (IsKeyDown(KEY_LEFT)) {
if (laserCanonPos.x > 0) {
laserCanonPos.x -= LASER_CANON_SPEED;
}
} else if (IsKeyDown(KEY_RIGHT)) {
if (laserCanonPos.x < (GAME_SCREEN_WIDTH - 1) - laserCanonSize) {
laserCanonPos.x += LASER_CANON_SPEED;
}
}
if (playerProj) {
playerProj = projectileTick(playerProj);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment