dial in sun movement
make it take as long as it takes the balls to move during rolltime basically
This commit is contained in:
parent
70f7ef747d
commit
e16482627a
3 changed files with 32 additions and 12 deletions
10
board.gd
10
board.gd
|
|
@ -1,6 +1,9 @@
|
||||||
class_name Board
|
class_name Board
|
||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
|
## squares per second
|
||||||
|
@export_range(0.0, 1, 0.01) var anim_time := 0.15
|
||||||
|
|
||||||
var dims: Vector2i
|
var dims: Vector2i
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
@ -75,7 +78,12 @@ func finish_tween():
|
||||||
# diagonal velocity
|
# diagonal velocity
|
||||||
# uhh that's it lol?
|
# uhh that's it lol?
|
||||||
# well, subphases: higher lvel magnitude moves first within a phase
|
# well, subphases: higher lvel magnitude moves first within a phase
|
||||||
# TODO: maybe show these phases with the sun
|
|
||||||
|
## returns the total time animation *will* take
|
||||||
|
func step_anim_time() -> float:
|
||||||
|
var pieces_moving := pieces().filter(func(piece): return piece.lvel != Vector2i.ZERO).size()
|
||||||
|
return pieces_moving * anim_time
|
||||||
|
|
||||||
func do_step():
|
func do_step():
|
||||||
var pieces_moving := pieces().filter(func(piece): return piece.lvel != Vector2i.ZERO)
|
var pieces_moving := pieces().filter(func(piece): return piece.lvel != Vector2i.ZERO)
|
||||||
var pieces_cardinal := pieces_moving.filter(func(piece): return piece.lvel.x == 0 or piece.lvel.y == 0)
|
var pieces_cardinal := pieces_moving.filter(func(piece): return piece.lvel.x == 0 or piece.lvel.y == 0)
|
||||||
|
|
|
||||||
25
main.gd
25
main.gd
|
|
@ -26,11 +26,8 @@ var levels: Array[PackedScene] = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# TODO: sun movement takes exactly as much time as all piece movement
|
# TODO: sun movement takes exactly as much time as all piece movement
|
||||||
var time := 0:
|
var time := 0
|
||||||
set(new_time):
|
|
||||||
var tween := get_tree().create_tween()
|
|
||||||
tween.tween_property($Sun, "rotation_degrees:y", -15*new_time, 0.1)
|
|
||||||
time = new_time
|
|
||||||
var advancing := false
|
var advancing := false
|
||||||
|
|
||||||
@onready var sound: AudioStreamPlayer = $Sound
|
@onready var sound: AudioStreamPlayer = $Sound
|
||||||
|
|
@ -118,11 +115,29 @@ func restart():
|
||||||
# scratch that i like that, don't clear the history
|
# scratch that i like that, don't clear the history
|
||||||
# you can like replay your steps up to a point
|
# you can like replay your steps up to a point
|
||||||
|
|
||||||
|
var last_sun_tween: Tween = null
|
||||||
# time advancing, basically
|
# time advancing, basically
|
||||||
func board_step():
|
func board_step():
|
||||||
|
var anim_time := maxf(board.step_anim_time(), board.anim_time)
|
||||||
hist.add_do_method(board.do_step)
|
hist.add_do_method(board.do_step)
|
||||||
hist.add_do_property(self, "time", time+1)
|
hist.add_do_property(self, "time", time+1)
|
||||||
|
hist.add_do_method(func():
|
||||||
|
if last_sun_tween:
|
||||||
|
last_sun_tween.custom_step(413)
|
||||||
|
last_sun_tween.kill()
|
||||||
|
var tween := get_tree().create_tween()
|
||||||
|
tween.tween_property($Sun, "rotation_degrees:y", -15*time, anim_time)
|
||||||
|
last_sun_tween = tween
|
||||||
|
)
|
||||||
hist.add_undo_property(self, "time", time)
|
hist.add_undo_property(self, "time", time)
|
||||||
|
hist.add_undo_method(func():
|
||||||
|
if last_sun_tween:
|
||||||
|
last_sun_tween.custom_step(413)
|
||||||
|
last_sun_tween.kill()
|
||||||
|
var tween := get_tree().create_tween()
|
||||||
|
tween.tween_property($Sun, "rotation_degrees:y", -15*time, 0.1)
|
||||||
|
last_sun_tween = tween
|
||||||
|
)
|
||||||
hist.add_undo_method(board.undo_step())
|
hist.add_undo_method(board.undo_step())
|
||||||
|
|
||||||
func step(move: Vector2i):
|
func step(move: Vector2i):
|
||||||
|
|
|
||||||
9
piece.gd
9
piece.gd
|
|
@ -16,9 +16,6 @@ enum Type {
|
||||||
PlayerBarrier,
|
PlayerBarrier,
|
||||||
}
|
}
|
||||||
|
|
||||||
## squares per second
|
|
||||||
@export_range(0.0, 1, 0.01) var anim_time := 0.1
|
|
||||||
|
|
||||||
func pos_of_lpos(pos: Vector2i, y := 0.0) -> Vector3:
|
func pos_of_lpos(pos: Vector2i, y := 0.0) -> Vector3:
|
||||||
return Vector3(pos.x, y, pos.y)
|
return Vector3(pos.x, y, pos.y)
|
||||||
|
|
||||||
|
|
@ -26,7 +23,7 @@ func target_pos() -> Vector3:
|
||||||
return pos_of_lpos(lpos, position.y) + Vector3(0.5, 0, 0.5)
|
return pos_of_lpos(lpos, position.y) + Vector3(0.5, 0, 0.5)
|
||||||
|
|
||||||
var last_move_tween: Tween = null
|
var last_move_tween: Tween = null
|
||||||
func tween_to_target(tween := get_tree().create_tween()):
|
func tween_to_target(tween := get_tree().create_tween(), anim_time: float = get_parent().anim_time):
|
||||||
if last_move_tween:
|
if last_move_tween:
|
||||||
last_move_tween.custom_step(413)
|
last_move_tween.custom_step(413)
|
||||||
last_move_tween.kill()
|
last_move_tween.kill()
|
||||||
|
|
@ -113,7 +110,7 @@ func do_bump(move: Vector2i, tween := get_tree().create_tween(), bumpee: Piece =
|
||||||
if bumpee:
|
if bumpee:
|
||||||
old_lvel_bumpee = bumpee.lvel
|
old_lvel_bumpee = bumpee.lvel
|
||||||
return func():
|
return func():
|
||||||
tween.tween_property(self, "position", target_pos() + pos_of_lpos(move)/2, anim_time/2)
|
tween.tween_property(self, "position", target_pos() + pos_of_lpos(move)/2, get_parent().anim_time/2)
|
||||||
if bumpee:
|
if bumpee:
|
||||||
tween.tween_callback(func():
|
tween.tween_callback(func():
|
||||||
if delay_bumpee_update:
|
if delay_bumpee_update:
|
||||||
|
|
@ -122,7 +119,7 @@ func do_bump(move: Vector2i, tween := get_tree().create_tween(), bumpee: Piece =
|
||||||
bumpee.lvel_displayed = old_lvel_bumpee
|
bumpee.lvel_displayed = old_lvel_bumpee
|
||||||
)
|
)
|
||||||
tween.tween_callback(func(): lvel_displayed = lvel)
|
tween.tween_callback(func(): lvel_displayed = lvel)
|
||||||
tween_to_target(tween)
|
tween_to_target(tween, get_parent().anim_time/2)
|
||||||
|
|
||||||
# TODO?: maybe fix? maybe the bump should be more complicated?
|
# TODO?: maybe fix? maybe the bump should be more complicated?
|
||||||
func undo_bump(_move: Vector2i) -> Callable:
|
func undo_bump(_move: Vector2i) -> Callable:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue