forked from team-sg/hero-mark-2
rolling fiends, unshackled
This commit is contained in:
parent
3bab40915c
commit
56fb173a24
1 changed files with 12 additions and 9 deletions
|
@ -8,7 +8,8 @@ export var clockwise: bool = false
|
|||
onready var floor_test = Physics2DShapeQueryParameters.new()
|
||||
onready var test_shape = $FloorTestShape
|
||||
|
||||
var floor_direction = 0
|
||||
var floor_direction: int = 0
|
||||
var movement_accumulator: float = 0.0
|
||||
|
||||
func _ready():
|
||||
if clockwise:
|
||||
|
@ -24,14 +25,16 @@ func _ready():
|
|||
move_speed *= Game.easy_mode_speed_factor
|
||||
|
||||
func _physics_process(delta):
|
||||
movement_accumulator += move_speed * delta
|
||||
while movement_accumulator >= 1.0:
|
||||
var offset = 1 if clockwise else -1
|
||||
var move_dir = posmod(floor_direction + offset, DIRS.size())
|
||||
if !is_on_surface(DIRS[floor_direction]):
|
||||
floor_direction = posmod(floor_direction - offset, DIRS.size())
|
||||
elif is_on_surface(DIRS[move_dir]):
|
||||
floor_direction = move_dir
|
||||
if Engine.time_scale > 0.5: #fixes stuttering when slowing down time
|
||||
position += DIRS[posmod(floor_direction + offset, DIRS.size())] * move_speed * delta
|
||||
position += DIRS[posmod(floor_direction + offset, DIRS.size())]
|
||||
movement_accumulator -= 1.0
|
||||
|
||||
func is_on_surface(dir):
|
||||
var space_state = get_world_2d().direct_space_state
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue