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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#include <string>
#include "Robots_Modified.h"
#include "MiniFW_Modified.h"
#include "strutils.h"
#include "randgen.h"
using namespace std;
int main ()
{
int a = 0;
string name;
EmptyAllTheCells(0, 0, 16, 16);
GetInput("Please enter the name of the snake" , name);
Robot r1(0, 0);
r1.SetColor(pink);
r1.SetName(name);
Robot r2(17, 2);
r2.SetColor(pink);
r2.SetVisibility (false);
Robot r3(17, 3);
r3.SetColor(pink);
Robot r4(17, 4);
r4.SetColor(pink);
Robot r5(17, 5);
r5.SetColor(pink);
Robot r6(17, 6);
r6.SetColor(pink);
RandGen rnd;
for (int i=0; i<5; i++)
{
PutThings(rnd.RandInt(0, 15), rnd.RandInt(0, 15), rnd.RandInt(0, 5));
}
while ( a<1)
{
if (IsPressed(keyRightArrow))
{
do
{r1.PickThings();
r1.Turn(east);
r1.Move();
}while( !(IsPressed(keyUpArrow) || IsPressed(keyDownArrow)));
}
if (IsPressed(keyLeftArrow))
{
do
{r1.Turn(west);
r1.Move();
r1.PickThings();
}while( !(IsPressed(keyUpArrow) || IsPressed(keyDownArrow)));
}
if (IsPressed(keyUpArrow))
{
do
{r1.Turn(north);
r1.Move();
r1.PickThings();
}while( !(IsPressed(keyLeftArrow) || IsPressed(keyRightArrow)));
}
if (IsPressed(keyDownArrow))
{
do
{r1.Turn(south);
r1.Move();
r1.PickThings();
}while( !(IsPressed(keyLeftArrow) || IsPressed(keyRightArrow)));
}
}
}
|