Fog of War - Is it Possible?
Rattlehead
Member Posts: 485
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. -
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
Nothing to do with the processor as much, but since there are no Arrays, keeping track of the grid would be a nightmare.
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.
What the heck are ARRAYS?? What benefit do these give? Maybe an example or 2? As detailed as possible please
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
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.
NOW WHERE'S MY ARRAYS!