Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends RigidBody2D
- var name = 'blue_laser'
- var laser_speed = 1
- var laser_pos
- var sound
- var score = 0
- func _ready():
- set_fixed_process(true)
- sound = get_node("SamplePlayer2D")
- sound.play("laser1")
- func _fixed_process(delta):
- apply_impulse(Vector2(0,0), Vector2(0,-1) * laser_speed)
- laser_pos = self.get_pos()
- if laser_pos.y < 0:
- free()
- print ("laser free")
- func _integrate_forces(state):
- var count = state.get_contact_count()
- if count > 0:
- print("count " + str(count))
- var collider = state.get_contact_collider_object(0)
- print(collider)
- if collider.get_name() != 'Player':
- update_score()
- print('freeing: ' + collider.get_name())
- collider.hide()
- collider.queue_free()
- hide()
- queue_free()
- func update_score():
- print("update score called")
- score += 100
- print(score)
- get_parent().get_node("Score").set_text("Score: " + str(score))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement