Compare commits
2 commits
193888cd2b
...
787210847b
| Author | SHA1 | Date | |
|---|---|---|---|
| 787210847b | |||
| 1c9fc2de85 |
2 changed files with 11 additions and 6 deletions
14
board.gd
14
board.gd
|
|
@ -15,10 +15,16 @@ 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)
|
||||||
|
|
||||||
# todo: Array[Piece]
|
func pieces() -> Array[Piece]:
|
||||||
func pieces() -> Array:
|
var sorted: Array[Piece] = []
|
||||||
# todo: sort for consistency
|
for child in get_children():
|
||||||
return get_children()
|
if child is Piece:
|
||||||
|
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] = []
|
||||||
|
|
|
||||||
3
piece.gd
3
piece.gd
|
|
@ -51,14 +51,13 @@ 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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue