Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 May 2011
Offline Last Active Yesterday, 08:35 AM

#5194383 Entity Component System - Accessing Components

Posted by AlanSmithee on 24 November 2014 - 05:18 AM

Since you do not describe how you are defining and using your components (other then that they are accessed through a method), it is hard to give any direct advice as how to store and access them.


There are many forms of entity-compoennt systems - some where an entity an object with a list of components and others where an entity is just a an id and the components are stored in seperat lists and accessed through that entity id.


I am personally using an approach based on the latter (where an entyity is represented by an id) since I like the simplicity and performance of that method,

I also think its very readable, but it can be a bit hard to wrap your head around initially if you are more used to the object oriented style of programming.


I started out by following some great articles here on gamedev:






Have a look and see if that is something you could use maybe.

#5194307 Problem with perspective in opengl

Posted by AlanSmithee on 23 November 2014 - 01:57 PM



I was passing GL_CW instead of GL_CCW to glFrontFace()... it works fine now!


I can also tell that when i thought i was rendering it correctly (using inverse of aspect ration) it was acutally rendering it from behind, which I guess is why glFrontFace(GL_CW) worked.


Thanks a lot!


(for any future reader having this problem, these are the flags I set to get the model to render properly)



#5126717 SDL_CreateTextureFromSurface issue

Posted by AlanSmithee on 27 January 2014 - 07:43 AM



Maybe you are confused by my code, i declared load_imge to return a bool, which mas a typo, it should return a Image object and the loader class should be separate from any other class.


An example:



class Window
    SDL_Renderer* get_renderer() { return _renderer; }
    SDL_Renderer* _renderer;


class ImageLoader
    Image const& load_image(SDL_Renderer*, std::string const&);


  Window window;
  ImageLoader imageLoader;
  Image image;
  image = imageLoader.load_image(window.get_renderer(), "foo.png");
  if (image == nullptr)
    std::cerr << "Could not load image" << std::endl;

Or something like that, sorry for any confusion i might have caused.

#5126296 Can someone help me think of a creative name for my puzzle/tower defense game?

Posted by AlanSmithee on 25 January 2014 - 05:34 AM

First of all, I agree with jbadams that it's a nice concept you have for your game!


There are some tower defence games out there that have pretty generic names, but I still remember them of the top of my head, like desktop tower defence, bloons tower defence. These games are just regular tower defence games though. You probably want a name that captures the spirit of combination of "match 3" with tower defence.


I dont have any concrete names for you, but a method that can help you come up with your own name is to write down words that represents each genre in two columns and then try different combinations and variants. You can use more columns if you want to incorporate more names, like your business name etc.


Good luck.

#5125113 Is HTML5 a legit language for developing game?

Posted by AlanSmithee on 20 January 2014 - 12:50 PM



Developing games in HTML5 has a lot of advantages over other environments/frameworks/languages, such as platform independant distribution (the browser is the patform) and no downloads required to play the game etc.


The things that I found to be bothersome is that there are some things that you, as a developer, cannot take full control over, such as mouse lock and fullscreen mode etc. There are API's for this, but as far as I have been able to discern, they do not quite simulate the same behavior as native applications, as far as control is concerned.


I guess it depends on what kind of a game you want to develop.. I have found that HTML5 games (or browser games in general) are more accessible - just navigate to the URL of the game, but at the same time it is just as easy to stop playing - there is no "investment" in playing the game.. which would probably affect how the game is played.. (favors shorter playing sessions etc)


PS. HTML5 is a collection of techniques in HTML, CSS and JavaScript, and not a language

#5125051 Help

Posted by AlanSmithee on 20 January 2014 - 08:32 AM

I agree with wath BitMaster said.


It should also be said that it is possible to design and create games without much programming at all, using an engine or software such as Unity or GameMaker.

Haing said that, personally I would do pretty much as what BitMaster suggested.

#5125008 sandbox openworld survival game *to quest or not to quest

Posted by AlanSmithee on 20 January 2014 - 04:52 AM



I don't have a good answer to your specific questions, but one "rule" that I think goes a long way in game design is that "doing one thing really well is always better than doing many things half-assed". This is true for many popular games that builds around a simple concept and delivers really well within that concept.

#5124426 Is using Java a good way to create a game?

Posted by AlanSmithee on 17 January 2014 - 10:44 AM


Java is fine as any other language to make your first game, but a RPG game isn't in my opinion.

That's a rather particular genre that this general purpose language can't seem to handle correctly. Why do you think so?



He was probably referring to the "make your first game" and not the coding language ^^ (as in a RPG might not be the best genre to try as your first language) I don't have any opinions on that though.


Edit* Maybe you were just making a joke boogyman.. Wouldn't be the first (or last) time sarcasm got the best of me over the internetz lol

#5122593 Component based game and component communication

Posted by AlanSmithee on 10 January 2014 - 07:49 AM



Im not sure of how your current setup is working, and what a "subsystem" is, but in general a system should act on an entity with one or more component.

For instance, the MovementSystem could move an entity that has a displacement and velocitty component, the RenderSystem could render an entity that has a displacement and appearance component etc. This way the system needs to know about certain components, but the components does not need to know about each other.


Look here: http://www.gamedev.net/page/resources/_/technical/game-programming/implementing-component-entity-systems-r3382


In some cases I guess components will need to know about each other, I do not have that need yet, so I can not offer you a good answer.

I do however think you should implement some sort of messaging system.


Look here: http://www.gamedev.net/page/resources/_/technical/game-programming/case-study-bomberman-mechanics-in-an-entity-component-system-r3159


Good luck =)

#5122227 "Proper" state management for CBE

Posted by AlanSmithee on 08 January 2014 - 02:09 PM

Hello there!


I too have had my share of problems implementing a finite state machine.

I have found the very last answer in this thread (the post from Henrique Barcelos) to be a very good starting point.

It is easy to understand and the implementation is very generic.


Good luck!


*EDIT: I guess I didn't really answer your question..


First of all I agree with phil_t that you should try to keep your components more generic in general.

If you do follow the example that I posted a link too, I think a good idea would be to put the system parts of the ECS in the machine and component parts in the states.


Something like this psuedo code..

// In machine.cpp

void Machine::on_render()
// In some state.. lets say play-state.cpp
void PlayState::on_render(Machine& machine)

..where _renderSystem is a local RenderSystem in machine and _world is a local container of components (enteties)

#5121874 Multiple constructors for Animation class has duplicated code. How to fix cod...

Posted by AlanSmithee on 07 January 2014 - 04:50 AM

Yes, a call to another constructor must always be on the first line, forgot to mention that, sorry.

#5121773 Multiple constructors for Animation class has duplicated code. How to fix cod...

Posted by AlanSmithee on 06 January 2014 - 06:05 PM

Java and C# are verly much alike in syntax..


Just a minor change from what ferrous said

public class A
  private int a;
  private String s;

  public A()

  public A(int a)
    this(a, "something");

  public A(int a, String s)
    this.a = a;
    this.s = s;

(A not so useful example, but you get it the just of it, I hope)


The constructors are differentiated by their signature (arguments) so you should be able to cascade the constructor calls in a nice way to suit your needs. The general rule of thumb is to chain from fewest arguments to most arguments.


In java,there is also a thing called "variable length argument lists" http://www.deitel.com/articles/java_tutorials/20060106/VariableLengthArgumentLists.html, it might be something that you can have use of in some situation...

#5119946 Help for beginner in creating games but experienced in programming

Posted by AlanSmithee on 29 December 2013 - 09:01 PM



What a game engine provides you with is the very core functionality of a game. Such as the loop(s) that the game exists and runs in, the rendering pipeline, input handling, windowing handling, sound/gfx/model loading etc.


Wheter you decide to write this engine yourself, or use an existing one, is up to you, but there is no "not using an engine" since you will, by the very definition of it, actually build one when making a game... (unless you use an already existing one that is).


On the subject of limitations and features of a specific game engine, sure not one engine provides every feature, but there are some very competent and complete engines out there that provides you with more than enough functionality. The problem is often that one does not know how to use what the engine provides.


Wheter you should use an existing engine or write one yourself is up to you;

If you are after the experience of building an engine and learning low level graphics programming, extension handling etc, then go ahead and start learning openGL or directX but be ready to spend a lot of time before you will see anything that even resembles a game.

If you want to build a game (like AI, level design, content creation, story etc) then I would strongly suggest using an already existing engine.


Unity3d is good to start out with, it is very intuetive, there is a free option, you can script in javascript and C# and there are lots of online resources/tutorials to get you started.. It has a very fast development cycle that lets you see results quick.. Wich is why Blizzard used it for the game Hearthstone


Good luck

#5119518 Does anyone try to Break their Game?

Posted by AlanSmithee on 27 December 2013 - 11:16 AM

Yes, of course.


Even though I write unit tests according to TDD (test driven development) most of the time and run regression tests when new features are introduced, there are lots of functionality (and non functional requirements) that are hard (or impossible) to test automatically. There are also cases where it is possible, but preferable to test by exploratory testing. Almost all "ility" requirements, such as usability, availability, operability, stability etc. are best tested using exploratory testing, and exploratory testing done right means trying to break your application any way you can think of (and not think of by performing random actions).


One lecture that I find very motivating and interesting on the the topic of exploratory testing, and "testing to break" is this one by James Bach:  https://www.youtube.com/watch?v=ILkT_HV9DVU


It is not about testing games in specific, but rather about testing in general. He knows what he is talking about when it comes to testing and he is fun to listen to, even if he comes across as a bit odd at times.. xD

#5116550 Grade me?

Posted by AlanSmithee on 12 December 2013 - 03:30 PM

I appreciate your feedback.  I'd assume using if statements would solve that, but I haven't made it that far yet.  I worked with them a bit in JavaScript when I took web programming a bit ago.


I'm not sure yet what the C# equivalent of NaN is but I'd go with using

if (variable = NaN)
    Console.WriteLine("Not a number.");

or something in that ballpark.  That's all stuff I've barely seen in action though.


Again, I really, truly appreciate the feedback!


Not sure if that was just an example, orif you actually use that code snippet, but if you do, be sure too use "equal to" == instead of "assign operator" =.


leftHandValue == rightHandValue "is the left had value equal to the right hand value?"

leftHandValue = rightHandValue "assign the right hand value to the left hand value"


you probably know this, but just to make it clear.