This commit is contained in:
2024-10-19 19:19:46 +02:00
parent 7c50910690
commit bbf3c5e593
12 changed files with 262 additions and 13 deletions

View File

@@ -13,11 +13,17 @@ public partial class DoorView : Control
string answerA{get; set;}
string answerB{get; set;}
bool answerA_good {get; set;}
CharacterBody2D player;
[Export] Label text_mob;
[Export] Button butA;
[Export] Button butB;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
player = (CharacterBody2D)GetParent().GetParent();
}
public void start()
{
GetParent<Camera2D>().PositionSmoothingEnabled = false;
@@ -43,4 +49,21 @@ public partial class DoorView : Control
butB.Text = answerB;
}
public void APressed()
{
if(answerA_good)
{
player.Set("sugar", (int)player.Get("sugar") + GD.RandRange(20, 40));
}
stop();
}
public void BPressed()
{
if(!answerA_good)
{
player.Set("sugar", (int)player.Get("sugar") + GD.RandRange(20, 40));
}
stop();
}
}

View File

@@ -4,19 +4,35 @@ using System;
public partial class Player : CharacterBody2D
{
[Export] float Speed;
[Export] float sugar_speed;
[Export] AnimationPlayer anim;
[Export] Camera2D cam;
[Export] TextureProgressBar bar;
[ExportGroup("controls")]
[Export] Control menu;
public float PixelSize = 1.0f;
float sugar { get; set;}= 50;
const float MAX_SUGAR = 100;
public override void _PhysicsProcess(double delta)
{
Vector2 velocity = Velocity;
sugar -= (float)delta / sugar_speed;
bar.Value = sugar;
if(sugar <= 0)
{
}
else if (sugar >= 100)
{
}
Vector2 direction = Input.GetVector("left", "right", "up", "down");

24
script/Principal.cs Normal file
View File

@@ -0,0 +1,24 @@
using Godot;
using System;
public partial class Principal : Control
{
[Export] Panel sub;
[Export] PackedScene play;
[Export] PackedScene credit;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public void EnterPressed()
{
sub.Visible = true;
}
}