-
Notifications
You must be signed in to change notification settings - Fork 0
/
ball.gd
25 lines (21 loc) · 1013 Bytes
/
ball.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
extends CharacterBody2D
var SPEED = 80
const JUMP_VELOCITY = -400.0
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var vel = Vector2(1, 1)
func _physics_process(delta):
velocity = vel
var colision = move_and_collide(velocity * delta * SPEED)
if colision:
if not colision.get_collider().is_in_group("brick"):
get_viewport().get_camera_2d().shake(0.5)
print("shake")
print("yewa")
if colision.get_collider().is_class("AnimatableBody2D") and (colision.get_collider().get_parent().get_parent().position - position).y - 2 >= 0:
vel = velocity.bounce(colision.get_normal().rotated((colision.get_collider().get_parent().get_parent().position).angle_to(position + Vector2(0, 5)) * -3))
print(colision.get_collider().get_parent().get_parent())
else:
vel = velocity.bounce(colision.get_normal())
if colision.get_collider().has_method("crash"):
colision.get_collider().call("crash")