forked from nakidai/csnake
1
0
Fork 0

Some fixes

- Fix UB in playerCreate (it had no return)
- Now Screen has field of Points, not chars
master
Nakidai 2023-10-30 02:36:03 +03:00
parent b402dc177c
commit 758dbf9cc2
Signed by untrusted user who does not match committer: nakidai
GPG Key ID: 914675D395210A97
3 changed files with 5 additions and 3 deletions

View File

@ -1,13 +1,13 @@
#ifndef __SCREEN_H__ #ifndef __SCREEN_H__
#define __SCREEN_H__ #define __SCREEN_H__
typedef char Point;
typedef struct screen_t typedef struct screen_t
{ {
int width; int width;
int height; int height;
char *screen; Point *screen;
} Screen; } Screen;
typedef char Point;
Screen *screenCreate(int width, int height, Point fill_value); Screen *screenCreate(int width, int height, Point fill_value);
void screenFree(Screen *screen); void screenFree(Screen *screen);

View File

@ -15,6 +15,8 @@ Player *playerCreate(Direction direction, int x, int y, int score)
player->head = head; player->head = head;
player->score = score; player->score = score;
player->direction = direction; player->direction = direction;
return player;
} }
void playerFree(Player *player) void playerFree(Player *player)

View File

@ -44,7 +44,7 @@ void screenShow(Screen *screen)
} }
} }
void screenSet(Screen *screen, char fill_value) void screenSet(Screen *screen, Point fill_value)
{ {
memset(screen->screen, fill_value, screen->width * screen->height * sizeof(char)); memset(screen->screen, fill_value, screen->width * screen->height * sizeof(char));
} }