using Godot; using Godot.Collections; using System; public partial class Gameboy : CanvasLayer { [Export] CharacterBody2D player; //[Export] Array 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() { 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(); } }