31
31
#include " MoveCommand.h"
32
32
#include " ShootCommand.h"
33
33
#include " BulletsManager.h"
34
+ #include " Structs.h"
34
35
/*
35
36
#include "SDLSoundSystem.h"
36
37
#include "ServiceLocator.h"*/
@@ -43,70 +44,55 @@ static void CreateLevel1()
43
44
44
45
const auto font{ ResourceManager::GetInstance ().LoadFont (" Lingua.otf" , 15 ) };
45
46
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 );
49
50
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 );
53
54
54
- CharactersManager::GetInstance (). CreatePlayerCharacters (scene);
55
+ CharactersManager::GetInstance ()-> CreatePlayerCharacters (scene);
55
56
56
57
// TODO: pass <EnemyType, glm::vec2 spawnPosition>
57
- CharactersManager::GetInstance (). SpawnEnemies (scene);
58
+ // CharactersManager::GetInstance()->SpawnEnemy (scene);
58
59
BulletsManager::GetInstance ().SetScene (&scene);
59
60
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 );
62
63
scene.Add (pPlayer1ScoreDisplay);
63
64
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 );
66
67
scene.Add (pPlayer1HealthDisplay);
67
68
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);
70
71
scene.Add(pPlayer2ScoreDisplay);
71
72
72
73
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);*/
75
76
76
77
std::unique_ptr<Keyboard> keyboard = std::make_unique<Keyboard>();
77
78
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 ));
93
86
94
87
std::unique_ptr<Controller> controller = std::make_unique<Controller>();
95
88
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 ));
110
96
111
97
auto & input = InputManager::GetInstance ();
112
98
input.AddDevice (std::move (keyboard));
@@ -116,6 +102,9 @@ static void CreateLevel1()
116
102
117
103
ServiceLocator::GetSoundSystem()->AddSFX("../Data/sound.wav", 1);
118
104
ServiceLocator::GetSoundSystem()->Play(1, 30);*/
105
+
106
+
107
+ CharactersManager::GetInstance ()->StartLevel1 ();
119
108
}
120
109
121
110
void load ()
0 commit comments