toutGlobalement
This commit is contained in:
@@ -4,22 +4,19 @@ using System;
|
||||
public partial class Player : CharacterBody2D
|
||||
{
|
||||
[Export] float Speed;
|
||||
[Export] AnimationPlayer anim;
|
||||
[Export] Camera2D cam;
|
||||
|
||||
[ExportGroup("controls")]
|
||||
[Export] Control menu;
|
||||
|
||||
|
||||
public float PixelSize = 1.0f;
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
Vector2 velocity = Velocity;
|
||||
|
||||
if(Input.IsActionPressed("quit"))
|
||||
{
|
||||
Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||
GetTree().Paused= true;
|
||||
menu.Visible = true;
|
||||
}
|
||||
|
||||
|
||||
Vector2 direction = Input.GetVector("left", "right", "up", "down");
|
||||
@@ -32,7 +29,39 @@ public partial class Player : CharacterBody2D
|
||||
{
|
||||
velocity.X = Mathf.MoveToward(Velocity.X, 0, Speed);
|
||||
velocity.Y = Mathf.MoveToward(Velocity.Y, 0, Speed);
|
||||
|
||||
velocity = velocity.Round();
|
||||
}
|
||||
|
||||
|
||||
if(Input.IsActionPressed("quit"))
|
||||
{
|
||||
Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||
anim.Play("paused");
|
||||
GetTree().Paused= true;
|
||||
}
|
||||
else if(velocity.X > 0)
|
||||
{
|
||||
anim.Play("right");
|
||||
}
|
||||
else if (velocity.X < 0)
|
||||
{
|
||||
anim.Play("left");
|
||||
}
|
||||
else if (velocity.Y > 0)
|
||||
{
|
||||
anim.Play("down");
|
||||
}
|
||||
else if (velocity.Y < 0)
|
||||
{
|
||||
anim.Play("up");
|
||||
}
|
||||
else
|
||||
{
|
||||
anim.Play("idle");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Velocity = velocity;
|
||||
MoveAndSlide();
|
||||
|
||||
Reference in New Issue
Block a user