raylibstarter 0.1.0
game_scene.cpp
Go to the documentation of this file.
1#include <memory>
2#include <string>
3
4#include <raylib-cpp.hpp>
5#include <raylib.h>
6
7#include <store.h>
8
9#include "scenes.h"
10#include "renderer.h"
11
12using namespace std::string_literals;
13
15 // Your scene initialization code here...
16 std::shared_ptr<game::core::Actor> actor1 = std::make_unique<game::core::Actor>(std::make_unique<game::core::Sprite>(std::make_shared<game::core::Texture2D>("assets/graphics/ball.png"), 100, 100));
17 this->actors.insert(std::make_pair("actor1", actor1));
18
19 std::shared_ptr<game::core::Actor> actor2 = std::make_unique<game::core::Actor>(std::make_unique<game::core::SpriteAnimated>(std::make_shared<game::core::Texture2D>("assets/graphics/anim_sprite.png"), 80.0f, 80.0f, 1, 3, 50, 100, 300));
20 this->actors.insert(std::make_pair("actor2", actor2));
21}
22
24 // Your scene cleanup code here...
25}
26
28 // Your process input and update game scene code here...
29 if (IsKeyPressed(KEY_ESCAPE))
30 game::core::Store::stage->switchToNewScene("pause"s, std::make_unique<PauseScene>());
31}
32
34 // Your scene drawing code here...
35 // Note that scene-actors are drawn automatically
36 DrawText("This is the game scene - press ESCAPE for pause", 10, 10, 30, LIGHTGRAY);
37}
std::map< std::string, std::shared_ptr< game::core::Actor > > actors
Actors of the scene. The Actor objects of this map are drawn automatically by the Stage object if the...
Definition: scene.h:26
void Update() override
The Update() method is used to process input and update the game state. It is called automatically be...
Definition: game_scene.cpp:27
void Draw() override
The Draw() method can be used to output graphics. Note that the elements of the actor map are drawn a...
Definition: game_scene.cpp:33
static std::unique_ptr< game::core::Stage > stage
The Stage object is responsible for the scene change and for updating and drawing the scene contents.
Definition: store.h:16