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

Talk about making games.

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

Postby Techdojo » Wed Jul 25, 2007 9:24 am

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 :)
Techdojo
 
Posts: 16
Joined: Mon Oct 16, 2006 11:56 am
Score: 0 Give a positive score

Postby Jay S. » Wed Jul 25, 2007 1:59 pm

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:
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Postby Techdojo » Wed Jul 25, 2007 2:11 pm

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...
Techdojo
 
Posts: 16
Joined: Mon Oct 16, 2006 11:56 am
Score: 0 Give a positive score

Postby Jay S. » Wed Jul 25, 2007 3:00 pm

Whatever works for you my friend, I was only making a suggestion. :)
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Postby Techdojo » Wed Jul 25, 2007 3:15 pm

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...
Techdojo
 
Posts: 16
Joined: Mon Oct 16, 2006 11:56 am
Score: 0 Give a positive score

Postby Jay S. » Wed Jul 25, 2007 4:19 pm

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. :)
User avatar
Jay S.
 
Posts: 118
Joined: Thu Apr 26, 2007 6:51 pm
Location: My computer desk. :P
Score: 9 Give a positive score

Postby DocRabbit » Wed Jul 25, 2007 5:46 pm

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.
Attachments
canvasdemo_ss.jpg
screenshot to visual describe it.
drawcanvasdemo.zip
See if this would solve your question.
(209.04 KiB) Downloaded 113 times
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron