update movement, and added fixed camera follow
mouse and player
This commit is contained in:
11
gamejam/src/Actors/Camera2D.gd
Normal file
11
gamejam/src/Actors/Camera2D.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
extends Camera2D
|
||||
|
||||
const DEAD_ZONE = 160
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
var _target = event.position - get_viewport().size * 0.5
|
||||
if _target.length() < DEAD_ZONE:
|
||||
self.position = Vector2(0,0)
|
||||
else:
|
||||
self.position = _target.normalized() * (_target.length() - DEAD_ZONE) * 0.5
|
||||
@@ -46,11 +46,11 @@ func add_friction():
|
||||
func player_moviment():
|
||||
move_and_slide()
|
||||
|
||||
func jump(delta):
|
||||
func jump(delta):
|
||||
velocity.y += get_grav() * delta
|
||||
|
||||
if Input.is_action_just_pressed("ui_up") and is_on_floor():
|
||||
velocity.y = jump_velocity
|
||||
else:
|
||||
velocity.y += get_grav() * delta
|
||||
|
||||
func get_grav() -> float:
|
||||
return jump_gravity if velocity.y < 0.0 else fall_gravity
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dp4nln7877kq3"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dp4nln7877kq3"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/Actors/Player.gd" id="1_qe2a3"]
|
||||
[ext_resource type="Texture2D" uid="uid://bglwfp5ngk8xr" path="res://assests/placeholder.png" id="2_ctbi8"]
|
||||
[ext_resource type="Script" path="res://src/Actors/Camera2D.gd" id="3_0ej4p"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xv46f"]
|
||||
size = Vector2(121, 149.5)
|
||||
@@ -19,3 +20,6 @@ texture = ExtResource("2_ctbi8")
|
||||
position = Vector2(0, -37.375)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
shape = SubResource("RectangleShape2D_xv46f")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
script = ExtResource("3_0ej4p")
|
||||
|
||||
Reference in New Issue
Block a user