Commit 05d83730 authored by Valentin Bartschies's avatar Valentin Bartschies
Browse files

Adding canon texture

parent b745e8d1
......@@ -14,22 +14,21 @@ const int LASER_CANON_SPEED = 2;
Projectile *playerProj;
Aliens* aliens;
Texture2D ALIEN_UP, ALIEN_DOWN, ALIEN_SHOOT;
Texture2D ALIEN_UP, ALIEN_DOWN, ALIEN_SHOOT, CANON_TEXTURE;
Rectangle laserCanon;
Rectangle gameBorder;
Vector2 laserCanonPos;
int laserCanonSize;
void initGame() {
aliens = spawnAliens();
ALIEN_UP = LoadTexture("img/alien_up.png");
ALIEN_DOWN = LoadTexture("img/alien_down.png");
ALIEN_SHOOT = LoadTexture("img/alien_shoot.png");
CANON_TEXTURE = LoadTexture("img/canon.png");
laserCanonSize = GAME_SCREEN_WIDTH / 20;
laserCanonPos = (Vector2) {(float) GAME_SCREEN_WIDTH / 2, (float) GAME_SCREEN_HEIGHT - (laserCanonSize * 2)};
laserCanon = (Rectangle) {(float) laserCanonPos.x, (float) laserCanonPos.y, (float) laserCanonSize, (float) laserCanonSize};
laserCanonPos = (Vector2) {(float) GAME_SCREEN_WIDTH / 2, (float) GAME_SCREEN_HEIGHT - (CANON_TEXTURE.width * 2)};
laserCanon = (Rectangle) {(float) laserCanonPos.x, (float) laserCanonPos.y, CANON_TEXTURE.width, CANON_TEXTURE.height};
gameBorder = (Rectangle) {0.0, 0.0, (float) GAME_SCREEN_WIDTH, (float) GAME_SCREEN_HEIGHT};
}
......@@ -39,7 +38,7 @@ void calcGame() {
laserCanonPos.x -= LASER_CANON_SPEED;
}
} else if (IsKeyDown(KEY_RIGHT)) {
if (laserCanonPos.x < (GAME_SCREEN_WIDTH - 1) - laserCanonSize) {
if (laserCanonPos.x < (GAME_SCREEN_WIDTH - 1) - CANON_TEXTURE.width) {
laserCanonPos.x += LASER_CANON_SPEED;
}
}
......@@ -57,7 +56,7 @@ void calcGame() {
}
void drawGame() {
DrawRectangleRec(laserCanon, WHITE);
DrawTexture(CANON_TEXTURE, (int) laserCanonPos.x, (int) laserCanonPos.y, WHITE);
DrawRectangleLines((int) gameBorder.x, (int) gameBorder.y, (int) gameBorder.width, (int) gameBorder.height, WHITE);
if (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