-
Notifications
You must be signed in to change notification settings - Fork 1
/
world.gd
61 lines (47 loc) · 1.25 KB
/
world.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
extends Node3D
@onready var tunnel = $tunnel
@onready var ship = $head/ship
@onready var splash = $splash_screen
@onready var anykey = $splash_screen/continue_text
@onready var pbar = $splash_screen/pbar
var http_request = HTTPRequest.new()
var T = 0
func _ready():
ship.is_started = true
splash.show()
tunnel.translate(Vector3(0, 0, 0))
ship.connect("bullet_hit", tunnel.bullet_hit)
add_child(http_request)
send_stat("start")
func send_stat(action, body = {}):
var user_id = OS.get_unique_id()
body.id = user_id
body.action = action
var bodyStr = JSON.new().stringify(body)
func _process(delta):
tunnel.translate(Vector3(0, 0, delta * ship.velocity))
tunnel.startube.set_instance_shader_parameter("ship_speed", max(0.3, ship.velocity))
T += delta
if T < 3:
pbar.size.x = 1000*T/3
anykey.hide()
return
else:
pbar.hide()
if fmod(T*2, 2) > 1:
anykey.show()
else:
anykey.hide()
func restart():
tunnel.transform.origin = Vector3(0,0,0)
tunnel.restart()
ship.restart()
func _input(event):
if T > 3.:
if splash.visible:
splash.hide()
restart()
if event is InputEventKey:
if event.keycode == 83 && event.pressed == false:
var img = get_viewport().get_texture().get_image()
img.save_png("UI/save%s.png" % [randi_range(10,1000)])