Posted By
|
Message
|
lembi2001
Registered 01/04/2005
Points 608
|
6th August, 2011 at 19:04:18 -
Hi all
Decided to try and make a quick game based on one of my favourite android games Alchemy. As it is currently a WIP i don't really want to go into too much detail about the game for those that don't know what Alchemy is but I have hit a snag that is quite integral to the game...
I have managed to create the basic game engine in which you can drag elements around to compare them but i am now stuck on how to create the resultant elements after you have combined them.
Each element has an Alterable String that contains the name of the element, they are also all part of the same group (player).
I first thought of using an array to store all the combinations in the format:
resultant element,element 1,element 2
This way i could use a fast loop to loop through the entire array and string tokenizer to split each entry up based on the comma. I coule dthen compare each element to the second and third parts of the string tokenizer and if i have a match i would then create the resultant element.
My problem is two fold:
1. Will this method become a HUGE system drain as i am expecting to have at least 200 elements which can then be expanded upon
2.How on earth can i create an active object based on it's alterable string
Hope someone is able to help with this.
n/a
|
Sketchy Cornwall UK
Registered 06/11/2004
Points 1971
|
6th August, 2011 at 19:40:50 -
I would have one "element" object, and just use different animations to make it look like different elements (don't use qualifiers). That's easier, more efficient, and means you won't have any trouble creating new objects based on an expression.
I would always use an alterable value from 1-200 instead of an alterable string (using a string to reference objects is a terrible idea).
That's much better than messing around with fastloops and parsing strings, etc - and the array can be a simple 2 dimensional number array (the x and y coordinates being the ID numbers of the two elements being mixed, and the value being the ID number of the resulting element).
That's assuming pretty much any two elements can be mixed. If only a few combinations work, some form of hash table would be better.
No, a 200x200 number array won't be a problem - apart from being a pain to fill with data in the first place.
Edited by Sketchy
n/a
|
lembi2001
Registered 01/04/2005
Points 608
|
6th August, 2011 at 20:51:13 -
Thanks for the reply sketchy, now putting together the hash table (i assume it's like the hundred square kids use for their ten time tables)
n/a
|
Sketchy Cornwall UK
Registered 06/11/2004
Points 1971
|
6th August, 2011 at 22:32:14 -
What I meant by "hash table" was really some kind of associative array (I just forgot the proper name).
The only difference being that a normal array would have to contain a space for every possible combination of elements, whereas an associative array would only contain the combinations that work (so if there are only a few working combinations, it could be a lot smaller).
You'd use the "Named Variable" extension (or something similar), and generate a unique "key" from combining the two elements.
eg.
Key = Str$(( Id_Element_A * 200 ) + Id_Element_B )
If most combinations do something anyway, you may as well just use a regular array.
It might be easiest to make the table as a spreadsheet in Excel/OpenOffice, and then convert it to MMF2 array format using my converter: http://www.create-games.com/download.asp?id=8360
Rows = first element ids
Columns = second element ids
n/a
|
lembi2001
Registered 01/04/2005
Points 608
|
7th August, 2011 at 22:54:50 -
Cheers Sketchy, i have finally managed to get your array editor to work. I'm running Windows 7 and it needs two dll's in order for it to run on anything above xp. Not sure if you want to include them in your zip file or not.
they are:
msvcp71.dll
and
msvcr71.dll
going to complete my array data and then see if i can get it to work the way i have planned it.
Cheers
n/a
|
Sketchy Cornwall UK
Registered 06/11/2004
Points 1971
|
8th August, 2011 at 00:07:50 -
Ah, thanks - I wasn't even aware that it required any .dlls
I guess the EasyXML extension needs them for something.
Good luck with it anyway
n/a
|
|
|