-
Notifications
You must be signed in to change notification settings - Fork 0
/
Screen.gd
65 lines (53 loc) · 1.34 KB
/
Screen.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 Sprite
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var ticking = false
var interval = -1
var startTicking = 0
var elapsed = 0
var numbers = [0,0,0]
var failed = false
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
if ticking:
elapsed = getElapsed()
if elapsed >= 100:
var number = floor(elapsed/100)
if number == 4:
reset()
else:
numbers[0] = number
$"Big Number".animation = str(number)
if elapsed >= 10:
var number = floor(elapsed/10-numbers[0]*10)
numbers[1] = number
$Tenth.animation = str(number)
var number = floor(elapsed-numbers[0]*100-numbers[1]*10)
numbers[2] = number
$Units.animation = str(number)
func getElapsed():
return (OS.get_ticks_msec() - startTicking) /interval
func reset():
numbers = [0,0,0]
$"Big Number".animation = "0"
$Tenth.animation = "0"
$Units.animation = "0"
ticking = false
func _on_Game_throw(step):
if visible:
numbers = [0,0,0]
$"Big Number".animation = "0"
$Tenth.animation = "0"
$Units.animation = "0"
ticking = true
interval = step*6/300
startTicking = OS.get_ticks_msec()
func _on_Game_catch(success):
if success:
ticking = false
else:
failed = true