-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenario.py
80 lines (66 loc) · 1.9 KB
/
scenario.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
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
import pygame
import core
from level import Level
from menu import Menu
import anim
import data
class Scenario:
level = 0
levels = []
menuOn = False
menu = None
quit = False
def __init__(self):
menu = Menu()
menu.set(0, anim.Slot(data.images['menu_newgame']), \
anim.Slot(data.images['menu_newgame_act']), self.newGame)
menu.set(1, anim.Slot(data.images['menu_random']), \
anim.Slot(data.images['menu_random_act']), self.randomLevel1)
menu.set(2, anim.Slot(data.images['menu_random']), \
anim.Slot(data.images['menu_random_act']), self.randomLevel2)
menu.set(4, anim.Slot(data.images['menu_quit']), \
anim.Slot(data.images['menu_quit_act']), self.end )
self.menu = menu
self.levels.append((0, 0, Level(0)))
self.levels.append((1, 1, Level(1)))
self.levels.append((2, 2, Level(2)))
self.initLevel()
#enddef
def newGame(self):
self.level = 1
self.initLevel()
self.menuOn = False
#enddef
def randomLevel(self):
self.levels[self.level][2].generate()
self.menuOn = False
#enddef
def randomLevel1(self):
self.level = 1
self.randomLevel()
#enddef
def randomLevel2(self):
self.level = 2
self.randomLevel()
#enddef
def end(self):
self.quit = True
#enddef
def initLevel(self):
self.levels[self.level][2].load()
#enddef
def draw(self):
self.levels[self.level][2].draw()
if self.menuOn:
self.menu.draw()
#enddef
def behave(self):
if self.menuOn:
self.menu.behave()
else:
self.levels[self.level][2].behave()
if core.controls.exit:
self.menuOn = not self.menuOn
core.controls.exit = False
#enddef
#endclass