-
Notifications
You must be signed in to change notification settings - Fork 2
/
jay.gd
67 lines (56 loc) · 1.5 KB
/
jay.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
extends KinematicBody2D
var motion = Vector2()
const UP = Vector2(0,-1)
const MAXSPEED = 80
var movingRight = true
onready var bg = get_node("../../")
func _ready():
pass
func _process(delta):
if position.x > 110:
bg.scroll_offset.x = -(position.x - 110)
if position.y > 300:
motion.y = 0
motion.x = 0
position.y = 0
position.x = position.x - 50
func _physics_process(delta):
motion.y += 14
if is_on_floor():
motion.x = 0
if Input.is_action_pressed("ui_right"):
motion.x += MAXSPEED
elif position.x > 4 and Input.is_action_pressed("ui_left"):
motion.x -= MAXSPEED
if Input.is_action_just_pressed("ui_jump"):
motion.y = -300
else:
if motion.x > -MAXSPEED and Input.is_action_pressed("ui_left"):
motion.x -= 2
elif motion.x < MAXSPEED and Input.is_action_pressed("ui_right"):
motion.x += 2
if motion.x > 0:
movingRight = true
$AnimatedSprite.flip_h = false
elif motion.x < 0:
movingRight = false
$AnimatedSprite.flip_h = true
if motion.x != 0 and is_on_floor():
$AnimatedSprite.animation = "run_right"
$AnimatedSprite.play()
else:
if motion.x != 0:
if motion.y > -100 and motion.y < 100:
$AnimatedSprite.animation = "jump2"
else:
$AnimatedSprite.animation = "jump1"
else:
if is_on_floor():
$AnimatedSprite.animation = "stand_right"
else:
if motion.y > -100 and motion.y < 100:
$AnimatedSprite.animation = "jump2"
else:
$AnimatedSprite.animation = "jump1"
$AnimatedSprite.stop()
motion = move_and_slide(motion, UP)