Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


SteveHatcher

Member Since 27 Nov 2013
Offline Last Active Today, 12:44 PM

Topics I've Started

What is this stuff called in c++

26 April 2015 - 04:14 AM

I have been using entityx https://github.com/alecthomas/entityx as an ECS framework. I have been following the Examples and looking at some sample projects, and applying what they do to my own engine.

 

I realize now that I am doing a lot of stuff that I really have no idea whats going on behind the scenes. I also have no clue as to what this stuff is called in c++, so I am asking if you guys can give me a quick rundown on 'keywords' I should be looking up.

Firstly,

 

class Game : public entityx::Receiver<Game>

 

Now I would understand if this was class Game : public entityx::Receiver

 

as Game inheriting from Receiver class, but in this case they use the so called "Curiously recurring template pattern" of which I cant fully understand the Point?

 

Next,

 

m_systemManager.update<MovementSystem>(frameTime); <-- What is code like this called in c++?

 

Somehow this updates everything in my class MovementSystem : public entityx::System<MovementSystem> update function. The update function reads as so:

void update(entityx::EntityManager &entities, entityx::EventManager &events, double dt);

But I only need to pass in my time step (frameTime), so how does it get the other two parameters?

 

Similarly the first thing I do is add all the systems using

 

m_systemManager.add<RenderSystem>(&graphics, spriteTextures);

 

I am just wondering what I can read to understand what is going on behind the scenes.

 

Edit: One more thing I am not sure of, I see this code:

 

SplashViewCreator().create(); <-- What is code like this called in c++?

 

where SplashViewCreator is a class.

I have never seen a class initiated and used without an object of it first being created... e.g. I would expect

 

SplashViewCreator mySplashViewObject;

mySplashViewObject.create();

 

Are those two things equivalent?

 

Thanks for your time.


Can D3D 11 get the created d3d Device?

07 April 2015 - 06:40 AM

This might be a stupid question but...

 

In the very limited win32 programming I have seen, whenever you call a function that needs the created HWND, you can call GetActiveWindow().

 

Does direct 3d 11 have anything like this? Such that if I open a win 32 window, then initialize a d3dDevice, I can call something that gives me previously initialized device within that window?

 

Thanks


Factory, managers, interfaces for noobs?

06 April 2015 - 07:18 AM

Hi,

 

I have been looking through some source code of 'simple' game projects and I keep seeing these words pop up:

 

something Factory e.g AnimationFactory.

 

something that inherits from an interface e.g. class pickupBox : public ICreatable

 

something Manager e.g. GameManager

 

I have goggled these terms and find a lot of articles discussing quite specific cases, or explaining them in a way I cant understand. I really need an explanation that focuses on their purpose for game engine development.

 

Can someone please explain, or link to good simple articles, that explain what these things are, and why they are useful? For instance are they to do with OOP, or a general software engine architectural pattern?

 

Thanks for your time.


How to initialize a class member variable when using compositon?

22 March 2015 - 03:04 AM

I am struggling to understand a concept when using composition in c++. I have created a demo program to illustrate my confusion. The program might seem a bit pointless but its only purpose is to illustrate my question.

#include <iostream>
using namespace std;

class Shape
{
private:
    double width;
    double length;
    double area;

public:
    void init(int, int);
    double getArea() const
    {
        return area;
    }

};

class Rectangle : public Shape
{
private:
    
public:

};

void Shape::init(int wid, int hei)
{
    width = wid;
    length = hei;

    area = length * width;
}

class ShapeArea
{
private:
    Rectangle rectShape;
    int area;

public:
    ShapeArea()
    {
        area = rectShape.getArea();
    }
};

int main()
{
    Rectangle rectShape;
    rectShape.init(5, 5);
    
    ShapeArea newshape;

    getchar();
    return 0;
}

In this program I create a rectShape object, and initialize its width and length as 5, and the program calculates its area, and stores them all as member variables.

 

Now I have created a class called ShapeArea, and using composition given it Rectangle object called rectShape.

class ShapeArea
{
private:
    Rectangle rectShape;
    int area;

public:
    ShapeArea()
    {
        area = rectShape.getArea();
    }
};

In its constructor, I am allowed to call rectShape.getArea(), because getArea() is a member function of class Rectangle (derived from class Shape). The problem I am facing is that the rectShape object it is using to call this function is filled with random values in memory.

 

So my question is, in this design, how do I tell class ShapeArea that the rectShape Rectangle object I want to call the getArea() function of, is the one I have already created earlier in the program? Ideally I want the newshape object I create to have the value "25" as area.

I hope this question is clear.

 

Thanks


implementing entity component system in current engine...

24 February 2015 - 08:10 AM

Hi All,

 

Thanks to a lot of help from this forum I have gotten my 'game' to this stage:

 

https://www.youtube.com/watch?v=bmjTAEKMaD8

 

Its time to add some enemies and make a proper 'level'. This is where I have been stuck for a while now, because up until here it has been pretty straight forward. There seems to be only really one way to have a general game loop, and to draw some sprites to the screen (I am using directX TK).

 

So I have been reading about this so called entity component system and it sounds like the way to go from here. What I have absolutely no clue about is how to implement it into my current engine.

 

In order to test adding ECS to my engine I would like to add what I consider to be a simple example of it: Adding three different enemy types. Each type will appear on screen using a timer, each enemy will have a different color, and a different weapon. My ship too, will have different weapons, selectable with 1-3. Id like my ship and the enemy ships to have health, and weapons to deal different damage.

 

As it stands now all sprites are an instance of my sprite class, the particle system is its own class particleSys, collision detection is done using a rectangle class, where methods in the rectangle class generate the bounding boxes and then test them for intersection. The map draws from its MapRenderer::draw() method .Apart from that, my game does the usual

 

update()  handles input(), then each sprite updates() itself

collisions() 

render()

 

I am extremely confused from here:

 

What makes up the Entity, components and systems in this example? Are the Entitiys class PlayerShip{}, and class EnemyShip{}. Would their components be something like:

 

struct shipComponent

{

    int life;                //Everyone's health

    int projectile;  //Damage each projectile does

}

 

Do I keep my current code and then add this ECS system in, or does it require a rewrite of the game engine from scratch? Or can I mix and match sections?

 

I would greatly appreciate a point in the right direction of how to implement the so called ECS. I am the kind of person who learns a lot more from reading source code too, so any examples of it in place in a small scale game would be interesting to me too. I feel I have read every post on gamedev and S.E on this but really wont fully grasp whats going on until I get down and dirty in some code.

 

Thanks for your time.


PARTNERS