Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Jun 2001
Offline Last Active Yesterday, 09:33 PM

#5269879 Time button is pressed

Posted by BeerNutts on 07 January 2016 - 12:44 PM

You're going to have to provide more detail.  Are you writing a program?  If so, what language?  Are you using any external libraries to handle input? Details, please.

#5266841 Event Handling within an ECS

Posted by BeerNutts on 17 December 2015 - 05:50 PM

A solution I've done before is t simply have a Collision Component added to entities that are colliding.  This component has which other entity is being collided with, and has a flag noting whether it's an initial collision, a sustain collision, or a just separated collision.  You can then have your collision system operate on entities with collision components, and call the functions required when collisions happen.


Just another way of doing things, not the right way, or the only way, just another possibility.

#5266448 [Help] How to create a game like original gangstaz

Posted by BeerNutts on 15 December 2015 - 07:02 AM

Peke, you better start from the bottom, and not worry about making your Gangstaz type game until you have a better grasp of what making games are all about.  I'd suggest you start with Unity and search for some tutorials to get you started, maybe even with some C# tutorials to start with.  Once you have a better understanding of what it takes to make a game, then you can look towards making specific games.


Good luck and have fun!

#5266280 Question about creating a replay system

Posted by BeerNutts on 14 December 2015 - 09:43 AM

I created a replay system that, every update frame, simply recorded the locations of all the graphical objects in the game screen as well as when sounds were played and saved it to a file.  This is much simpler than recording inputs and trying to make it deterministic, and it's much smaller than taking a screenshot every frame.  You can still do the replays form different angles as Sean was mentioned as well.


It worked great for a game I made years ago, I don't know why it won't work for you.

#5265374 entity system implementation

Posted by BeerNutts on 07 December 2015 - 08:35 PM


And, FWIW, the "MAX_ENTITY" value can be really bad if you can have thousands of entities in a game;  the harm may out weigh the benefits.  If you're in the hundreds, maybe it's OK, but it's still not the way I'd do it.

While it's not the way I'd implement it either, what harm are you referring to? It's a known constant memory cost, with known limitations.
I'd consider it (or the use of vectors) as the most simple and straitforward way of doing it, with more complex ways available if you have more intricate needs.
(for example, the way described above is fast, but there's potentially an even faster way)


For every possible Component type, you need to make an array of MAX_ENTITIES large, and, if that's thousands of entities and 10's of components, you've wasted a lot of memory.  I suppose memory isn't such a burden any more, but it just seems like a waste.

#5265323 entity system implementation

Posted by BeerNutts on 07 December 2015 - 02:10 PM

I believe I responded in your other post, but I'm not sure I agree "the first approach seem to be more popular" and I don't think you should really concern your self over forcing all components of the same type to be stored in cache friendly location.  Do what you feel is best for you, especially since you're new to the paradigm.


I can promise you, as a single developer, I doubt you'll be writing code that required the savings you'll get from grouping all components together.


And, FWIW, the "MAX_ENTITY" value can be really bad if you can have thousands of entities in a game;  the harm may out weigh the benefits.  If you're in the hundreds, maybe it's OK, but it's still not the way I'd do it.

#5264451 Game engine communication (character

Posted by BeerNutts on 01 December 2015 - 12:45 PM

As I mentioned earlier, there are multiple different ways this can be resolved using an ECS paradigm.  The example I presented uses events (which you should have observers for these events), but you could do it all with Components as well.  


For example, you have an Input system and an Input component.  Your Input system checks for button presses/releases and sets what buttons are being pressed in the Input component.  Your main player entity contains this Input component and a spell component (and many others), which lists the spells your player can cast.


Let's also say you have a Spell system, and this spell system, when it runs, it checks entities with the Input component (which the player currently owns) and see if the "Fireball" key has been pressed.  If so, it checks the spell component to see if you have the fireball spell, if the spell can be cast, and lets assume it's says, "yes cast it".


Now, the spell system would create the fireball entity.  It does this by adding the components the fireball needs like the Spell component (that dictates the damage, speed, etc. build from some prefab data), position component (derived from the Parent Entity's Position Component), animation component, etc. and adds it to the list of active components for that fireball entity.  Now the fireball will be updated in the world (since there's a system that updates all objects with a position component with the current speed) and might collide with an enemy.


All that means is you have Systems that run and it works on specific components (realizing Entities are just a bag of components).  It's obvious, when you shoot a fireball and the fireball is created, it will need to know where to create the fireball within the world, so the Spell System would ask it's owner's entity for it's position component.  It doesn't care what kind of entity it is (player, enemy, tree), it just knows the entity it's looking at has a spell component and a position component, and it's ready to create a fireball.  That's how you can decouple.


You can also decouple using events, and having the systems or components listen for events (like button press, or Spell Cast), and they react to those events.  it doesn't matter where they originate, the systems just know it needs to cast the spell given in the event.  Again, the player, and enemy, or a tree might have sent the "Cast Fireball" event, the spell system won't know nor care.


Writing ECS programs means thinking differently than you've probably thought in the past about programming.  It's a great tool, but realize it isn't the only tool.  Good luck.

#5263573 Game engine communication (character

Posted by BeerNutts on 25 November 2015 - 10:05 AM

"if user presses 1, set user.hasCastFireball to TRUE. Character Annimation somehow checks to see what state the user is in (Polling, observer??) and sees it is set to TRUE, then plays the castFireball animation, also setting its castFireballAnnimation to TRUE. FireballSpanwer also checks to see the user state, sees castFireball is TRUE, and spawns a fireball" or should FireballSpawner check to see if castFireballAnnimation is TRUE?


It's not quite that simple, and not the way I'd probably do it.  I'd probably have a fireball system that listens for certain input messages, like KEY_FIREBALL_PRESSED (this key is configurable), and when received, it checks if it's allowed to shoot a fireball (mana available? fireball re-fire time has expired? etc).  If so, it spawns a fireball entity, and maybe generates a spell cast event.  You could then have your player system listen for spell cast events and, when fireball cast event is encountered, it set the animation component state to fireball.


That's just one possibility off the top of my head, but it uses events.  There are many other ways of doing it, you need to find one you're comfortable with.

#5261769 Need help with beginning game programming with C language

Posted by BeerNutts on 12 November 2015 - 10:22 AM

Use SDL for graphics, input, and audio, it's tons easier than glut, and it has a lot of other functionality you'll need for a game.  It's a C based library, so it should fit the restrictionst.  Here's a good site for SDL tutorials.


Good luck and have fun!

#5260341 Best design for "dynamic configuration"?

Posted by BeerNutts on 03 November 2015 - 11:09 AM

Why not just make ConfigurationManager functions globally available?  Why must it all be referenced from a class?


Simply define your functions like this:

namespace ConfigurationMgr {
// returns a 2d vector of width and height of the current window
Vector2 GetWindowDimensions();
// returns true if in fullscreen mode 
boolean IsFullScreen();

And, in you class where it's needed, just call:

Vector2 WindowDim = ConfigurationMgr::GetWindowDimensions();

That my personal opinion on things that many sub systems need, just keep it simple, and make it a globally available function.

#5258087 Which game-engine to I use?

Posted by BeerNutts on 20 October 2015 - 07:12 AM

Unity.  Tons of tutorials for it on the internet.

#5257602 Game Engine Creation: What are the biggest challenges faced?

Posted by BeerNutts on 16 October 2015 - 08:34 PM

IMO, I would program an engine for YOU to use for your games.  Trying to create an engine generic enough for the masses, especially for what sounds like a hobby project, will be difficult, and probably unfulfilling.  However, if you create something for you to use in your own games, you'll learn a ton, and probably have fun doing it.


For example, way back when I was working on creating a networking engine (MUNE ) and I used it in a few of my own games, but it wasn't strong enough, and I got tired of working on it, for it t be used by the masses.  Same with my Component-based entity system Escape.


Create an engine, have fun with it, learn from it, and use it in some projects, and you'll benefit.


Honestly, my favorite part of game creation is the engine, even though I know I'll be the only one using it

#5255464 Struggling with JSON in text based RPG

Posted by BeerNutts on 03 October 2015 - 11:01 PM

It's also important to notice, that you can access JSON data by named index, instead of numbered index.
Say you got a file/object that looks like this:

locations = {
  "City": {
    "name" = "city",
    "difficulty" = 4,
    "description" = "A low population city",
  "Home": {
    "name" = "Athurs Home",
    "difficulty" = 8,
    "description" = "It's dark",
    "possible_directions" = ["City", "FordsHome", "Kitchen"],

Instead of looping through all possible locations, you can simply write something like:
var current_location = locations['City'];
display_text(current_location.description); // assuming you got a display_text() function

Which should improve readability.
Notice that you can access the data both as an array, and as an object.

If you use spaces in the name, you have to use the array-method.

Hope this helps.

That's not proper json.  You should be using : instead of = . in the json data.


locations = {
"City": {
"name" : "city",
"difficulty" : 4,
"description" : "A low population city",
"Home": {
"name" : "Athurs Home",
"difficulty" : 8,
"description" : "It's dark",
"possible_directions" : ["City", "FordsHome", "Kitchen"],

#5251599 Over-Engineered Battle System?

Posted by BeerNutts on 10 September 2015 - 01:44 PM

My question is whether or not the administrator class is necessary or am I over-engineering it by creating an intermediary body between the two fighter classes? Could the same results be created by simply having the Fighter classes check each other or am I right in thinking it's important to have something that creates a synchronized timeline to check if combos hit?


I think it's fine having an external system handling the updates, in fact, it's probably the right way to do it.  Your character classes would put their actions into the admin's queue, and each update the admin would check the actions and do whatever.  Then, when the time comes for the admin to "resolve", it would resolve everything in the right order according to when it received the action, not according to whichever character's Update() function is called 1st.  The Admin class would just query the character classes (punch damage value) and set values after (health, etc.)


Another possible issue, imagine PC1 and PC2 both press the punch button in the same update frame.  You'd want both punches occurring at the same time, in fact, possibly even killing each other.  But, if you tried it via character updates, you may update PC1, see he has health >0, and then apply his punch damage on PC2.  Now, PC2 will update, but his health <= 0, so he dies instead of executing his punch at the same itme.

#5250154 entity component system object creation

Posted by BeerNutts on 01 September 2015 - 12:50 PM

Isn't this a one person effort? Rebuilding is fast compared to putting time into implementing a scripting system you only want to use for loading some data.

IMHO just use CSV files with column headings, exported from a spreadsheet application where you type it in. They are easy to read into your game and don't contain cruft these XML-like formats have.


I would highly recommend using json instead, as it is extremely flexible in that it can handle arrays, structs, and dictionaries and is quick and easy to use.  You'll find tons of parsers out there for it, and it's not nearly as verbose or clumsy as XML.