CHORE: Removed redundant for loop
This commit is contained in:
+2
-10
@@ -30,15 +30,7 @@ engine_init(Engine* engine)
|
||||
engine->dir = RIGHT;
|
||||
engine->m_score = 0;
|
||||
engine->tail_size = 0;
|
||||
memset(engine->view, 0, sizeof(engine->view));
|
||||
|
||||
for (unsigned char i = 0; i < ROW; i++)
|
||||
{
|
||||
for (unsigned char j = 0; j < COL; j++)
|
||||
{
|
||||
engine->view[i][j] = '.';
|
||||
}
|
||||
}
|
||||
memset(engine->view, '.', sizeof(engine->view));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -80,7 +72,7 @@ process_input(Direction* dir)
|
||||
unsigned char ch;
|
||||
if (read(1, &ch, 1) > 0)
|
||||
{
|
||||
if (ch == 'q') return false;
|
||||
if (ch == 'q') return 0;
|
||||
if (ch == 'w')
|
||||
if (*dir != DOWN) *dir = UP;
|
||||
if (ch == 's')
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
@@ -24,8 +24,8 @@ main()
|
||||
|
||||
while (is_open(status, 64, &engine) && process_input(&engine.dir))
|
||||
{
|
||||
|
||||
if(equals(&engine.fruit, &engine.head)) {
|
||||
if (equals(&engine.fruit, &engine.head))
|
||||
{
|
||||
eat(&engine);
|
||||
}
|
||||
move(&engine);
|
||||
|
||||
Reference in New Issue
Block a user