Tag Archives: DirectX

At the end of this week I can say game is almost finished!

Huzzah! Game as it should be is pretty much finished – well there is always something that can be added, improved or modified – but as far as I am considered  game should look like it looks atm.

Obviously, it needs final touches – tidying up GUI for instance.
and before handing it out I still need to improve zombies’ behavior, add some more animations, and most important implement behavior module into marines class.

but as I mentioned – I am pretty happy with what I have done.

Economic system is an interesting one.

We start with 500 coins, or whatever it is ;)
then every 10 seconds we add x into the pull – where x is defined by 5*number of houses – number of marines. – I was thinking a bit about that and it seems to be a reasonable solution.
as well Limit system has been added – into economics manager class – to avoid negative values for income and other issues. our population limit is 5 times number of houses – note: scv is excluded. Yes, I know it is a bit weird but lets say SCV is not a human ;P

yes I know I haven’t done much this week but in my defense – I am sick and on Saturday I was in Dundee – Games in Scotland – pretty awesome event where teams such as Veemee, Codeplay or Digital Goldfish were presenting what are they doing and who they are looking for in terms of employment.
Some photos below:




Content added

last week I have improved collision detection between zombies – now I am trying to implement one universal.
New animations added for marines – shooting and die.
Additional content – stone and tree,
tile set has been changed to nicer one,
behaviour manager implemented for zombies,
range added to marines,
different collision added for different types of entities,
live variable added to SCV, Marine, Zombie

Current issues I have is marines formation – not sure how to solve it yet.
When more than one marine is selected and destination location is selected – collision detection is not applied correctly. the can stand at the same place at the same time.

We can buy stuff!

Finally I have prototyped pouching units system – it uses messaging system, however I am having weird bug, when I am getting more marines animation for them is speeding up. I am wondering if it is caused by using pointer to the animation.. well it shouldn’t, should it? to be fair animation system was designed for animating single instance of the object but still.. it should be flexible enough to handle that.

I haven’t tested that on buildings yet… – memo added :)

the scenario is:
when single building is selected we can press “T” to train marines, atm. it is done instantly and target location for new “trained” unit is set to fixed location.

future improvements include:

  • developing training time
  • changeable spawn location
  • implement cost
  • as far as I am thinking about that game.. I need decent GUI!

there is loads to do.. argh.. damn you father time! why one day has only 24hrs?!

2D Zombieesh Continues

That was freaking remarkable week,

Meetings Meetings Meetings.

Apparently I have enough “clients” to open my own company. Yeah.. who could even thought about that? World is crazy.

anyway, this is not what post will be about.

What I want to show is today’s achievement. Zombeesh project :) – yes as you can see I have implemented sprites from Starcraft – still there is a lot to do – shadows, moving elements, etc but I need to create working prototype of a game in less than month.. and believe me it will be tough.. Group project, own company – planning, game development for xBox360 – yes on site We :) will be developing xBox game well I cannot tell much about it yet but nick name for a project is “Craft” – yeah I need work something better.. but that can wait. Back to the topic

  • I have managed to implement animations – but making them work is later issue.
  • GUI manager allows me to add text on a screen to any position – future development placing images and animations – can be shifted for later on.
  • SCV on a screen can build barracks in selected place, but to do that need to get there,
  • Small fix for approximation error has been placed – SCV wasn’t moving to exact place, if it is close enough it/he (?) stops.

This weekend’s development plan – allow barracks to train Marines/Ghosts

I can select you!


yeah this red triangle means – I am selected.. I will be working on sprites manager over the weekend..
At least.. I have managed to select sprites inside of box described by start point and end point – both defined by mouse click and release.

Class probably will be improved in the future but now.. welcome to AddToSelected method

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
void PlayerManager::addEntityToSelected(POINT mouseBoxStart, POINT mouseBoxEnd){

std::map::iterator iter = playersEntities.begin();
for(; iter != playersEntities.end(); ++iter)
{
if(mouseBoxStart.x> mouseBoxEnd.x)
{
mouseBoxStart.x +=mouseBoxEnd.x;
mouseBoxEnd.x = mouseBoxStart.x - mouseBoxEnd.x;
mouseBoxStart.x -= mouseBoxEnd.x;
}

if(mouseBoxStart.y> mouseBoxEnd.y)
{
mouseBoxStart.y +=mouseBoxEnd.y;
mouseBoxEnd.y = mouseBoxStart.y - mouseBoxEnd.y;
mouseBoxStart.y -= mouseBoxEnd.y;
}

bool collisionResult = false;

if(mouseBoxStart.x < = iter->second->getPosition().x && iter->second->getPosition().x < = mouseBoxEnd.x)
{
if(mouseBoxStart.y <= iter->second->getPosition().y && iter->second->getPosition().y < = mouseBoxEnd.y)
{
collisionResult = true;
}
}

//if point is inside square then add to selected

if(collisionResult == true)
{
playersSelectedEntities[iter->second->getID()] = iter->second;
}

}

}

idea of this method is to search player entities list.
let me explain

when program is adding new objects to the scene it is adding new entities. Entities can have tag/name simple if check at this stage can save a bit of CPU later on, when instead of searching through all entities on the map we are searching only list of players entities that are pointing to exact entity.

1
2
3
4
5
6
7
8
9
void PlayerManager::markSelected(ID3DXSprite* sprite){
std::map::iterator iter = playersSelectedEntities.begin();
for(; iter != playersSelectedEntities.end(); ++iter)
{
D3DXVECTOR3 deltaPosition = iter->second->getPosition() - LevelManager::getOffset();
sprite->Draw(texture, 0, 0, &deltaPosition, D3DCOLOR_XRGB(255,255,255));

}
}

markSelected method is the one that needs little bit more brain storming on. At the moment I am keeping it in PlayerManager class.. which in my opinion is little bit weird.. but in my defense.. we want to mark “Players” selected entities.. don’t we?

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.

LevelManager.h

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
#pragma once

#ifndef LEVELMANAGER_H
#define LEVELMANAGER_H

#include <map>
#include <d3dx9 .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

LevelManager.cpp

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
59
60
61
62
63
64
65
66
67
68
69
70
#include "LevelManager.h"

int LevelManager::currentLevelId=-1; //no level
LevelManager* LevelManager::instance =0;
std::map</int><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);

}