level now detects (in a very rudimentary way, by checking every frame) whether all blocks have been broken
This commit is contained in:
+8
-19
@@ -3,18 +3,18 @@ extends CharacterBody2D
|
||||
@export var speed: float = 5
|
||||
@export var strength: int = 1
|
||||
|
||||
const _speed_mult: float = 20
|
||||
var _direction: Vector2 = Vector2(-1.0, -0.5)
|
||||
var _velocity: Vector2
|
||||
const _speed_mult: float = 5000
|
||||
|
||||
var _direction: Vector2
|
||||
var _velocity: Vector2
|
||||
var deg: float
|
||||
|
||||
func _ready():
|
||||
_velocity.x = 400#speed * _speed_mult * _direction.x * delta
|
||||
_velocity.y = 450#speed * _speed_mult * _direction.y * delta
|
||||
|
||||
_direction = Vector2.UP.rotated(deg_to_rad(randf_range(0.0, 360.0)))
|
||||
|
||||
func _physics_process(delta):
|
||||
_velocity.x = speed * _speed_mult * _direction.x * delta
|
||||
_velocity.y = speed * _speed_mult * _direction.y * delta
|
||||
|
||||
var collide = move_and_collide(_velocity * delta)
|
||||
if collide:
|
||||
@@ -23,22 +23,11 @@ func _physics_process(delta):
|
||||
_invert_x()
|
||||
if (deg >= 135 and deg < 225) or deg < 45 or deg >= 315:
|
||||
_invert_y()
|
||||
print(collide.get_collider())
|
||||
if collide.get_collider().get_parent() is Block:
|
||||
print(true)
|
||||
collide.get_collider().get_parent().take_damage(strength)
|
||||
|
||||
func _invert_x():
|
||||
_velocity.x *= -1
|
||||
_direction.x *= -1
|
||||
|
||||
func _invert_y():
|
||||
_velocity.y *= -1
|
||||
|
||||
func has_collided():
|
||||
pass
|
||||
#if $Raycasts/North.is_colliding() or $Raycasts/South.is_colliding():
|
||||
#_invert_y()
|
||||
#print("y")
|
||||
#if $Raycasts/West.is_colliding() or $Raycasts/East.is_colliding():
|
||||
#_invert_x()
|
||||
#print("x")
|
||||
_direction.y *= -1
|
||||
|
||||
Reference in New Issue
Block a user