-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmovegenerator.cpp
More file actions
44 lines (42 loc) · 861 Bytes
/
Copy pathmovegenerator.cpp
File metadata and controls
44 lines (42 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "movegenerator.h"
#include<iostream>
ARRAY<Cordinate> SnakeMoveGenerator::getNextMove(ARRAY<Cordinate> cord, int size, MovementDirection dir)
{
for (int i = 0; i < size; i++)
std::cout << "(" << cord[i].X << ", " << cord[i].Y << ") ";
std::cout << std::endl;
// //increment snake body
for (int i = size; i > 0; --i)
{
cord[i].X = cord[i - 1].X;
cord[i].Y = cord[i - 1].Y;
}
switch (dir)
{
case enDown: {
cord[0].Y += 1;
break;
}
case enLeft: {
cord[0].X -= 1;
break;
}
case enRight: {
cord[0].X += 1;
break;
}
case enUp: {
cord[0].Y -= 1;
break;
}
default:
break;
}
return cord;
}
ARRAY<Cordinate> FruitMoveGenerator::getNextMove(ARRAY<Cordinate> cord, int size, MovementDirection dir)
{
cord[0].X = rand() % ROWS;
cord[0].Y = rand() % COLUMBS;
return cord;
}