Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple game class with Atlantis Framework C++ version. It's XNA like :)
#include "SDL.h"
#include "Game.h"
#include "Graphics/SpriteBatch.h"
#include "Vector2.h"
using namespace Atlantis::Framework;
class Game1 : public Game
{
private:
Graphics::SpriteBatch *spriteBatch;
Vector2 position;
SDL_Texture *texture;
public:
Game1() : Game(1024, 600, "Atlantis Game Test", false)
{
position.X = 50;
position.Y = 50;
texture = nullptr;
}
protected:
virtual void LoadContent()
{
spriteBatch = new Graphics::SpriteBatch(GetRenderer());
texture = GetContentManager()->LoadTexture("../Content/spaceShip.png");
}
virtual void Update(Atlantis::Framework::GameTime *gameTime)
{
Game::Update(gameTime);
Input::KeyboardState state = GetInputManager()->GetKeyboardManager()->GetState();
if (state.IsKeyDown(SDL_SCANCODE_UP))
position.Y -= 2;
else if (state.IsKeyDown(SDL_SCANCODE_DOWN))
position.Y += 2;
if (state.IsKeyDown(SDL_SCANCODE_LEFT))
position.X -= 2;
else if (state.IsKeyDown(SDL_SCANCODE_RIGHT))
position.X += 2;
if (state.IsKeyDown(SDL_SCANCODE_ESCAPE))
Exit();
}
virtual void Draw(Atlantis::Framework::GameTime *gameTime)
{
Game::Draw(gameTime);
spriteBatch->Draw(texture, position);
}
};
int main (int argc, char **argv)
{
Game1 game;
return game.Run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.