plein
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
24
script/Principal.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user