Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
Level02.cpp
Go to the documentation of this file.
1
2
3#include "Level02.h"
4#include "BioEnemyShip.h"
5
6
8{
9 // Setup enemy ships
10 Texture* pTexture = resourceManager.Load<Texture>("Textures\\BioEnemyShip.png");
11
12 const int COUNT = 22;
13
14 double xPositions[COUNT] =
15 {
16 0.25, 0.2, 0.3,
17 0.75, 0.8, 0.7,
18 0.3, 0.25, 0.35, 0.2, 0.4,
19 0.7, 0.75, 0.65, 0.8, 0.6,
20 0.5, 0.4, 0.6, 0.45, 0.55, .6
21 };
22
23 double delays[COUNT] =
24 {
25 0.0, 0.25, 0.25,
26 3.0, 0.25, 0.25,
27 3.25, 0.25, 0.25, 0.25, 0.25,
28 3.25, 0.25, 0.25, 0.25, 0.25,
29 3.5, 0.3, 0.3, 0.3, 0.3, 0.3
30 };
31
32 float delay = 3.0; // start delay
33 Vector2 position;
34
35 for (int i = 0; i < COUNT; i++)
36 {
37 delay += delays[i];
38 position.Set(xPositions[i] * Game::GetScreenWidth(), -pTexture->GetCenter().Y);
39
40 BioEnemyShip* pEnemy = new BioEnemyShip();
41 pEnemy->SetTexture(pTexture);
42 pEnemy->SetCurrentLevel(this);
43 pEnemy->Initialize(position, (float)delay);
44 AddGameObject(pEnemy);
45 }
46
47 Level::LoadContent(resourceManager);
48}
49
Represents an enemy ship that is biological in nature.
Definition BioEnemyShip.h:8
virtual void SetTexture(Texture *pTexture)
Sets the texture that will be used to render the enemy ship.
virtual void Initialize(const Vector2 position, const double delaySeconds)
Initializes the enemy ship.
Definition EnemyShip.cpp:34
static void SetCurrentLevel(Level *pLevel)
Set the current level.
Definition GameObject.h:26
static int GetScreenWidth()
Gets the screen width in pixels.
Definition Game.h:36
Loads and manages the lifespan of objects from external files.
T * Load(const std::string &path, const bool cache=true, const bool appendContentPath=true)
Load and manage a resource.
Represents a 2D grid of texels.
Definition Texture.h:21
Vector2 GetCenter() const
Gets the center position of the texture.
Definition Texture.h:48
Defines a vector with 2 components (x and y).
Definition Vector2.h:21
float Y
The y-coordinate of the vector.
Definition Vector2.h:187
void Set(const float x, const float y)
Sets the components of the vector.
Definition Vector2.h:49
virtual void LoadContent(ResourceManager &resourceManager)
Load the content for the level, including game objects and resources.
Definition Level02.cpp:7
virtual void AddGameObject(GameObject *pGameObject)
Add a game object to the level. This object will be updated, rendered, and checked for collisions.
Definition Level.h:46
virtual void LoadContent(ResourceManager &resourceManager)
Load the content for the level, including game objects and resources.
Definition Level.cpp:88