Commit 113a090c authored by Valentin Bartschies's avatar Valentin Bartschies
Browse files

Removing unnecessary Alien pos Vector

parent 19093a68
......@@ -3,8 +3,8 @@
#include <stdlib.h>
#include <stdbool.h>
#define ALIEN_OFFSET 5
const int ALIEN_OFFSET = 5;
const int ALIEN_SIZE = 30;
extern const int GAME_SCREEN_WIDTH, LASER_CANON_SPEED, FRAME_RATE;
extern int FRAMES_COUNT;
......@@ -41,8 +41,6 @@ void drawAliens(Aliens *aliens) {
if (aliens->instances[j]) {
for (int i = 0; i < ALIEN_ROWS; ++i) {
Alien *alien = aliens->instances[j][i];
alien->pos.x = aliens->pos.x + j * (ALIEN_SIZE + ALIEN_OFFSET);
alien->pos.y = aliens->pos.y + i * (ALIEN_SIZE + ALIEN_OFFSET);
if (alien) {
Texture2D *texture = NULL;
if (alien->shooting) {
......@@ -52,7 +50,7 @@ void drawAliens(Aliens *aliens) {
texture = up ? &ALIEN_UP : &ALIEN_DOWN;
}
if (alien->alive) {
DrawTexture(*texture, alien->pos.x, alien->pos.y, WHITE);
DrawTexture(*texture, aliens->pos.x + j * (ALIEN_SIZE + ALIEN_OFFSET), aliens->pos.y + i * (ALIEN_SIZE + ALIEN_OFFSET), WHITE);
}
}
}
......
......@@ -11,7 +11,6 @@
typedef struct {
bool shooting;
Vector2 pos;
bool alive;
} Alien;
......
......@@ -8,7 +8,7 @@
#include <stdlib.h>
#include <stdbool.h>
extern const int GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT, FRAME_RATE, ALIEN_SIZE;
extern const int GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT, FRAME_RATE, ALIEN_SIZE, ALIEN_OFFSET;
const int LASER_CANON_SPEED = 2;
extern int sec;
......@@ -109,7 +109,7 @@ void alienCollisionDetection() {
for (int i = 0; i < ALIEN_ROWS; i++) {
for (int j = 0; j < ALIEN_COLS; j++) {
if (aliens->instances[j][i]->alive) {
if (CheckCollisionPointRec(playerProj->pos, (Rectangle) {aliens->instances[j][i]->pos.x, aliens->instances[j][i]->pos.y, ALIEN_SIZE, ALIEN_SIZE})) {
if (CheckCollisionPointRec(playerProj->pos, (Rectangle) {aliens->pos.x + j * (ALIEN_SIZE + ALIEN_OFFSET), aliens->pos.y + i * (ALIEN_SIZE + ALIEN_OFFSET), ALIEN_SIZE, ALIEN_SIZE})) {
aliens->instances[j][i]->alive = false;
playerProj->pos.y = 0;
}
......
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