-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce scenes, editor instructions
- Loading branch information
Showing
13 changed files
with
152 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "scenes/Scene.h" | ||
|
||
class EditorScene : public Scene { | ||
|
||
public: | ||
EditorScene(SDL_Window* window); | ||
|
||
private: | ||
void update() override; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "scenes/Scene.h" | ||
|
||
class GameScene : public Scene { | ||
|
||
public: | ||
GameScene(SDL_Window* window); | ||
|
||
private: | ||
void update() override; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include "systems/EditorSystem.h" | ||
#include "systems/RenderSystem.h" | ||
#include "systems/EditorSystem.h" | ||
#include "systems/PhysicsSystem.h" | ||
#include "systems/CallbackSystem.h" | ||
#include "systems/EnemySystem.h" | ||
#include "systems/TileSystem.h" | ||
#include "systems/MapSystem.h" | ||
#include "systems/AnimationSystem.h" | ||
#include "systems/PlayerSystem.h" | ||
#include "systems/SoundSystem.h" | ||
#include "systems/ScoreSystem.h" | ||
#include "Constants.h" | ||
|
||
class Scene { | ||
protected: | ||
World* world; | ||
|
||
public: | ||
|
||
virtual void update() {}; | ||
virtual void handleEvents(SDL_Event& event) { | ||
world->handleEvent(event); | ||
}; | ||
|
||
virtual ~Scene() { | ||
std::cout << "Scene deleted" << std::endl; | ||
delete world; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "scenes/EditorScene.h" | ||
|
||
EditorScene::EditorScene(SDL_Window* window) { | ||
world = new World(); | ||
world->registerSystem(new RenderSystem(window, SNES_RESOLUTION_WIDTH, SNES_RESOLUTION_HEIGHT)); | ||
world->registerSystem(new EditorSystem()); | ||
world->registerSystem(new TileSystem()); | ||
world->registerSystem(new PhysicsSystem()); | ||
|
||
|
||
//FIRST COLUMN (left aligned) | ||
auto title = world->create(); | ||
title->assign<TextComponent>("MAP EDITOR MODE"); | ||
title->assign<TransformComponent>(10, 10, 60, 8); | ||
|
||
auto instructions1 = world->create(); | ||
instructions1->assign<TextComponent>("up down keys change tiles"); | ||
instructions1->assign<TransformComponent>(10, 20, 80, 5); | ||
|
||
auto instructions2 = world->create(); | ||
instructions2->assign<TextComponent>("press keys a and d to pan camera"); | ||
instructions2->assign<TransformComponent>(10, 26, 90, 5); | ||
|
||
auto instructions3 = world->create(); | ||
instructions3->assign<TextComponent>("press s to save the map to disk"); | ||
instructions3->assign<TransformComponent>(10, 32, 86, 5); | ||
|
||
auto instructions4 = world->create(); | ||
instructions4->assign<TextComponent>("click to add and remove tiles"); | ||
instructions4->assign<TransformComponent>(10, 38, 80, 5); | ||
|
||
auto instructions5 = world->create(); | ||
instructions5->assign<TextComponent>("press e to exit the editor"); | ||
instructions5->assign<TransformComponent>(10, 44, 80, 5); | ||
} | ||
|
||
void EditorScene::update() { | ||
Scene::update(); | ||
world->tick(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "scenes/GameScene.h" | ||
|
||
GameScene::GameScene(SDL_Window* window) { | ||
world = new World(); | ||
world->registerSystem(new SoundSystem()); | ||
world->registerSystem(new RenderSystem(window, SNES_RESOLUTION_WIDTH, SNES_RESOLUTION_HEIGHT)); | ||
world->registerSystem(new PlayerSystem([](){})); | ||
world->registerSystem(new MapSystem()); | ||
world->registerSystem(new EnemySystem()); | ||
world->registerSystem(new CallbackSystem()); | ||
world->registerSystem(new AnimationSystem()); | ||
world->registerSystem(new ScoreSystem()); | ||
world->registerSystem(new TileSystem()); | ||
world->registerSystem(new PhysicsSystem()); | ||
} | ||
|
||
void GameScene::update() { | ||
Scene::update(); | ||
world->tick(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters