-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rock.gd
66 lines (56 loc) · 1.7 KB
/
Rock.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
extends RigidBody2D
var PlayerEnteredInteractionHitbox = 0
var SharpRockEquipped = 0
var RockJustSpawned = 0
var random = RandomNumberGenerator.new()
func _process(_delta):
MoveTheRock()
PickUp()
func _ready():
RockJustSpawned = 1
func MoveTheRock():
if RockJustSpawned == 1:
apply_impulse(Vector2(random.randi_range(-20,-220),random.randi_range(10,-250)))
RockJustSpawned = 0
if int(Input.is_action_pressed("Jump")):
global.Facing = 2
if int(Input.is_action_pressed("Right")):
global.Facing = 1
if int(Input.is_action_pressed("Left")):
global.Facing = -1
if SharpRockEquipped == 1 and int(Input.is_action_pressed("Attack")):
if global.Facing == 1:
apply_impulse(Vector2(500,-250))
$Stone.play()
if global.Facing == -1:
apply_impulse(Vector2(-500,-250))
$Stone.play()
if global.Facing == 2:
apply_impulse(Vector2(0,-500))
$Stone.play()
SharpRockEquipped = 0
global.SharpRockEquipped = 0
elif SharpRockEquipped == 0:
if $Timer.is_stopped() == true:
$Timer.start()
elif SharpRockEquipped == 1:
$CollisionShape2D.disabled = true
global_position = global.PlayerPosition + Vector2(0,-10)
angular_velocity = 0
linear_velocity = Vector2(0,0)
global.RockLVelocity = linear_velocity
func PickUp():
if PlayerEnteredInteractionHitbox == 1 and int(Input.is_action_pressed("Interact")) == 1:
if global.SharpRockEquipped == 0:
SharpRockEquipped = 1
global.SharpRockEquipped = 1
else:
pass
func _on_timer_timeout():
$CollisionShape2D.disabled = false
func _on_area_2d_body_entered(body):
if body.is_in_group("Player"):
PlayerEnteredInteractionHitbox = 1
func _on_area_2d_body_exited(body):
if body.is_in_group("Player"):
PlayerEnteredInteractionHitbox = 0