5
Player::Player() : Entity(),
8
sprite = new SpriteAnimation("player.png", FILTER_NONE, 64, 64);
9
sprite->Add("idle", 0, 0, 0.35f);
15
SetCollider(new RectangleCollider(32, 32));
22
//Scene::GetCamera()->position = position;
29
DarkScene::DarkScene() : Scene()
33
void DarkScene::Begin()
37
Graphics::Set2D(1024, 768);
39
Text *inst2 = new Text("Press ESC to quit");
40
inst2->position = Vector2(-492, -354); // 20px h, 30px v from U-L corner
43
Input::DefineMaskKey("left", KEY_LEFT);
44
Input::DefineMaskKey("right", KEY_RIGHT);
45
Input::DefineMaskKey("up", KEY_UP);
46
Input::DefineMaskKey("down", KEY_DOWN);
48
Input::DefineMaskKey("up", KEY_W);
49
Input::DefineMaskKey("left", KEY_A);
50
Input::DefineMaskKey("down", KEY_S);
51
Input::DefineMaskKey("right", KEY_D);
54
Add( levelEditor = new LevelEditor() );
55
levelEditor->Disable();
57
// load level from files
58
Level::LoadProject("project.xml");
59
Level::Load("level.xml", this);
61
Player *player = new Player;
62
player->position = Graphics::GetScreenCenter();
65
Graphics::SetBackgroundColor(Color::green * 0.2f);
69
void DarkScene::Update()
73
if (Input::IsKeyPressed(KEY_ESCAPE))
78
if (Input::IsKeyPressed(KEY_S) && Input::IsKeyHeld(KEY_LCTRL))
81
if (Input::IsKeyPressed(KEY_A))
82
Scene::GetCamera()->position.x -= 600;
84
if (Input::IsKeyPressed(KEY_D))
85
Scene::GetCamera()->position.x += 600;
88
if (Input::IsKeyPressed(KEY_TAB))
90
// if we're not doing anything in the levelEditor...
91
if (levelEditor->GetState() == FTES_NONE)
96
levelEditor->Enable();
98
levelEditor->Disable();
102
}// DarkScene::Update
104
Text::Text(const std::string& text, FontAsset* font)
105
: Entity(), text(text)
108
this->font = Assets::RequestFont("LiberationSans-Regular.ttf", 18.0f);
115
Graphics::PushMatrix();
117
// place text directly relative to camera
118
Graphics::Translate(scene->GetCamera()->position + position);
120
Graphics::SetBlend(BLEND_ALPHA);
121
Graphics::SetColor(Color::white);
122
Graphics::BindFont(font);
124
Graphics::RenderText(*font, text, 0, 0);
125
Graphics::PopMatrix();