Skip to content

Commit 7977e42

Browse files
committed
removed unused commands
1 parent 91953f4 commit 7977e42

File tree

1 file changed

+34
-45
lines changed

1 file changed

+34
-45
lines changed

Galaga/Main.cpp

+34-45
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "MoveCommand.h"
3232
#include "ShootCommand.h"
3333
#include "BulletsManager.h"
34+
#include "Structs.h"
3435
/*
3536
#include "SDLSoundSystem.h"
3637
#include "ServiceLocator.h"*/
@@ -43,70 +44,55 @@ static void CreateLevel1()
4344

4445
const auto font{ ResourceManager::GetInstance().LoadFont("Lingua.otf", 15) };
4546

46-
std::shared_ptr<GameObject> pMovementInfo{ std::make_shared<GameObject>(10.0f, 20.0f) };
47-
pMovementInfo->AddComponent<Text>("Movement: Keyboard - WASD / Controller - DPAD", font);
48-
scene.Add(pMovementInfo);
47+
std::shared_ptr<GameObject> pBackground{ std::make_shared<GameObject>(SCREEN_SIZE / 2.0f) };
48+
pBackground->AddComponent<Sprite>("bg.png");
49+
scene.Add(pBackground);
4950

50-
std::shared_ptr<GameObject> pActionsInfo{ std::make_shared<GameObject>(10.0f, 40.0f) };
51-
pActionsInfo->AddComponent<Text>("Kill Enemy: Keyboard - T / Controller - B Kill Self: Keyboard - R / Controller - Y", font);
52-
scene.Add(pActionsInfo);
51+
std::shared_ptr<GameObject> pCharactersManager{ std::make_shared<GameObject>(0.0f, 0.0f) };
52+
pCharactersManager->AddComponent<CharactersManager>();
53+
scene.Add(pCharactersManager);
5354

54-
CharactersManager::GetInstance().CreatePlayerCharacters(scene);
55+
CharactersManager::GetInstance()->CreatePlayerCharacters(scene);
5556

5657
// TODO: pass <EnemyType, glm::vec2 spawnPosition>
57-
CharactersManager::GetInstance().SpawnEnemies(scene);
58+
//CharactersManager::GetInstance()->SpawnEnemy(scene);
5859
BulletsManager::GetInstance().SetScene(&scene);
5960

60-
std::shared_ptr<GameObject> pPlayer1ScoreDisplay{ std::make_shared<GameObject>(40.0f, 80.0f) };
61-
pPlayer1ScoreDisplay->AddComponent<ScoreComponent>(1, "Lingua.otf", 15);
61+
std::shared_ptr<GameObject> pPlayer1ScoreDisplay{ std::make_shared<GameObject>(20.0f, 20.0f) };
62+
pPlayer1ScoreDisplay->AddComponent<ScoreComponent>(0, "emulogic.ttf", 15);
6263
scene.Add(pPlayer1ScoreDisplay);
6364

64-
std::shared_ptr<GameObject> pPlayer1HealthDisplay{ std::make_shared<GameObject>(40.0f, 95.0f) };
65-
pPlayer1HealthDisplay->AddComponent<HealthDisplayComponent>(1, "Lingua.otf", 15);
65+
std::shared_ptr<GameObject> pPlayer1HealthDisplay{ std::make_shared<GameObject>(30.0f, SCREEN_SIZE.y - 30.0f) };
66+
pPlayer1HealthDisplay->AddComponent<HealthDisplayComponent>(0);
6667
scene.Add(pPlayer1HealthDisplay);
6768

68-
std::shared_ptr<GameObject> pPlayer2ScoreDisplay{ std::make_shared<GameObject>(40.0f, 110.0f) };
69-
pPlayer2ScoreDisplay->AddComponent<ScoreComponent>(2, "Lingua.otf", 15);
69+
/*std::shared_ptr<GameObject> pPlayer2ScoreDisplay{ std::make_shared<GameObject>(40.0f, 110.0f) };
70+
pPlayer2ScoreDisplay->AddComponent<ScoreComponent>(1, "Lingua.otf", 15);
7071
scene.Add(pPlayer2ScoreDisplay);
7172
7273
std::shared_ptr<GameObject> pPlayer2HealthDisplay{ std::make_shared<GameObject>(40.0f, 125.0f) };
73-
pPlayer2HealthDisplay->AddComponent<HealthDisplayComponent>(2, "Lingua.otf", 15);
74-
scene.Add(pPlayer2HealthDisplay);
74+
pPlayer2HealthDisplay->AddComponent<HealthDisplayComponent>(1, "Lingua.otf", 15);
75+
scene.Add(pPlayer2HealthDisplay);*/
7576

7677
std::unique_ptr<Keyboard> keyboard = std::make_unique<Keyboard>();
7778

78-
KeyboardInput k_up{ SDL_SCANCODE_W, InputState::Previous };
79-
KeyboardInput k_left{ SDL_SCANCODE_A, InputState::Previous };
80-
KeyboardInput k_down{ SDL_SCANCODE_S, InputState::Previous };
81-
KeyboardInput k_right{ SDL_SCANCODE_D, InputState::Previous };
82-
KeyboardInput k_R{ SDL_SCANCODE_R, InputState::Released };
83-
KeyboardInput k_T{ SDL_SCANCODE_T, InputState::Released };
84-
KeyboardInput k_Space{ SDL_SCANCODE_SPACE, InputState::Released };
85-
86-
keyboard->AddCommand(k_up, std::make_unique<MoveCommand>(1, glm::vec2(0.0f, -1.0f), 120.0f));
87-
keyboard->AddCommand(k_left, std::make_unique<MoveCommand>(1, glm::vec2(-1.0f, 0.0f), 120.0f));
88-
keyboard->AddCommand(k_down, std::make_unique<MoveCommand>(1, glm::vec2(0.0f, 1.0f), 120.0f));
89-
keyboard->AddCommand(k_right, std::make_unique<MoveCommand>(1, glm::vec2(1.0f, 0.0f), 120.0f));
90-
keyboard->AddCommand(k_R, std::make_unique<SuicideCommand>(1));
91-
//keyboard->AddCommand(k_T, std::make_unique<KillEnemyCommand>(1));
92-
keyboard->AddCommand(k_Space, std::make_unique<ShootCommand>(1));
79+
KeyboardInput k_left{ SDL_SCANCODE_A, InputState::Held };
80+
KeyboardInput k_right{ SDL_SCANCODE_D, InputState::Held };
81+
KeyboardInput k_Space{ SDL_SCANCODE_SPACE, InputState::Held };
82+
83+
keyboard->AddCommand(k_left, std::make_unique<MoveCommand>(0, glm::vec2(-1.0f, 0.0f), 200.0f));
84+
keyboard->AddCommand(k_right, std::make_unique<MoveCommand>(0, glm::vec2(1.0f, 0.0f), 200.0f));
85+
keyboard->AddCommand(k_Space, std::make_unique<ShootCommand>(0));
9386

9487
std::unique_ptr<Controller> controller = std::make_unique<Controller>();
9588

96-
ControllerInput up{ Button::XINPUT_GAMEPAD_DRAD_UP, InputState::Previous };
97-
ControllerInput left{ Button::XINPUT_GAMEPAD_DRAD_LEFT, InputState::Previous };
98-
ControllerInput down{ Button::XINPUT_GAMEPAD_DRAD_DOWN, InputState::Previous };
99-
ControllerInput right{ Button::XINPUT_GAMEPAD_DRAD_RIGHT, InputState::Previous };
100-
ControllerInput Y{ Button::XINPUT_CONTROLLER_Y, InputState::Released };
101-
ControllerInput B{ Button::XINPUT_CONTROLLER_B, InputState::Released };
102-
103-
controller->AddCommand(up, std::make_unique<MoveCommand>(2, glm::vec2(0.0f, -1.0f), 100.0f));
104-
controller->AddCommand(left, std::make_unique<MoveCommand>(2, glm::vec2(-1.0f, 0.0f), 100.0f));
105-
controller->AddCommand(down, std::make_unique<MoveCommand>(2, glm::vec2(0.0f, 1.0f), 100.0f));
106-
controller->AddCommand(right, std::make_unique<MoveCommand>(2, glm::vec2(1.0f, 0.0f), 100.0f));
107-
controller->AddCommand(Y, std::make_unique<SuicideCommand>(2));
108-
//controller->AddCommand(B, std::make_unique<KillEnemyCommand>(2));
109-
controller->AddCommand(B, std::make_unique<ShootCommand>(2));
89+
ControllerInput left{ Button::XINPUT_GAMEPAD_DRAD_LEFT, InputState::Held };
90+
ControllerInput right{ Button::XINPUT_GAMEPAD_DRAD_RIGHT, InputState::Held };
91+
ControllerInput B{ Button::XINPUT_CONTROLLER_B, InputState::Held };
92+
93+
controller->AddCommand(left, std::make_unique<MoveCommand>(1, glm::vec2(-1.0f, 0.0f), 200.0f));
94+
controller->AddCommand(right, std::make_unique<MoveCommand>(1, glm::vec2(1.0f, 0.0f), 200.0f));
95+
controller->AddCommand(B, std::make_unique<ShootCommand>(1));
11096

11197
auto& input = InputManager::GetInstance();
11298
input.AddDevice(std::move(keyboard));
@@ -116,6 +102,9 @@ static void CreateLevel1()
116102
117103
ServiceLocator::GetSoundSystem()->AddSFX("../Data/sound.wav", 1);
118104
ServiceLocator::GetSoundSystem()->Play(1, 30);*/
105+
106+
107+
CharactersManager::GetInstance()->StartLevel1();
119108
}
120109

121110
void load()

0 commit comments

Comments
 (0)