Switch direction of MorseState state array
Originally it was easier for the MorseBanner to have the states with newest in front, but this makes the code harder to read and complicates things in other places. At some point it also might make sense to not use a range() in MorseBanner, but use a int var + counter instead, as we often might only consume a small number of elements. But as this is game programming, "winging it" and getting something done seems to be the modus operandi.
This commit is contained in:
parent
ca3b8dba62
commit
ec7b46ebc9
|
@ -16,5 +16,5 @@ func set_state(state: bool) -> void:
|
|||
curr_state = state
|
||||
|
||||
var now := Time.get_ticks_msec()
|
||||
states.push_front(now - last_change)
|
||||
states.push_back(now - last_change)
|
||||
last_change = now
|
||||
|
|
|
@ -27,7 +27,8 @@ func _draw():
|
|||
else:
|
||||
px_per_s = size.x / (Time.get_ticks_msec() - MorseState.start_time) * 1000.0
|
||||
|
||||
for duration in [first_time] + MorseState.states:
|
||||
for n in [-1] + range(MorseState.states.size() - 1, -1, -1):
|
||||
var duration := first_time if n == -1 else MorseState.states[n]
|
||||
var rect_width: float = min(duration / 1000.0 * px_per_s, curr_x)
|
||||
curr_x -= rect_width
|
||||
if morse_on:
|
||||
|
|
Loading…
Reference in New Issue