MosHiBi
P
31
Skara
Hjälte
4 994 inlägg
Trådskapare
2012-10-22 22:52
Svar till Splux [
Gå till post]:
Jo jag trodde de skull fungera med, men antingen gör jag fel. Eller så fungerar det inte. Kan posta koden.
Entity.h Basklassen
Visa spoiler
[code:c++]
#ifndef INCLUDED_ENTITY
#define INCLUDED_ENTITY
#include "VGCVirtualGameConsole.h"
#include <vector>
#include <string>
#include <sstream>
class Entity{
public:
typedef std::vector<Entity*> EntityVector;
EntityVector entities;
Entity();
virtual ~Entity();
virtual bool isAlive() = 0;
virtual void render(Layer layer) = 0;
};
#endif
[/code]
Bullet.h
Visa spoiler
[code:c++]
#ifndef INCLUDED_BULLET
#define INCLUDED_BULLET
#include "Entity.h"
class Bullet : public Entity{
public:
Bullet(Category, const VGCVector &position;, const VGCVector &diretion;);
virtual ~Bullet();
[/code]
Invader.cpp(subklass som för fiendens skepp)
Visa spoiler
[code:c++]
void Invader::fire(EntityVector &entities;){
if(VGCClock::isExpired(mReloadTimer)){
const VGCVector direction(0, 1);
entities.push_back(new Bullet(ENEMY, mPosition, direction));
VGCClock::reset(mReloadTimer);
}
}
[/code]
Tror detta är all den beröda koden.
one by one the penguins steal my sanity