boogit
This commit is contained in:
parent
f5ad603864
commit
ae7b962896
101 changed files with 1520 additions and 0 deletions
55
ball.gd
Normal file
55
ball.gd
Normal file
|
@ -0,0 +1,55 @@
|
|||
extends RigidBody2D
|
||||
|
||||
signal clicked
|
||||
|
||||
var held = false
|
||||
|
||||
@onready var Blood = preload("res://blood.tscn")
|
||||
var contact_point = Vector2.ZERO
|
||||
|
||||
func _on_input_event(viewport, event, shape_idx):
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if event.pressed:
|
||||
print("clicked")
|
||||
clicked.emit(self)
|
||||
|
||||
func _physics_process(delta):
|
||||
if held:
|
||||
var mouse_position = clamp(get_global_mouse_position(),Vector2.ZERO,Vector2(640,480))
|
||||
global_transform.origin = mouse_position
|
||||
|
||||
func pickup():
|
||||
if held:
|
||||
return
|
||||
freeze = true
|
||||
held = true
|
||||
|
||||
func drop(impulse=Vector2.ZERO):
|
||||
if held:
|
||||
freeze = false
|
||||
apply_central_impulse(impulse)
|
||||
held = false
|
||||
|
||||
|
||||
func _integrate_forces(state):
|
||||
contact_point = state.get_contact_collider_position(0)
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
if abs(linear_velocity.x) > 200 or abs(linear_velocity.y) > 200:
|
||||
%AudioStreamPlayer.play()
|
||||
%Impact_noise.play()
|
||||
%Timer.start()
|
||||
var blood = Blood.instantiate()
|
||||
var random_position = Vector2(randf_range(-70,70),randf_range(-50,50))
|
||||
blood.global_position = contact_point + random_position
|
||||
get_parent().add_child(blood)
|
||||
battle_damage()
|
||||
|
||||
func battle_damage():
|
||||
print(%Bruising.modulate.a)
|
||||
if %Bruising.modulate.a < 1:
|
||||
%Bruising.modulate.a += randf_range(0,0.1)
|
||||
if %Bruising.modulate.a > 0.5:
|
||||
%Bleeding.modulate.a += randf_range(0,0.05)
|
||||
if %Bleeding.modulate.a > 0.9:
|
||||
%HeavyBleeding.modulate.a += randf_range(0,0.025)
|
Loading…
Add table
Add a link
Reference in a new issue