-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathExample07.cpp
More file actions
80 lines (80 loc) · 1.75 KB
/
Example07.cpp
File metadata and controls
80 lines (80 loc) · 1.75 KB
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
//#include<iostream>
//#include"SFML\Graphics.hpp"
//#include"SFML\Window.hpp"
//#include"SFML\System.hpp"
//
//using namespace sf;
//
//int main()
//{
// RenderWindow window(VideoMode(640, 480), "Simple game");
// window.setFramerateLimit(60);
//
// CircleShape hoop;
// int dir = 0;
// hoop.setRadius(50.f);
// hoop.setFillColor(Color::Black);
// hoop.setOutlineThickness(2.f);
// hoop.setOutlineColor(Color::Blue);
// hoop.setPosition(Vector2f(0, 10.f));
//
// CircleShape ball;
// bool isShot = false;
// ball.setRadius(20.f);
// ball.setFillColor(Color::Red);
// ball.setPosition(Vector2f(0, window.getSize().y - ball.getRadius()*3));
//
// while (window.isOpen())
// {
// sf::Event event;
// while (window.pollEvent(event))
// {
// if (event.type == sf::Event::Closed)
// window.close();
// if (event.type == Event::KeyPressed && event.key.code == Keyboard::Escape)
// window.close();
// }
//
// //Update hoop
// if (hoop.getPosition().x <= 0)
// dir = 1;
// else if (hoop.getPosition().x + hoop.getRadius()*2 >= window.getSize().x)
// dir = 0;
//
// if (dir == 0)
// {
// hoop.move(-5.f, 0);
// }
// else
// {
// hoop.move(5.f, 0);
// }
//
// //Update ball
// if (Mouse::isButtonPressed(Mouse::Left))
// isShot = true;
//
// if(!isShot)
// ball.setPosition(Mouse::getPosition(window).x, ball.getPosition().y);
// else
// ball.move(0, -5.f);
//
// //Collision ball
// if (ball.getPosition().y <= 0 || ball.getGlobalBounds().intersects(hoop.getGlobalBounds()))
// {
// //Reset ball
// isShot = false;
// ball.setPosition(ball.getPosition().x, window.getSize().y - ball.getRadius() * 3);
// }
//
// //DRAW
// window.clear(Color::White);
//
// window.draw(hoop);
// window.draw(ball);
//
// window.display();
// }
//
// return 0;
//}