forked from akademikbilisim/ab2015-python-oyun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_ornek.py
43 lines (30 loc) · 929 Bytes
/
class_ornek.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
# -*- coding: utf-8 -*-
import sfml as sf
WIDTH = 640
HEIGHT = 480
TITLE = "Python SFML Class Example"
class Game:
def __init__(self):
self.window = sf.RenderWindow(
sf.VideoMode(WIDTH, HEIGHT), TITLE)
self.circle = sf.CircleShape(50)
self.circle.origin = self.circle.radius, self.circle.radius
def run(self):
while self.window.is_open:
for event in self.window.events:
self.handle_events(event)
self.update()
self.render()
def handle_events(self, event):
if type(event) is sf.CloseEvent:
self.window.close()
def render(self):
self.window.clear()
self.window.draw(self.circle)
self.window.display()
def update(self):
self.circle.position = \
sf.Mouse.get_position(self.window)
if __name__ == "__main__":
oyun = Game()
oyun.run()