forked from Leo-Santos17/gamejamCria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.gd
122 lines (97 loc) · 2.12 KB
/
player.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
extends CharacterBody2D
# Variáveis de Cena
@onready var scene = get_node("/root/Game/")
@onready var animation := $anim as AnimatedSprite2D
# Variáveis Locais
var is_ready = true
var rateDamage = 1
var hudAmmo : String
var time : float = 0
var psicoce = 1
var qtdFake: int
var qtdReal: int
var pontuacao : int
# Var Abilites
var life = 10
var lifeMax = life
var speedMove = 600
var speedShoot = 600*2
var range = 600
var damageMulti = 1
#Var Empths
var speedMoveF : float
var speedShootF : float
var damageMultiF : float
# Operations
func _ready() :
upStatus()
speedMoveF = speedMove
speedShootF = speedShoot
damageMultiF = damageMulti
func _physics_process(delta):
move()
checkHurt()
# Move
func move():
var direction = Input.get_vector("move_left", "move_right", "move_up", "move_down")
if direction.x != 0 or direction.y != 0:
velocity = direction*speedMove
animation.play("walk")
move_and_slide()
else:
animation.play("idle")
# Dano do Toucher
func take_damage_py():
$getHurt.play()
var overlappingMobs = $HurtBox.get_overlapping_bodies().size()
life -= rateDamage*overlappingMobs-1
status()
dead()
# Dano da Bullet
func take_damage():
check_fake_damage()
status()
dead()
# Recuperar sem aumentar vida (Futuro)
func recLife(x):
life = lifeMax
#status()
# Checks or/and Update
# Atualizar status Apenas vida
func status():
$BarLife.hit(life)
# Atualizar status total
func upStatus():
$BarLife.upgradeLife(life)
# Cooldown Hurt
func checkHurt():
var overlappingMobs = $HurtBox.get_overlapping_bodies()
if overlappingMobs.size() > 1:
if is_ready:
is_ready = false
$CooldownHurt.start()
take_damage_py()
# Update HUD bullets
func HUD(BM, B):
hudAmmo = str(BM)+"/"+str(B)
%quantAmmo.text = hudAmmo
%psicoce.text = str(psicoce)
%MetaScore.text = str(pontuacao)
# Checks Death
func dead():
if life <= 0:
$Death.play()
scene.gameOver()
func check_fake_damage():
$getHurt.play()
if (randi_range(0,psicoce) == randi_range(0,psicoce)):
life -= rateDamage
qtdReal += 1
else:
qtdFake += 1
func score(x):
pontuacao += x
pass
# Timers
func _on_timer_timeout() -> void:
is_ready = true