gameboy manque juste des texture et leur animation
This commit is contained in:
@@ -1,30 +1,103 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
using System;
|
||||
|
||||
public partial class Gameboy : CanvasLayer
|
||||
{
|
||||
[Export] CharacterBody2D player;
|
||||
|
||||
//[Export] Array<Texture2D> image_boss;
|
||||
[Export] AnimationPlayer anim;
|
||||
[Export] Control Cmenu;
|
||||
[Export] Label scoreLabel;
|
||||
|
||||
bool menu = true;
|
||||
int round = -1;
|
||||
int actScore = 0;
|
||||
|
||||
int score = 0;
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
Visible = false;
|
||||
anim.Play("RESET");
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
|
||||
{
|
||||
if (Input.IsActionJustPressed("game"))
|
||||
{
|
||||
start();
|
||||
}
|
||||
else if (Input.IsActionJustPressed("interact") || Input.IsActionJustPressed("game"))
|
||||
{
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
void start()
|
||||
{
|
||||
player.Set("pausable", false);
|
||||
Input.MouseMode = Input.MouseModeEnum.Visible;
|
||||
player.Set("pausable", false);
|
||||
this.Visible = true;
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
Input.MouseMode = Input.MouseModeEnum.Hidden;
|
||||
player.Set("pausable", true);
|
||||
this.Visible = false;
|
||||
}
|
||||
|
||||
void attack()
|
||||
{
|
||||
if((int)Cmenu.Get("spell") -1 >= round)
|
||||
{
|
||||
round = (round + 1) % 8;
|
||||
anim.Play(round.ToString());
|
||||
actScore++;
|
||||
updateScore();
|
||||
}
|
||||
else
|
||||
{
|
||||
actScore = 0;
|
||||
anim.Play("RESET");
|
||||
menu = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void APressed()
|
||||
{
|
||||
if (menu)
|
||||
{
|
||||
menu = false;
|
||||
round = 0;
|
||||
anim.Play("start");
|
||||
}
|
||||
else
|
||||
{
|
||||
attack();
|
||||
}
|
||||
}
|
||||
|
||||
public void BPressed()
|
||||
{
|
||||
if (menu)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
menu = true;
|
||||
anim.Play("RESET");
|
||||
}
|
||||
}
|
||||
|
||||
void updateScore()
|
||||
{
|
||||
if (actScore >= score) score = actScore;
|
||||
scoreLabel.Text = "High Score : " + score.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public partial class Menu : Control
|
||||
[Export] Panel trick;
|
||||
[Export] CharacterBody2D player;
|
||||
Node parent;
|
||||
int spell {get; set;} = 0;
|
||||
int spell {get; set;} = 2;
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
|
||||
Reference in New Issue
Block a user