Zombeesh back in 2D

After lately chat with my tutor I have to move back to 2D based game. – time pressure and general overloading forced me to make this decision.
GDD must be finished by tomorrow – but shall not fear! I have some resources. I will borrow units tile set from star craft – come on zombies looks almost like infected marine

as well as terrain tiles – provided by Maniak – thanks man!

I am improving level manager so I will be able to deal with offsets and a stuff.. as far as now I have prototype and hopefully it will be ready in next couple hours.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// LevelManager.h
 
#pragma once
 
#ifndef LEVELMANAGER_H
#define LEVELMANAGER_H
 
[...]
#include "Level.h"
 
class LevelManager
{
private:
  //list of maps
  static std::map<int , Level*> levels;
  static int currentLevelId;	
public:
  static LevelManager* instance;
  static void init();
  static void loadLevel(Level* level); // load level
  static void unloadLevel(Level* level); 
  static void registerLevel(Level* level); //add level to levels pool
  static Level* getLevel(int id) ;
  static D3DXVECTOR3 getOffset(); //gets offset off current map;
 
  LevelManager();
  ~LevelManager();
};
#endif
</int>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// LevelManager.cpp
#include "LevelManager.h"
 
int LevelManager::currentLevelId=-1; //no level
LevelManager* LevelManager::instance =0;
std::map<int , Level*> LevelManager::levels = std::map</int><int , Level*>();
 
LevelManager::LevelManager(){}
 
void LevelManager::init(){
  LevelManager::instance = new LevelManager();
}
 
LevelManager::~LevelManager(){
  if(!levels.empty()){
    std::map</int><int ,Level*>::iterator iter = levels.begin();
    for(; iter != levels.end(); ++iter){
      delete iter->second;
      iter->second = 0;
    }
    levels.clear();
  }
}
 
void LevelManager::loadLevel(Level* level){
  registerLevel(level);
  LevelManager::currentLevelId = levels.size();
}
 
void LevelManager::unloadLevel(Level* level){
  std::map</int><int , Level*>::iterator iter = levels.find(level->getId());
  if(iter != levels.end())
    levels.erase(iter);
}
 
void LevelManager::registerLevel(Level* level){
  //get size of current levels list and increment by one
  int size = levels.size() + 1;
  levels[size]= level;
  level->setId(size);
}
 
//ok do I need to register all entitys into level? - I guess I do. need to double check that with Kevin
Level* LevelManager::getLevel(int id){
  std::map</int><int , Level*>::iterator iter = levels.find(id);
  if(iter != levels.end()){
    return iter->second;
  }
  return 0;
}
 
D3DXVECTOR3 LevelManager::getOffset(){
  std::map</int><int , Level*>::iterator iter = levels.find(currentLevelId);
  if(iter != levels.end())
    return iter->second->getOffset();
  return D3DXVECTOR3(0,0,0);
}
</int>

Leave a Reply

Your email address will not be published. Required fields are marked *