forked from kyle-stevens/GeoJump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player_cube_demo.gd
42 lines (32 loc) · 1.06 KB
/
Player_cube_demo.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
extends RigidBody2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var is_jumping = false
var prev_position = position
var iteration = 0
var jumps = 0
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
#if prev_position != position:
if abs(prev_position.x - position.x) > 0.09 or abs(prev_position.y - position.y) > 0.09:
is_jumping = true
else:
is_jumping = false
#$Line2D.visible = true
prev_position = position
print(is_jumping, $Line2D.visible)
iteration += 1
$Line2D.visible = false
$Line2D.set_point_position(0, get_transform().affine_inverse() * get_global_mouse_position())
if Input.is_action_pressed("ui_accept") and not is_jumping:
$Line2D.visible = true
pass
if Input.is_action_just_released("ui_accept"):
var offset = Vector2.ZERO
var target = get_global_mouse_position() - position
apply_impulse(offset, target*3)
$Line2D.visible = false