Initial reorganization of shmup prroject; temp player sprites added.
This commit is contained in:
parent
02d14e913c
commit
accc463791
116 changed files with 298 additions and 177 deletions
36
scenes/score_counter.gd
Normal file
36
scenes/score_counter.gd
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
extends HBoxContainer
|
||||
|
||||
var last_score: String = "00000000"
|
||||
|
||||
var digit_coords = {
|
||||
1: Vector2(0, 0),
|
||||
2: Vector2(8, 0),
|
||||
3: Vector2(16, 0),
|
||||
4: Vector2(24, 0),
|
||||
5: Vector2(32, 0),
|
||||
6: Vector2(0, 8),
|
||||
7: Vector2(8, 8),
|
||||
8: Vector2(16, 8),
|
||||
9: Vector2(24, 8),
|
||||
0: Vector2(32, 8)
|
||||
}
|
||||
|
||||
func display_digits(n):
|
||||
|
||||
var s = "%08d" % n
|
||||
var start = 8 - str(n).length() # Finds the starting position of the counter by converting the score to a string, minus the leading zeros.
|
||||
var changed = false
|
||||
|
||||
for i in 8:
|
||||
get_child(i).texture.region = Rect2(digit_coords[int(s[i])], Vector2(8, 8))
|
||||
if i >= start and s[i] != last_score[i]:
|
||||
changed = true
|
||||
if changed:
|
||||
for i in 8:
|
||||
if i >= start:
|
||||
var tween = create_tween()
|
||||
tween.tween_property(get_child(i), "scale", Vector2(2,2), .15).set_trans(Tween.TRANS_BOUNCE)
|
||||
# tween.tween_property(get_child(i), "position:y", +5, .15).set_ease(tween.TRANS_QUART)
|
||||
tween.tween_property(get_child(i), "scale", Vector2(1,1), .15).set_trans(Tween.TRANS_BOUNCE)
|
||||
# tween.tween_property(get_child(i), "position:y", -5, .15).set_ease(tween.TRANS_QUART)
|
||||
last_score = s
|
||||
Loading…
Add table
Add a link
Reference in a new issue