First level prototype, fixed inair movement

This commit is contained in:
Jakob Feldmann 2022-06-27 22:39:55 +02:00
parent fb52fd0ecd
commit 6951028145
8 changed files with 77 additions and 13 deletions

6
.gitignore vendored
View File

@ -26,5 +26,7 @@ export_presets.cfg
data_*/ data_*/
# VSCode specific ignores # VSCode specific ignores
/.vscode /.vscode/*
.vscode/launch.json /.vscode/launch.json
*/.vscode/*
*/.vscode/launch.json

2
.vscode/launch.json vendored
View File

@ -8,7 +8,7 @@
"name": "GDScript Godot", "name": "GDScript Godot",
"type": "godot", "type": "godot",
"request": "launch", "request": "launch",
"project": "C:\\Users\\Jakob\\Documents\\Godot\\Wumper", "project": "C:\\Users\\Jakob F\\Documents\\Godot\\Wumper",
"port": 6007, "port": 6007,
"address": "127.0.0.1", "address": "127.0.0.1",
"launch_game_instance": true, "launch_game_instance": true,

View File

@ -61,7 +61,7 @@ window/stretch/aspect="keep"
[editor_plugins] [editor_plugins]
enabled=PoolStringArray( "res://addons/AsepriteWizard/plugin.cfg" ) enabled=PoolStringArray( )
[global] [global]
@ -146,6 +146,8 @@ boost_move={
quality/intended_usage/framebuffer_allocation=0 quality/intended_usage/framebuffer_allocation=0
quality/intended_usage/framebuffer_allocation.mobile=0 quality/intended_usage/framebuffer_allocation.mobile=0
2d/snapping/use_gpu_pixel_snap=true 2d/snapping/use_gpu_pixel_snap=true
quality/filters/use_nearest_mipmap_filter=true
quality/filters/msaa=1
environment/default_environment="res://default_env.tres" environment/default_environment="res://default_env.tres"
quality/2d/use_pixel_snap=true quality/2d/use_pixel_snap=true
environment/2d/use_nvidia_rect_flicker_workaround=true environment/2d/use_nvidia_rect_flicker_workaround=true

View File

@ -147,8 +147,9 @@ func is_correct_airstrafe_input() -> bool:
return ( return (
air_strafe_charges > 0 air_strafe_charges > 0
&& ( && (
Input.is_action_just_pressed("move_right")
||
Input.is_action_just_pressed("move_left") Input.is_action_just_pressed("move_left")
|| Input.is_action_just_pressed("move_right")
) )
) )
@ -191,11 +192,11 @@ func calculate_jump_velocity(
linear_velocity.y += _gravity * delta linear_velocity.y += _gravity * delta
# TODO Dis shizzle buggy # TODO Dis shizzle buggy
# TODO is boosting part of jump? if (-4 < velocity.x and velocity.x < 4) :
if is_equal_approx(velocity.x, 0):
linear_velocity.x += inair_velocity * direction.x linear_velocity.x += inair_velocity * direction.x
if is_correct_airstrafe_input() && !walljumping: if is_correct_airstrafe_input() && !walljumping:
# var rev = 1 if !is_reversing_horizontal_movement(direction) else -1
linear_velocity.x = PhysicsFunc.two_step_euler( linear_velocity.x = PhysicsFunc.two_step_euler(
linear_velocity.x, linear_velocity.x,
acceleration_force["air_strafe"].x * direction.x, acceleration_force["air_strafe"].x * direction.x,
@ -219,13 +220,13 @@ func calculate_fall_velocity(
) )
else: else:
linear_velocity.y = max_velocity["fall"] linear_velocity.y = max_velocity["fall"]
# TODO Gets velocity away from wall when moving against it
if (-4 < velocity.x and velocity.x < 4) : if (-4 < velocity.x and velocity.x < 4) :
# TODO This is poop # TODO This is poop
linear_velocity.x += inair_velocity * direction.x linear_velocity.x += inair_velocity * direction.x
if Input.is_action_just_pressed("jump"): if Input.is_action_just_pressed("jump"):
jump_buffer_filled = true jump_buffer_filled = true
if is_correct_airstrafe_input(): if is_correct_airstrafe_input():
# var rev = 1 if !is_reversing_horizontal_movement(direction) else -1
linear_velocity.x = PhysicsFunc.two_step_euler( linear_velocity.x = PhysicsFunc.two_step_euler(
linear_velocity.x, linear_velocity.x,
acceleration_force["air_strafe"].x * direction.x, acceleration_force["air_strafe"].x * direction.x,
@ -250,9 +251,10 @@ func calculate_wallslide_velocity(
# TODO this is done 3 times for different states # TODO this is done 3 times for different states
# TODO make air strafe a portionable boost instead of a one time acceleration (or not?! whaaat?) # TODO make air strafe a portionable boost instead of a one time acceleration (or not?! whaaat?)
elif is_correct_airstrafe_input(): elif is_correct_airstrafe_input():
# var rev = 1 if !is_reversing_horizontal_movement(direction) else -1
linear_velocity.x = PhysicsFunc.two_step_euler( linear_velocity.x = PhysicsFunc.two_step_euler(
linear_velocity.x, linear_velocity.x,
acceleration_force["air_strafe"].x * direction.x, acceleration_force["air_strafe"].x * velocity.x,
mass, mass,
delta delta
) )

View File

@ -113,6 +113,8 @@ func _get_transition(_delta):
self.state self.state
+ " x vel:" + " x vel:"
+ String(round(parent.velocity.x)) + String(round(parent.velocity.x))
+ " y vel/10:"
+ String(round(parent.velocity.y/10))
) )
var new_state var new_state
if !parent.is_on_floor(): if !parent.is_on_floor():

View File

@ -6,7 +6,7 @@ const FLOOR_NORMAL := Vector2.UP
var stomp_feedback := 1000.0 var stomp_feedback := 1000.0
var inair_velocity := 21 var inair_velocity := 21
var wallslide_threshold := 300 var wallslide_threshold := 1000
# TODO Map to floor types and move to physics constants # TODO Map to floor types and move to physics constants
var normal_floor_friction := 0.5 var normal_floor_friction := 0.5
var max_velocity := { var max_velocity := {
@ -23,7 +23,7 @@ var acceleration_force := {
"walk": Vector2(2000, 74000), "walk": Vector2(2000, 74000),
"idle": Vector2(2000, 74000), "idle": Vector2(2000, 74000),
"run": Vector2(2800, 74000), "run": Vector2(2800, 74000),
"walljump": Vector2(36000, 74000), "walljump": Vector2(36000, 63000),
"air_strafe": Vector2(20000, 100) "air_strafe": Vector2(20000, 100)
} }
# Gravity as m/s^2 # Gravity as m/s^2

56
src/Levels/1Level.tscn Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long