Page 1 of 1

Yet another question about Tiles (Dynamic ones at that!)

PostPosted: Wed Jul 25, 2007 9:24 am
by Techdojo
I'm creating a little puzzle game and I want to fill the screen with a tiled actor and then let the player change the individual tile images when they click on them with the mouse.

I was going to have a 2D array represent the puzzle data and have the tiles represent the current state of the puzzle.

Is this possible - if so can some one give me some clues ???

Thanks in advance

Jon...

OOPS - Sorry for the double post - my PC went on the offensive :)

PostPosted: Wed Jul 25, 2007 1:59 pm
by Jay S.
I don't think you can change the animation of tiled actors. :(

You may need individual actors for each part of the puzzle...

You could create a variable, say, called "puzzleState," a global integer array. For example, if your puzzle has 28 actors, then put the array as 28.

Then, on a Mouse Button Down event for each actor, have it so each actor sets a different value in the array:
Code: Select all
puzzleState[0]++;
puzzleState[1]++;

And so on...

Then set each actor's animation based on the value of each array in puzzleState:
Code: Select all
animpos=puzzleState[0];


I hope this has helped... :) There's probably better ways to do this, but I'm still a noob at programming. :wink:

EDIT: Did I post in the wrong topic?! :shock: :lol:

PostPosted: Wed Jul 25, 2007 2:11 pm
by Techdojo
Thanks Jay,
I'd sorta came to the same conclusion, however I'm using two grid sizes - small (8x5) and large (12x9) that's going to give me a total of either 40 or 108 actors, I'm not sure if the humble Pocket PC can handle that load (not to mention it's WAAAY overkill for what I'm trying to do!)

The other way I'm looking at doing this is by using either 5 or 9 text actors (one per row) and using the animation frames as a custom font image, that way I can make each row a simple null terminated string, and then when the player clicks the mouse I can simply pick up the mouse coords and then work out which character within each row needs to be changed!

But your right in that I can keep the current puzzle state updated in a 2D array (that's how it works in the PC version of the game).

Cheers

Jon...

PostPosted: Wed Jul 25, 2007 3:00 pm
by Jay S.
Whatever works for you my friend, I was only making a suggestion. :)

PostPosted: Wed Jul 25, 2007 3:15 pm
by Techdojo
Jay - don't get me wrong - your suggestion was very good and that was the train of thought I was going along, then I remembered seeing this article on making health bars and the idea of using a text actor came too me.

It might work (I haven't tried it yet), and if it does all I have to do is change the text string to be displayed, it might even be a way to implement a dynamic map system - something which I think GE is seriously lacking in!

Jon...

PostPosted: Wed Jul 25, 2007 4:19 pm
by Jay S.
Techdojo wrote:It might work (I haven't tried it yet), and if it does all I have to do is change the text string to be displayed, it might even be a way to implement a dynamic map system - something which I think GE is seriously lacking in!


In fact, I believe this was discussed a long time ago... I'm not sure how many people use it, though.

Well, glad to help you out. :)

PostPosted: Wed Jul 25, 2007 5:46 pm
by DocRabbit
Techdojo,

See if this example may be something you could use. This will allow a click on a screen area to draw the block based on an array value and sets based on previous value. Example, if nothing painted there, paints it first color, red . Then if red block, paints it green. if green, paints it blue. If blue paints it red. These are all done from a single actor with 3 frames of animation: red,green,blue. The draw event for the canvas is only triggered to do something when a global value is set to 0. At all other times it is set to -1.