-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKinematicBody2D.gd
60 lines (48 loc) · 1.26 KB
/
KinematicBody2D.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
extends KinematicBody2D
const gForce = 800
const jump = 450
const distance = 10
const neededScore = 5
export var speed = 300
export var hp = 100
var play = 0
var direction = Vector2()
var score = 0
func _physics_process(delta):
direction.y += gForce*delta
if is_on_floor():
if Input.is_action_pressed("hore"):
direction.y = -jump
direction.x /= distance
$postavicka.play("vyskok")
if Input.is_action_pressed("vlavo"):
direction.x = -speed
$postavicka.play("pohyb")
$postavicka.flip_h = true
elif Input.is_action_pressed("vpravo"):
direction.x = speed
$postavicka.play("pohyb")
$postavicka.flip_h = false
else:
direction.x = 0
if play == 0:
$hudba.play()
play = 1
if Input.is_action_pressed("koniec"):
get_tree().quit()
direction = move_and_slide(direction,Vector2(0,-1))
func GetDamage_Cactus():
hp -= 30
print("Zostavajuce zivoty: ",hp) # debug
if (hp <= 0):
get_tree().change_scene("res://gameOver.tscn")
func GetDamage_Bird():
hp = hp - 10
print("Zostavajuce zivoty: ",hp) # debug
if (hp <= 0):
get_tree().change_scene("res://gameOver.tscn")
func CoinGrabbed():
score += 1
print("Pocet coinov, ktore mas: ",score)
#if (score == neededScore):
#get_tree().change_scene("res://victory.tscn")