toutGlobalement

This commit is contained in:
2024-10-19 15:17:39 +02:00
parent 93a468a604
commit dbad63f3b0
19 changed files with 1464 additions and 47 deletions

40
script/Door.cs Normal file
View File

@@ -0,0 +1,40 @@
using Godot;
using System;
public partial class Door : Node2D
{
[ExportGroup("text")]
[Export] string text_char;
[Export] string answerA;
[Export] string answerB;
[Export] bool answerA_good;
bool player_in = false;
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
if(player_in && Input.IsActionPressed("interact"))
{
}
}
public void BodyEntered(Node body)
{
if(body is CharacterBody2D)
{
player_in = true;
}
}
public void BodyExited(Node body)
{
if(body is CharacterBody2D)
{
player_in = false;
}
}
}

View File

@@ -3,6 +3,7 @@ using System;
public partial class Menu : Control
{
[Export] AnimationPlayer anim;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
@@ -15,9 +16,9 @@ public partial class Menu : Control
public void ResumeDown()
{
GetTree().Paused = false;
Input.MouseMode = Input.MouseModeEnum.Hidden;
Visible = false;
anim.Play("resume");
}
public void OptionDown()
@@ -29,4 +30,9 @@ public partial class Menu : Control
{
GetTree().Quit();
}
public void Res()
{
GetTree().Paused = false;
}
}

View File

@@ -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();