How do I make a graph game

0 favourites
  • 14 posts
From the Asset Store
five golem elements Sprites Sheet.Best for enemy or villain game characters.
  • I want to make a game that uses a graph underneath, but not sure what is the best way to do it. Each cell should be able to examine the type of the neighbouring cells, but the neighbours aren't necessarily visually touching each other, they're logically connected

    any suggestions on what is the best way to do it? (I'm an experienced programmer, but haven't used Construct 2 before)

  • I guess you're looking for the array object, with it you could loop through all cells..

  • problem with the array is that each cell has 4 or 8 neighbours and it forces a certain topology

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • If you use the z direction as well, it has even more..

    Maybe you could explain better what you are trying to do, for I'm sure a solution can be thought of..

  • It's a turn-based chase game, where nodes can have say up to N links connecting them to other nodes and there are N-1 enemies chasing a player that moves over the links on the graph nodes. The nodes+links (graph) is the underlying data structure, the display can be some drawing where the links aren't necessarily direct lines (can show up like say paths in some forest from a top view)

  • I guess I could use an array anyway, of (K,1,N) dimension - I could store a number 0-(K-1) in each cell to mark a one way link. For two way links would store two times, as two one-way links

  • And in the (i,0,0) position I'd store some info on where the node is on the UI or some reference to a graphics object (are there such?). If I can only keep numbers in the array then I'd need (K,2,N) dimension so that at (I,0,0) I store X and at (I,1,0) I store Y coordinate of the node on the display

  • you can keep complete strings in the array if needed and use TokenAt to get information from that string..

  • Another thing is that I need to be able to go the other way too, from clicking something on the display to finding the correct cell in the datamodel (the array). Can I keep some Tag value on visual objects or use their Name or something to point back to the cell's number? (I mean x in (x,*,*))

  • I guess using an instance variable would be the easiest way for that..

  • indeed, had recently read about that but it skipped my mind

  • i think 2 arrays would be easier... one array to hold all your nodes in the graph and then another to hold all the connections between the nodes, with the key to both being some unique node id. You can always make your connection array larger than you can imagine, it's unlikely to consume too much memory unless you have 1000's of nodes.

    storing variable length data in a string and using tokenat is very handy but gets messy if you ever change the contents

    KISS principle.. keep it simple stupid... sometimes two simple things is much easier to implement than one slightly more complex thing.

    R

  • thanks for the replies,

    found this one too that sounds interesting:

    Data storage objects in a container

    ----

    It's possible to add data storage objects like Array and Dictionary to a container with another object. Despite the fact these objects are invisible, a separate instance of the object is still created for each container. This allows you to have a dedicated Array or Dictionary for each instance of an object. This can be very useful as an advanced substitute for instance variables, such as if a very large number of variables is necessary, or if variables need to be dynamically added and removed.

    scirra. com /manual/150/containers

  • Another thing I could use is Dictionary, if only it had a mode to work as a MultiValueDictionary, where it allows one to add multiple values for a given key and returns a list of values for the key if it has more than one value

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)