-
Notifications
You must be signed in to change notification settings - Fork 2
/
Splash.gd
66 lines (53 loc) · 1.82 KB
/
Splash.gd
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
extends Node2D
func _ready():
Global.load_settings()
randomize()
var n = 100
for i in range(n):
var building = create_building()
var angle = 2 * PI / n * i
var v = Vector2.RIGHT.rotated(angle)
building.position = v.normalized() * 540
building.rotation = v.angle() + PI / 2
$planet.add_child(building)
func create_building():
var scenes = {
Global.BuildingType.APARTMENT_BUILDING: preload('res://Apartment.tscn'),
Global.BuildingType.AD_AGENCY: preload('res://AdAgency.tscn'),
Global.BuildingType.FACTORY: preload('res://Factory.tscn'),
Global.BuildingType.MINE: preload('res://Mine.tscn'),
Global.BuildingType.POWERPLANT: preload('res://Powerplant.tscn'),
}
var building_types = [
Global.BuildingType.APARTMENT_BUILDING,
Global.BuildingType.AD_AGENCY,
Global.BuildingType.FACTORY,
Global.BuildingType.FACTORY,
Global.BuildingType.FACTORY,
Global.BuildingType.FACTORY,
Global.BuildingType.MINE,
Global.BuildingType.MINE,
Global.BuildingType.MINE,
Global.BuildingType.POWERPLANT,
Global.BuildingType.POWERPLANT,
Global.BuildingType.POWERPLANT,
Global.BuildingType.POWERPLANT,
]
var building_type = building_types[randi() % len(building_types)]
var building_scene = scenes[building_type]
var building = building_scene.instance()
building.decorative = true
return building
func _on_animation_speed_timer_timeout():
if $animation.playback_speed > 0.1:
$animation.playback_speed *= 0.93
func _input(event):
if event is InputEventKey or \
(event is InputEventMouseButton and event.button_index in [BUTTON_LEFT, BUTTON_RIGHT]):
next_screen()
func _on_animation_animation_finished(_anim_name):
yield(get_tree().create_timer(1.5), "timeout")
next_screen()
func next_screen():
if get_tree().change_scene("res://World.tscn") != OK:
print('change_scene failed. Run for your life!')