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
|
#include "stdafx.h"
#include "SFML/Graphics.hpp"
int _tmain(int argc, _TCHAR* argv[])
{
sf::VideoMode VTMode(600, 400, 32);
sf::VideoMode VBMode(800, 300, 32);
sf::RenderWindow BotWin(VBMode, "This is the bottom window.");
sf::RenderWindow TopWin(VTMode, "This is the top window.");
sf::Shape Ball=sf::Shape::Circle (0,0,25,sf::Color(0,0,200));
int x, y;
x=255; y=100;
int z=150;
while (TopWin.IsOpened()||BotWin.IsOpened())
{
sf::Event A;
if (TopWin.GetEvent(A))
{
if (A.Type==sf::Event::Closed)TopWin.Close();
if (A.Type==sf::Event::MouseEntered) {x=255;y=100;}
if (A.Type==sf::Event::MouseLeft) {x=0;y=255;}
}
if (BotWin.GetEvent(A))
if (A.Type==sf::Event::Closed) BotWin.Close();
if (BotWin.IsOpened())
{
BotWin.Display();
BotWin.Clear(sf::Color(255, 0, 255));
}
if (TopWin.IsOpened())
{
TopWin.Display();
TopWin.Clear(sf::Color(x, y, 0));
Ball.SetPosition(z,150);
TopWin.Draw(Ball);
z++;
sf::Sleep(0.03f);
}
}
return 0;
}
|