We mainly have two meetings (one in a lab and the other we organised in the library), where I helped a bit with getting some ideas for the motivations of the enemies in the game, and me and Misha got assigned homework by Shay (gameplay designer); we needed to make the movement by Monday.
Mostly apllied basics from the godot wiki, but me and Misha were not able to make the turn/timer part of the code work (it simply did nothing or made the game get stuck).
using Godot;
using System;
using System.Threading.Tasks;
public partial class player_movement : StaticBody2D
{
//important varibles
[Export]
public int TileSize { get; set; } = 64;
bool has_moved = false;
//input handling
public Vector2 GetInput()
{
Vector2 direction = Input.GetVector("move_left", "move_right", "move_up", "move_down");
return direction;
}
/*movement method
TODO - Implement TestMove
- fix the turns (kill me)
*/
public void Move(Vector2 direction) {
if (has_moved == true)
{
//miserable implemntation of turns (does not work)
DelayMethod();
}
else if (direction != Vector2.Zero && has_moved == false)
{
direction = direction.Normalized();
Position += TileSize * direction;
Position = Position.Snapped(Vector2.One * TileSize);
has_moved = true;
}
}
//delay method to create turns (work in progress)
private async void DelayMethod()
{
var timer = GetTree().CreateTimer(4f);
await Task.Delay(TimeSpan.FromMilliseconds(1));
timer.Timeout += OnTimerTimeout;
}
public override void _PhysicsProcess(double delta)
{
Vector2 direction = GetInput();
Move(direction);
//MoveAndSlide();
}
public override void _Ready()
{
Position = Position.Snapped(Vector2.One * TileSize);
Position += Vector2.One * TileSize;
}
private void OnTimerTimeout()
{
has_moved = false;
}
}
And then we got one of our artists (that is actually a really good programmer) to do it, but they only know GDScript... Now i need to translate all the code that Piraker made in GDScript to C#; that will be a task for next week.
What we got at the end of the week is this: