1+ #include " TutorialCore.h"
2+ #include " ../Constants.h"
3+ #include " ../Sprites/ScaledSpriteArray.h"
4+ #include < Engine/Input.h>
5+ #include < Engine/InputEvents.h>
6+ #include < Engine/Renderer.h>
7+
8+ /* *
9+ * @brief Loads all variables and sprites for this scene
10+ * @details Initialises all variables and creates all the new
11+ sprites for the scene
12+ */
13+ bool TutorialCore::load (ASGE::Renderer* renderer, ASGE::Input* input, SoLoud::Soloud& player)
14+ {
15+ renderer->setClearColour (ASGE::COLOURS::BLACK);
16+
17+ // Share the renderer
18+ rend = renderer;
19+
20+ // Load tutorial slides
21+ tutorial_slides = new ScaledSpriteArray (tutorial_slide_count);
22+ for (int i = 0 ; i < tutorial_slide_count; i++)
23+ {
24+ ASGE::Sprite* slide = renderer->createRawSprite ();
25+ slide->loadTexture (" data/UI/TUTORIAL/" + localiser.getLanguage () + " /" + std::to_string (i) +
26+ " .jpg" );
27+ tutorial_slides->addSprite (*slide);
28+ }
29+ tutorial_slides->scale (0 .6666f );
30+ tutorial_slides->xPos (1 );
31+ tutorial_slides->yPos (-17 );
32+ tutorial_slides->setCurrentSprite (tutorial_index);
33+
34+ return true ;
35+ }
36+
37+ /* *
38+ * @brief Changes game state based on inputs
39+ * @details Is called for every input event and will change
40+ * @details the game state / variables etc depending
41+ * @param data is the event
42+ */
43+ void TutorialCore::keyHandler (const ASGE::SharedEventData data)
44+ {
45+ user_input.registerEvent (static_cast <const ASGE::KeyEvent*>(data.get ()));
46+ if (user_input.keyReleased (" Activate" ))
47+ {
48+ // Increment tutorial slides
49+ tutorial_index++;
50+ if (tutorial_index <= tutorial_slide_count)
51+ {
52+ tutorial_slides->setCurrentSprite (tutorial_index);
53+ }
54+ }
55+ }
56+
57+ /* *
58+ * @brief Changes game state based on mouse inputs
59+ * @details Is called for every input event and will change
60+ * the game state / variables etc depending
61+ * @param data is the event, mouse_position the position of the cursor
62+ */
63+ void TutorialCore::mouseHandler (const ASGE::SharedEventData data, Point mouse_position) {}
64+
65+ /* *
66+ * @brief Updates all variables for this scene
67+ * @details Runs every frame and handles all the logic and updates
68+ * of the active scene
69+ * @param delta_time is time since last update
70+ * @return number of the scene to switch to, -1 no change, -2 exit game
71+ */
72+ scenes TutorialCore::update (double delta_time)
73+ {
74+ // Return to main menu when tutorial is over
75+ if (tutorial_index >= tutorial_slide_count)
76+ {
77+ next_scene = scenes::TUTORIAL_MENU;
78+ }
79+ return next_scene;
80+ }
81+
82+ /* *
83+ * @brief Renders all sprites for this scene
84+ * @details Runs every frame and draws all the sprites in
85+ * order
86+ */
87+ void TutorialCore::render (double delta_time)
88+ {
89+ // Render current tutorial slide
90+ rend->renderSprite (tutorial_slides->returnCurrentSprite ());
91+ }
0 commit comments