Fog of War - Is it Possible?

RattleheadRattlehead Member Posts: 485
edited November -1 in Working with GS (Mac)
I am just in the process of finishing my pong clone to get an understanding of GS and was looking at a couple of potential ideas for my next project.

One of the projects I was interesting was resurrecting a Battleship clone I had done a couple of years ago but I am struggling whether or not it is feasible with GS.

Would I be correct when stating that it would be difficult to manage the layers where a player could tap a number of actors to indicate where their units are located and then the fog of war which layers on top of it?

Would you simply be limited to small grids so you don't overload the processing of too many actors?

I couldn't find anything through either the regular or Google search but if anyone has any thoughts, I'd be more than appreciative to hear them.

Thanks.

- R. -

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Anything is possible, but really really tedious with GameSalad.

    Nothing to do with the processor as much, but since there are no Arrays, keeping track of the grid would be a nightmare.
  • rebumprebump Member Posts: 1,058
    I would think the way to approach a Battleship type game in GS would be to think "vector" for ship placement. For each ship placed, it would have an initial location for its nose (or tail) and then its length (number of holes), and then its "vector" or direction of the rest of the ship (i.e. N, W, S, or East). That would allow a somewhat easy way to test for a "hit" (i.e. the snap-to value of the touch X/Y compared the ships' initial location and then direction/length).

    You could use the "grid snap-to" demo to snap the player touch to the grid for initial ship placement and during game play for firing.

    The harder part I think would be during initial ship placement...allowing the player to adjust its placement (up, down, left, right and then its direction) and keeping track of that. Still doable I think.

    To make "hit" determination easier, you could use four additional game attributes per ship to populate its nose X/Y and its tail X/Y coordinates during the placement phase. Then the test for the snap-to touch X/Y could be tested to be between each set...if so, a "hit".

    Of course, an array of ships' values would make the logic a bit easier to handle but until GS has arrays, you got to get creative.
  • JGary321JGary321 Member Posts: 1,246
    The risk of sounding like a complete moron... I'm gonna go ahead and ask the question that I'm sure is being asked in the head of many newbs here...

    What the heck are ARRAYS?? What benefit do these give? Maybe an example or 2? As detailed as possible please :)
  • KamazarKamazar Member Posts: 287
    @JGary, y'know when you're using Photoshop, or any graphics software with layers, and there's a window where you select the layer you want to work with, toggle visible, opacity, etc? That's an Array. Basically that, columns that let you manage individual bits and pieces. With GS, you have to actually click something to select, which is a real pain.
  • rebumprebump Member Posts: 1,058
    So we have variables (aka attributes) in GS of a certain data type (i.e. real, angle, integer, or...etc.).

    An array (as something we would like implemented in GS) would be an array of attributes - a whole bunch of a particular data type of attributes referable by one attribute name and indexable by another value (its index). The index is almost always implemented as a unique value and is usually an integer value. The index is usually included after the attribute name but enclosed in some sort of matched brackets (i.e. [], {}, () ). Indexing usually starts at zero or sometimes 1.

    So a single attribute of type real:

    `myRealValue = 5.2`

    and an array of the same type of attribute:

    `
    myRealValueList[0] = 7.3
    myRealValueList[1] = 22.54
    myRealValueList[2] = 3.33
    `
    It allows looping through a bunch of related numbers (example further down).

    An array can usually be multi-dimensional too:

    `
    myCheckerboard[0][0]
    myCheckerboard[0][1]
    .
    .
    .
    myCheckerboard[0][7]
    myCheckerboard[1][0]
    myCheckerboard[1][1]
    .
    .
    .
    myCheckerboard[7][6]
    myCheckerboard[7][7]
    `
    Also, you can usually have an array of complex data types (objects/structures/etc.). Think of this:

    `
    myEnemyActors[0]
    myEnemyActors[1]
    myEnemyActors[2]
    .
    .
    .
    `
    So on the more complex data type arrays, you can then access their internal data with something like:

    `
    myEnemyActosr[0].Position.X = random(0,screen.Width)
    myEnemyActors[5].Postition.X = random(0,screen.Width)
    `
    You can see where this would come in handy, especially if they made looping easier:

    `
    change_attribute myIntIndexValue = 0

    (repeat the following code until the last index value of myEnemyActors[] is reached:)

    change_attribute myEnemyActors[myIntIndexValue].Position.X = random(0,screen.Width)

    change_attribute myIntIndexValue = myIntIndexValue + 1

    (end of repeat code)
    `
    Arrays usually provide some niceties such as an easy way to return the count of values in the array - usually by way of the array name by itself without an index in brackets or:

    `
    myArrayValues.length
    `
    (or something similar)

    Such a feature would be nice to count the items as well as use in the loop termination logic (e.g. in the pseudo-code loop above).

    For more reading, check out Wikipedia. A few things to research:

    - sparse arrays
    - associative arrays
    - collections
    - lists
    - dictionaries / key-value pair arrays

    and even:

    - classes / objects
    - structures
  • RattleheadRattlehead Member Posts: 485
    Hmmm...

    I'll maybe give it a whirl and see how creative I can be. Arrays would definitely have been the way to go but maybe there is something else I can come up with. Otherwise I guess it will be time to pick another project.

    Thanks guys. Appreciate the feedback.
  • JGary321JGary321 Member Posts: 1,246
    Kamazar/Rebump thanks a lot. I had a loose idea of it, but that really puts it into perspective.

    NOW WHERE'S MY ARRAYS!
Sign In or Register to comment.