This commit is contained in:
Bingus_Violet 2024-02-22 00:10:13 -06:00
parent 87ef0af5dd
commit 14ef7ad7f9
26 changed files with 1738 additions and 0 deletions

View file

@ -0,0 +1,39 @@
extends Sprite2D
@onready var player = $"../"
func spin(veloc, delta):
var vertSpinMult = abs(veloc.y) * clamp(veloc.x, -1, 1) / 1.5
var spinFactor = (veloc.x + vertSpinMult) / 20
if player.direction:
rotation = lerp(rotation, rotation + (spinFactor), delta)
else:
rotation = lerp(rotation, snappedf(rotation + (spinFactor * delta * 2), PI / 2), delta * 10)
var landed = 0
func _process(delta):
var velocity = player.velocity
var floored = player.is_on_floor()
print(scale)
if not floored:
spin(velocity, delta)
landed = velocity.y
scale = Vector2.ONE
else:
rotation = 0
if landed:
scale.y = 1 - (landed / 800)
scale.x = 1 + (landed / 800)
landed = 0
scale.y = lerp(scale.y, 1.0, delta * 10)
scale.x = lerp(scale.x, 1.0, delta * 10)
offset.y = (8 * pow(scale.y, -1) - 8)

View file

@ -0,0 +1,4 @@
extends Camera2D
func _process(delta):
position = get_local_mouse_position() / 3

View file

@ -0,0 +1,26 @@
[gd_scene load_steps=6 format=3 uid="uid://cqcjan67wgkc1"]
[ext_resource type="Texture2D" uid="uid://dvx8lliqdi3dv" path="res://Player/Skins/Square/Square.png" id="1_3vfyw"]
[ext_resource type="Script" path="res://Player/BasicCharacter/CharacterController.gd" id="1_c5ycp"]
[ext_resource type="Script" path="res://Player/BasicCharacter/CameraController.gd" id="3_2bdku"]
[ext_resource type="Script" path="res://Player/BasicCharacter/AnimationController.gd" id="3_6plye"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_42acf"]
size = Vector2(16, 16)
[node name="Character" type="CharacterBody2D"]
script = ExtResource("1_c5ycp")
[node name="BoxCollider" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_42acf")
[node name="Camera" type="Camera2D" parent="."]
zoom = Vector2(3, 3)
position_smoothing_enabled = true
position_smoothing_speed = 20.0
script = ExtResource("3_2bdku")
[node name="Sprite" type="Sprite2D" parent="."]
self_modulate = Color(1, 0, 0, 1)
texture = ExtResource("1_3vfyw")
script = ExtResource("3_6plye")

View file

@ -0,0 +1,34 @@
extends CharacterBody2D
const SPEED = 400.0
const ACCEL = 7.0
const JUMP_VELOCITY = -400.0
const FALL_SPEED = -JUMP_VELOCITY * 2
var falling = false
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var direction = Vector2.ZERO
func _physics_process(delta):
if not is_on_floor():
var lowGrav = velocity.y < 0 and Input.is_action_pressed("jump")
velocity.y += gravity * delta / gen.boolToNumb(lowGrav, 1)
else:
falling = false
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
if Input.is_action_just_pressed("down") and not falling:
falling = true
velocity.y = clamp(velocity.y + FALL_SPEED, -INF, FALL_SPEED)
direction = round(Input.get_axis("left", "right"))
velocity.x = lerp(velocity.x, direction * SPEED, delta * ACCEL)
move_and_slide()