Skip to content

Commit f02411b

Browse files
committed
refactoring files
1 parent 296cd7f commit f02411b

File tree

4 files changed

+47
-40
lines changed

4 files changed

+47
-40
lines changed

Diff for: game.py

-2
This file was deleted.

Diff for: launch.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/python
2+
3+
from src import Game
4+
5+
Game().run()

Diff for: src/__init__.py

+1-38
Original file line numberDiff line numberDiff line change
@@ -1,38 +1 @@
1-
#!/usr/bin/python
2-
3-
import time
4-
import pygame
5-
6-
from world import World
7-
from gui import Gameview
8-
from player import Player
9-
from images import ImageCache
10-
11-
seed = 26281376
12-
13-
pygame.init()
14-
screenSize = (1024, 600)
15-
surface = pygame.display.set_mode(screenSize)
16-
pygame.display.set_caption("RPG Game")
17-
18-
world = World(seed)
19-
user = Player(world)
20-
view = Gameview(world, user, surface, ImageCache())
21-
22-
clock = pygame.time.Clock()
23-
24-
while(True):
25-
26-
clock.tick(20)
27-
view.draw()
28-
29-
if not world.update():
30-
continue
31-
32-
if(user.turn()):
33-
continue
34-
35-
world.turn()
36-
user.save()
37-
38-
1+
from game import Game

Diff for: src/game.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import time
2+
import pygame
3+
4+
from world import World
5+
from gui import Gameview
6+
from player import Player
7+
from images import ImageCache
8+
9+
class Game(object):
10+
11+
def __init__(self):
12+
13+
pygame.init()
14+
self.screenSize = (1024, 600)
15+
pygame.display.set_caption("RPG Game")
16+
17+
self.seed = 26281376
18+
self.surface = pygame.display.set_mode(self.screenSize)
19+
20+
self.world = World(self.seed)
21+
self.user = Player(self.world)
22+
self.view = Gameview(self.world, self.user, self.surface, ImageCache())
23+
24+
self.clock = pygame.time.Clock()
25+
26+
def run(self):
27+
28+
while(True):
29+
30+
self.view.draw()
31+
32+
if not self.world.update():
33+
continue
34+
35+
if self.user.turn():
36+
continue
37+
38+
self.world.turn()
39+
self.user.save()
40+
41+
self.clock.tick(30)

0 commit comments

Comments
 (0)