-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathshapes.py
45 lines (33 loc) · 1.11 KB
/
shapes.py
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
# -*- coding: utf-8 -*-
import sfml as sf
WIDTH = 640
HEIGHT = 480
TITLE = "Python SFML Shapes"
window = sf.RenderWindow(sf.VideoMode(WIDTH, HEIGHT), TITLE)
circle = sf.CircleShape(50)
circle.origin = circle.radius, circle.radius
alpha = 255
circle.fill_color = sf.Color(123, 43, 25, alpha)
rectangle = sf.RectangleShape((100, 100))
rectangle.fill_color = sf.Color.BLUE
rectangle.origin = rectangle.size.x / 2, rectangle.size.y / 2
rectangle.position = 200, 200
while window.is_open:
for event in window.events:
if type(event) is sf.CloseEvent:
window.close()
if type(event) is sf.MouseWheelEvent:
alpha += event.delta
if not 0 <= alpha <= 255:
print "Bozuk!"
alpha = 0
circle.fill_color = sf.Color(123, 43, 25, alpha)
circle.position = sf.Mouse.get_position(window)
if sf.Keyboard.is_key_pressed(sf.Keyboard.LEFT):
rectangle.rotate(-5)
if sf.Keyboard.is_key_pressed(sf.Keyboard.RIGHT):
rectangle.rotate(5)
window.clear()
window.draw(circle)
window.draw(rectangle)
window.display()