#include <SFML/Graphics.
hpp>
#include <time.h>
using namespace sf;
const int W=600;
const int H=480;
int speed = 4;
bool field[W][H]={0};
struct player
{ int x,y,dir;
Color color;
player(Color c)
{
x=rand() % W;
y=rand() % H;
color=c;
dir=rand() % 4;
}
void tick()
{
if (dir==0) y+=1;
if (dir==1) x-=1;
if (dir==2) x+=1;
if (dir==3) y-=1;
if (x>=W) x=0; if (x<0) x=W-1;
if (y>=H) y=0; if (y<0) y=H-1;
}
Vector3f getColor()
{return Vector3f(color.r,color.g,color.b);}
};
int main()
{
srand(time(0));
RenderWindow window(VideoMode(W, H), "The Tron Game!");
[Link](60);
Texture texture;
[Link]("[Link]");
Sprite sBackground(texture);
player p1(Color::Red), p2(Color::Green);
Sprite sprite;
RenderTexture t;
[Link](W, H);
[Link](true);
[Link]([Link]());
[Link](); [Link](sBackground);
bool Game=1;
while ([Link]())
{
Event e;
while ([Link](e))
{
if ([Link] == Event::Closed)
[Link]();
}
if (Keyboard::isKeyPressed(Keyboard::Left)) if ([Link]!=2) [Link]=1;
if (Keyboard::isKeyPressed(Keyboard::Right)) if ([Link]!=1) [Link]=2;
if (Keyboard::isKeyPressed(Keyboard::Up)) if ([Link]!=0) [Link]=3;
if (Keyboard::isKeyPressed(Keyboard::Down)) if ([Link]!=3) [Link]=0;
if (Keyboard::isKeyPressed(Keyboard::A)) if ([Link]!=2) [Link]=1;
if (Keyboard::isKeyPressed(Keyboard::D)) if ([Link]!=1) [Link]=2;
if (Keyboard::isKeyPressed(Keyboard::W)) if ([Link]!=0) [Link]=3;
if (Keyboard::isKeyPressed(Keyboard::S)) if ([Link]!=3) [Link]=0;
if (!Game) continue;
for(int i=0;i<speed;i++)
{
[Link](); [Link]();
if (field[p1.x][p1.y]==1) Game=0;
if (field[p2.x][p2.y]==1) Game=0;
field[p1.x][p1.y]=1;
field[p2.x][p2.y]=1;
CircleShape c(3);
[Link](p1.x,p1.y); [Link]([Link]); [Link](c);
[Link](p2.x,p2.y); [Link]([Link]); [Link](c);
[Link]();
}
////// draw ///////
[Link]();
[Link](sprite);
[Link]();
}
return 0;
}