Commit 19093a68 authored by Özgür Balataci's avatar Özgür Balataci
Browse files

Downward move

Alien downwards movement per frame
parent 5c37bc3a
......@@ -3,7 +3,6 @@
#include "projectile.h"
#include "raylib.h"
#include <stdbool.h>
#define ALIEN_ROWS 3
......@@ -20,6 +19,7 @@ typedef struct {
Alien ***instances;
Projectile *projectiles[ALIEN_MAX_PROJECTILES];
Vector2 pos;
Vector2 speed;
bool movingRight;
int velocity;
int *lastShots;
......
......@@ -10,6 +10,7 @@
extern const int GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT, FRAME_RATE, ALIEN_SIZE;
const int LASER_CANON_SPEED = 2;
extern int sec;
int playerLives;
......@@ -58,13 +59,13 @@ void calcGame() {
for (int i = 0; i < 3; i++)
{
if (playerCollisionDetection(aliens->projectiles[i]))
{
{
free(aliens->projectiles[i]);
aliens->projectiles[i] = NULL;
}
}
}
if (IsKeyPressed(KEY_K)) { // Placeholder, deleting Aliens one by one with "K"
for (int i = ALIEN_ROWS - 1; i >= 0; i--) {
for (int j = 0; j < ALIEN_COLS; j++) {
......@@ -78,8 +79,10 @@ void calcGame() {
laserCanon.x = laserCanonPos.x;
laserCanon.y = laserCanonPos.y;
aliensTick(aliens);
if(sec % 5 == 0){
alienDownward();
}
}
void drawGame() {
......@@ -88,6 +91,7 @@ void drawGame() {
drawProjectile(playerProj);
drawAliens(aliens);
}
void destructGame() {
......@@ -134,3 +138,9 @@ bool allAliensDead() {
}
return true;
}
/*void gameupdate(){
}*/
void alienDownward(void){
aliens->pos.y += 1;
}
......@@ -10,6 +10,7 @@
const int GAME_SCREEN_WIDTH = 400, GAME_SCREEN_HEIGHT = 400, FRAME_RATE = 60;
int FRAMES_COUNT = 0;
long int sec=0;
extern const int playerLives;
int startTime = 0, endTime = 0;
......@@ -87,6 +88,7 @@ int main() {
EndDrawing();
++FRAMES_COUNT;
sec++;
}
destructGame();
......
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