refactor to latest godot api

item-info
John Montagu, the 4th Earl of Sandvich 2023-01-29 12:05:44 -08:00
parent 38bfae2aaa
commit f0797388d8
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
9 changed files with 182 additions and 183 deletions

View File

@ -18,6 +18,7 @@ generate_mipmaps=false
multichannel_signed_distance_field=false multichannel_signed_distance_field=false
msdf_pixel_range=8 msdf_pixel_range=8
msdf_size=48 msdf_size=48
allow_system_fallback=true
force_autohinter=false force_autohinter=false
hinting=1 hinting=1
subpixel_positioning=1 subpixel_positioning=1

View File

@ -83,7 +83,7 @@ namespace SupaLidlGame.Characters
StateMachine.Process(delta); StateMachine.Process(delta);
} }
Sprite.FlipH = Target.x < 0; Sprite.FlipH = Target.X < 0;
DrawTarget(); DrawTarget();
} }
@ -136,16 +136,16 @@ namespace SupaLidlGame.Characters
protected void DrawTarget() protected void DrawTarget()
{ {
Vector2 target = Target; Vector2 target = Target;
float angle = Mathf.Atan2(target.y, Mathf.Abs(target.x)); float angle = Mathf.Atan2(target.Y, Mathf.Abs(target.X));
Vector2 scale = Inventory.Scale; Vector2 scale = Inventory.Scale;
if (target.x < 0) if (target.X < 0)
{ {
scale.y = -1; scale.Y = -1;
angle = Mathf.Pi - angle; angle = Mathf.Pi - angle;
} }
else else
{ {
scale.y = 1; scale.Y = 1;
} }
Inventory.Scale = scale; Inventory.Scale = scale;
Inventory.Rotation = angle; Inventory.Rotation = angle;

View File

@ -120,8 +120,8 @@ namespace SupaLidlGame.Characters
Vector2 dir = Target.Normalized(); Vector2 dir = Target.Normalized();
float dist = GlobalPosition.DistanceSquaredTo(pos); float dist = GlobalPosition.DistanceSquaredTo(pos);
var spaceState = GetWorld2d().DirectSpaceState; var spaceState = GetWorld2D().DirectSpaceState;
var exclude = new Godot.Collections.Array<RID>(); var exclude = new Godot.Collections.Array<Godot.Rid>();
exclude.Add(this.GetRid()); exclude.Add(this.GetRid());
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
@ -243,7 +243,7 @@ namespace SupaLidlGame.Characters
public Vector2 GetBlocking() public Vector2 GetBlocking()
{ {
var spaceState = GetWorld2d().DirectSpaceState; var spaceState = GetWorld2D().DirectSpaceState;
int rayLength = 16; int rayLength = 16;
float[] weights = new float[16]; float[] weights = new float[16];
Vector2[] rays = new Vector2[16]; Vector2[] rays = new Vector2[16];
@ -254,7 +254,7 @@ namespace SupaLidlGame.Characters
// the length determines its strength // the length determines its strength
// exclude itself from raycasts // exclude itself from raycasts
var exclude = new Godot.Collections.Array<RID>(); var exclude = new Godot.Collections.Array<Godot.Rid>();
exclude.Add(GetRid()); exclude.Add(GetRid());
var rayParams = new PhysicsRayQueryParameters2D var rayParams = new PhysicsRayQueryParameters2D

View File

@ -1,5 +1,4 @@
using Godot; using Godot;
using System.Linq;
namespace SupaLidlGame.Extensions namespace SupaLidlGame.Extensions
{ {
@ -7,8 +6,8 @@ namespace SupaLidlGame.Extensions
{ {
public static Vector2 Midpoint(this Vector2 vector, Vector2 other) public static Vector2 Midpoint(this Vector2 vector, Vector2 other)
{ {
return new Vector2((vector.x + other.x) / 2, return new Vector2((vector.X + other.X) / 2,
(vector.y + other.y) / 2); (vector.Y + other.Y) / 2);
} }
public static Vector2 Midpoints(params Vector2[] vectors) public static Vector2 Midpoints(params Vector2[] vectors)
@ -19,8 +18,8 @@ namespace SupaLidlGame.Extensions
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
x += vectors[i].x; x += vectors[i].X;
y += vectors[i].y; y += vectors[i].Y;
} }
return new Vector2(x / length, y / length); return new Vector2(x / length, y / length);
@ -28,12 +27,12 @@ namespace SupaLidlGame.Extensions
public static Vector2 Counterclockwise90(this Vector2 vector) public static Vector2 Counterclockwise90(this Vector2 vector)
{ {
return new Vector2(-vector.y, vector.x); return new Vector2(-vector.Y, vector.X);
} }
public static Vector2 Clockwise90(this Vector2 vector) public static Vector2 Clockwise90(this Vector2 vector)
{ {
return new Vector2(vector.y, -vector.x); return new Vector2(vector.Y, -vector.X);
} }
} }
} }

View File

@ -26,7 +26,7 @@ namespace SupaLidlGame.Items.Weapons
public double AttackTime { get; set; } = 0; public double AttackTime { get; set; } = 0;
[Export] [Export]
public CPUParticles2D ParryParticles { get; set; } public CpuParticles2D ParryParticles { get; set; }
public override bool IsParryable { get; protected set; } public override bool IsParryable { get; protected set; }
@ -98,7 +98,7 @@ namespace SupaLidlGame.Items.Weapons
Hitbox.IsDisabled = true; Hitbox.IsDisabled = true;
ProcessHits(); ProcessHits();
Hitbox.ResetIgnoreList(); Hitbox.ResetIgnoreList();
AnimationPlayer.PlaybackSpeed = 1; AnimationPlayer.SpeedScale = 1;
} }
public override void _Ready() public override void _Ready()
@ -146,7 +146,7 @@ namespace SupaLidlGame.Items.Weapons
{ {
// our character was parried // our character was parried
IsParried = true; IsParried = true;
AnimationPlayer.PlaybackSpeed = 0.25f; AnimationPlayer.SpeedScale = 0.25f;
Character.Stun(1.5f); Character.Stun(1.5f);
GetNode<AudioStreamPlayer2D>("ParrySound").Play(); GetNode<AudioStreamPlayer2D>("ParrySound").Play();
} }

View File

@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.0.0-beta.7"> <Project Sdk="Godot.NET.Sdk/4.0.0-beta.16">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading> <EnableDynamicLoading>true</EnableDynamicLoading>

View File

@ -1,5 +1,4 @@
using Godot; using Godot;
using System;
public partial class StaticMovement : CharacterBody2D public partial class StaticMovement : CharacterBody2D
{ {
@ -15,22 +14,22 @@ public partial class StaticMovement : CharacterBody2D
// Add the gravity. // Add the gravity.
if (!IsOnFloor()) if (!IsOnFloor())
velocity.y += gravity * (float)delta; velocity.Y += gravity * (float)delta;
// Handle Jump. // Handle Jump.
if (Input.IsActionJustPressed("ui_accept") && IsOnFloor()) if (Input.IsActionJustPressed("ui_accept") && IsOnFloor())
velocity.y = JumpVelocity; velocity.Y = JumpVelocity;
// Get the input direction and handle the movement/deceleration. // Get the input direction and handle the movement/deceleration.
// As good practice, you should replace UI actions with custom gameplay actions. // As good practice, you should replace UI actions with custom gameplay actions.
Vector2 direction = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down"); Vector2 direction = Input.GetVector("ui_left", "ui_right", "ui_up", "ui_down");
if (direction != Vector2.Zero) if (direction != Vector2.Zero)
{ {
velocity.x = direction.x * Speed; velocity.X = direction.X * Speed;
} }
else else
{ {
velocity.x = Mathf.MoveToward(Velocity.x, 0, Speed); velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed);
} }
Velocity = velocity; Velocity = velocity;

View File

@ -42,8 +42,8 @@ namespace SupaLidlGame.Utils
{ {
Vector2 ret = Vector2.Zero; Vector2 ret = Vector2.Zero;
var rng = new RandomNumberGenerator(); var rng = new RandomNumberGenerator();
ret.x = (rng.Randf() - 0.5f) * intensity; ret.X = (rng.Randf() - 0.5f) * intensity;
ret.y = (rng.Randf() - 0.5f) * intensity; ret.Y = (rng.Randf() - 0.5f) * intensity;
return ret; return ret;
} }
} }

View File

@ -23,32 +23,32 @@ project/assembly_name="SupaLidlGame"
ui_left={ ui_left={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
ui_right={ ui_right={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
ui_up={ ui_up={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
ui_down={ ui_down={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":83,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
roll={ roll={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":3,"pressed":false,"double_click":false,"script":null) "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":3,"pressed":false,"double_click":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"unicode":0,"echo":false,"script":null) , Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":0,"echo":false,"script":null)
] ]
} }
attack1={ attack1={
@ -58,7 +58,7 @@ attack1={
} }
equip={ equip={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":0,"echo":false,"script":null)
] ]
} }