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