#pragma once
#include "Laser.hpp"
#include "KeyPressHandle.hpp"
#include "Alien.h"
#include "misc/Timer.hpp"
#include <Gorgon/CGI/Line.h>
#include <Gorgon/Containers/Collection.h>
#include <Gorgon/Geometry/Point.h>
#include <Gorgon/Graphics/Animations.h>
#include <Gorgon/Graphics/Bitmap.h>
#include <Gorgon/Graphics/Layer.h>
#include <Gorgon/Graphics/TextureAnimation.h>
#include <Gorgon/Input/Keyboard.h>
#include <Gorgon/Main.h>
#include <Gorgon/Game/World/World.h>
#include <Gorgon/Scene.h>
#include <Gorgon/String.h>
#include <Gorgon/Widgets/Label.h>
using Gorgon::Geometry::Point;
using Gorgon::Graphics::Bitmap;
namespace W = Gorgon::Widgets;
namespace Keycodes = Gorgon::Input::Keyboard::Keycodes;
class Game : Gorgon::Game::Template::World<Gorgon::Game::Template::EmptyInitializer> {
public:
using Base = Gorgon::Game::Template::World<Gorgon::Game::Template::EmptyInitializer>;
using StandardRenderer = Gorgon::Game::Rendering::Tiled::StandardRenderer;
Game(Gorgon::SceneManager& manager) : Base(manager), keypress({KeyPressHandle{Keycodes::Left}, {Keycodes::Right},{Keycodes::Up},{Keycodes::Down}, {Keycodes::Space}}) {
GameStartScene();
ShootingScene();
GameEndScene();
}
// Scenes
void GameStartScene();
void ShootingScene();
void GameEndScene();
// Player
void PreparePlayerResources();
void PlayerMech();
void LaserMovement();
void LaserCollusion();
void PlayerCollusion();
// Alien
void PrepareAlienResources();
void AlienFireLaser(int delta);
void AlienSpeedUp(int delta);
void AlienCountUp(int delta);
void AddAlien(int delta);
void AlienMovement(int delta);
// Misc.
void PrepareLasers();
void Run() {
Base::manager.Run();
}
private:
int next_fire = 300;
std::array<KeyPressHandle, 5> keypress;
Gorgon::Graphics::RectangularAnimationStorage player_laser, alien, alien_laser;
Gorgon::Containers::Collection<Laser> player_lasers, alien_lasers;
Gorgon::Containers::Collection<Alien> aliens;
struct {
int speed = 200;
Point location = {480, 320}, target = {480, 320};
Bitmap image;
} player;
int points = 0;
W::MarkdownLabel score, welcome, gameend, timer_text;
int health = 5;
bool left = false, right = false;
int Delta = 0;
int time_left = 60;
Timer timer;
};