-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameData.adept
95 lines (85 loc) · 2.63 KB
/
GameData.adept
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import 'main.adept'
enum Background (GRASS, ABYSS, ABYSS_GREY)
enum SceneKind (OVERWORLD, BATTLE)
struct GameData (
scene_id int,
scene_kind SceneKind,
background Background,
player Player,
houses <House> List,
enemy Pet,
friendly_pet_label Label,
enemy_pet_label Label,
select int,
select_lock bool,
move_labels 4 Label,
reset_time double,
selected_a_move bool,
return_from_battle int,
return_from_room int,
inventory Inventory,
inventory_lock bool,
save_dialog SaveDialog
) {
func init {
this.scene_id = 0
this.background = Background::GRASS
this.player.init()
this.gotoScene(1)
//this.enemy
this.friendly_pet_label.clear()
repeat 4, this.move_labels[idx].clear()
this.select = 0
this.select_lock = true
this.reset_time = glfwGetTime()
this.selected_a_move = false
this.return_from_battle = 0
this.return_from_room = 0
this.inventory.init()
this.inventory.addPet(pet(textures.tadpole))
this.inventory_lock = true
this.save_dialog.init()
}
func gotoScene(id int){
this.houses.clear()
switch id {
case 0
this.return_from_battle = this.scene_id
this.scene_kind = SceneKind::BATTLE
this.background = Background::ABYSS_GREY
this.select = 0
this.select_lock = true
this.enemy = randomPet()
case 1
this.scene_kind = SceneKind::OVERWORLD
this.background = Background::GRASS
this.inventory_lock = true
//this.houses.add(384.0f, 160.0f)
//this.houses.add(160.0f, 224.0f)
//this.houses.add(384.0f, 352.0f)
randomHouses()
case 2
this.scene_kind = SceneKind::OVERWORLD
this.background = Background::GRASS
this.inventory_lock = true
//this.houses.add(160.0f, 352.0f)
//this.houses.add(384.0f, 224.0f)
randomHouses()
}
this.scene_id = id
}
}
func randomHouses {
repeat randomInt(1, 10) {
valid successful = false
x, y float = undef
until valid {
valid = true
x = 32.0f + 32.0f * randomInt(18) as float
y = 32.0f + 32.0f * randomInt(13) as float
each House in gamedata.houses, if it.x == x && it.y == y, valid = false; break
valid = valid && distance(x, y, gamedata.player.x, gamedata.player.y) > 32.0f
}
gamedata.houses.add(x, y)
}
}