Compare commits
No commits in common. "40dc962d5ec28f0c3b42bc257e567375925f2ae4" and "d6eef4c404086c01118e27744d8e5766730dabde" have entirely different histories.
40dc962d5e
...
d6eef4c404
|
@ -1,3 +1,3 @@
|
|||
obj/
|
||||
game
|
||||
config/
|
||||
config.mk
|
||||
|
|
6
Makefile
6
Makefile
|
@ -1,9 +1,7 @@
|
|||
include config/config.mk
|
||||
|
||||
OUT = game
|
||||
CFLAGS =
|
||||
LDFLAGS =
|
||||
INCLUDE = -Iinclude -Iconfig
|
||||
INCLUDE = -Iinclude
|
||||
CC = cc
|
||||
LD = ld
|
||||
RM = rm -f
|
||||
|
@ -24,6 +22,6 @@ $(OUT): obj $(OBJ)
|
|||
$(CC) -o $@ $(OBJ) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
$(RM) $(OUT) $(OBJDIR)/*
|
||||
$(RM) $(OUT) config.mk $(OBJDIR)/*
|
||||
|
||||
.PHONY: default clean
|
||||
|
|
|
@ -5,28 +5,15 @@ RM=${RM:-rm -f}
|
|||
CFLAGS=${CFLAGS:-}
|
||||
LDFLAGS=${LDFLAGS:-}
|
||||
OUT=${OUT:-game}
|
||||
SIZE=${SIZE:-10}
|
||||
DEFX=${DEFX:-0}
|
||||
DEFY=${DEFY:-0}
|
||||
|
||||
echo "Makefile configuration:"
|
||||
echo "Compiler: $CC"
|
||||
echo "Remove: $RM"
|
||||
echo "CFLAGS: $CFLAGS"
|
||||
echo "LDFLAGS: $LDFLAGS"
|
||||
echo "Out file: $OUT"
|
||||
echo
|
||||
echo "Code configuration:"
|
||||
echo "Size: $SIZE"
|
||||
echo "Start x: $DEFX"
|
||||
echo "Start y: $DEFY"
|
||||
|
||||
echo "CC = $CC
|
||||
RM = $RM
|
||||
CFLAGS = $CFLAGS
|
||||
LDFLAGS = $LDFLAGS
|
||||
OUT = $OUT" > config/config.mk
|
||||
|
||||
echo "#define SIZE $SIZE
|
||||
#define DEFX $DEFX
|
||||
#define DEFY $DEFY" > config/config.h
|
||||
OUT = $OUT" > config.mk
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "screen.h"
|
||||
#include "player.h"
|
||||
#include "food.h"
|
||||
#include "config.h"
|
||||
|
||||
void drawPlayer(Player *player, Screen *screen)
|
||||
{
|
||||
|
@ -23,7 +22,7 @@ Food generateFood(Player *player)
|
|||
Food food;
|
||||
do
|
||||
{
|
||||
food = (Food){random() % SIZE, random() % SIZE};
|
||||
food = (Food){random() % 10, random() % 10};
|
||||
} while (playerCheckFoodCollision(player, food));
|
||||
return food;
|
||||
}
|
||||
|
@ -31,8 +30,8 @@ Food generateFood(Player *player)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
srandom(time(NULL));
|
||||
Player *player = playerCreate(DOWN, DEFX, DEFY, 0);
|
||||
Screen *screen = screenCreate(SIZE, SIZE, ' ');
|
||||
Player *player = playerCreate(DOWN, 0, 0, 0);
|
||||
Screen *screen = screenCreate(10, 10, ' ');
|
||||
PlayerNode *node;
|
||||
pthread_t input_thread;
|
||||
int head_x, head_y;
|
||||
|
@ -69,7 +68,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
head_x = player->head->x;
|
||||
head_y = player->head->y;
|
||||
if (head_x >= SIZE || head_x < 0 || head_y >= SIZE || head_y < 0)
|
||||
if (head_x >= 10 || head_x < 0 || head_y >= 10 || head_y < 0)
|
||||
{
|
||||
*running = false;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue