Compare commits

..

No commits in common. "787210847b4b8ee023708f0ca1c0b91ca5ef3775" and "193888cd2b1a674f0e8f799ce3e6db63ebaff5af" have entirely different histories.

2 changed files with 6 additions and 11 deletions

View file

@ -15,16 +15,10 @@ func top_left_aabb() -> AABB:
func bottom_right_aabb() -> AABB: func bottom_right_aabb() -> AABB:
return AABB(position + Vector3(dims.x, 0, dims.y) + Vector3(1,0,2), Vector3.ONE*0.1) return AABB(position + Vector3(dims.x, 0, dims.y) + Vector3(1,0,2), Vector3.ONE*0.1)
func pieces() -> Array[Piece]: # todo: Array[Piece]
var sorted: Array[Piece] = [] func pieces() -> Array:
for child in get_children(): # todo: sort for consistency
if child is Piece: return get_children()
sorted.push_back(child)
# important for consistency.
# everything involving pieces is done top to bottom, then left to right
# expensive? yes. wasteful? definitely. worth it? i think so.
sorted.sort_custom(func(a, b): return a.lpos.y < b.lpos.y or a.lpos.x < b.lpos.x)
return sorted
func pieces_at(pos: Vector2i) -> Array[Piece]: func pieces_at(pos: Vector2i) -> Array[Piece]:
var out: Array[Piece] = [] var out: Array[Piece] = []

View file

@ -51,13 +51,14 @@ func do_step(board: Board):
# ball being collided *with* gets the remainder of the momentum # ball being collided *with* gets the remainder of the momentum
# EMERGENT COMPLEXITY!??!? # EMERGENT COMPLEXITY!??!?
if board.solid_at(new_pos): if board.solid_at(new_pos):
do_bump(move).call()
var ball_here := board.type_at(new_pos, Piece.Type.Ball) var ball_here := board.type_at(new_pos, Piece.Type.Ball)
if ball_here: if ball_here:
do_bump(move).call()
var rem := lvel % 2 var rem := lvel % 2
ball_here.do_push(lvel/2 + rem).call() ball_here.do_push(lvel/2 + rem).call()
lvel = -lvel/2 lvel = -lvel/2
else: else:
lpos = lpos
lvel -= move lvel -= move
return return
lpos = new_pos lpos = new_pos