-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer_Code
63 lines (51 loc) · 1.53 KB
/
Player_Code
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
extends KinematicBody2D
const UP = Vector2(0, -1)
var motion = Vector2()
var GRAVITY = 50
var velocity = 100
const JUMP = -800
var sideFacing = "right"
var inAir = false
func _ready():
#snap the window into fullscreen
OS.window_fullscreen = true
#pass
func _physics_process(delta):
#x position intial = 64.677
#y position initial = 451.631
motion.y += GRAVITY;
if (Input.is_action_just_pressed("camera")):
$Camera2D.current = true
$Camera2D.current = false
if (Input.is_action_just_pressed("ui_right")) || (Input.is_action_just_pressed("alt_right")):
motion.x = velocity
if Input.is_action_just_pressed("ui_left") || (Input.is_action_just_pressed("alt_left")):
motion.x = 0 - velocity
if Input.is_action_pressed("ui_right") || (Input.is_action_just_pressed("alt_left")):
if not motion.x >= 460:
motion.x += 60
$Sprite.flip_h = true;
if not inAir:
$Sprite.play('run');
elif Input.is_action_pressed("ui_left") || (Input.is_action_just_pressed("alt_left")):
if not motion.x <= -460:
motion.x += -60
$Sprite.flip_h = false
if not inAir:
$Sprite.play('run');
else:
motion.x = 0
if not inAir:
$Sprite.play('idle')
else:
$Sprite.play('Jump')
#deal with the case where we fall off of an object
#if (motion.y > 0 && inAir == false):
#motion.y -= gravity
if is_on_floor():
inAir = false;
if Input.is_action_just_pressed("ui_up") || (Input.is_action_just_pressed("alt_up")):
inAir = true
motion.y = JUMP
$Sprite.play('Jump')
motion = move_and_slide(motion, UP)