Pick up keys only once through entire game.
I am working on a Zelda II type platformer game. You know how in that game, where you go into palaces for the first time, there are a few keys and locked doors around? When you pick up a key, and open a locked door, they do NOT re-appear ever again.
I am trying to achieve this. I know it probably has to do with spreading out values.
I managed to spread the values out for the keys, & use a fast loop function. The key does not come back when I just restart the frame. However, when I leave the frame, go to another frame (say for example, the map frame), and come back to the same frame where the keys were, the keys come back. So, am I missing something here?
If I can get the keys to disappear indefinately after picking them up once, I can probably figure out the rest (in terms of getting rid of the locked doors indefinately too).
Re: Pick up keys only once through entire game.
What a game like Zelda II probably did was use an array for this type of data.
An array is just a table/grid of data. Each slot in the array will hold a "Have" (1) or "Have Not" (0) value for each key in the game.
Since there may only be about 4 keys per dungeon, and say 8 dungeons... we are looking at only about 32 keys in the entire game. So this can be stored in a global array.
So in your game, lets make the X position in the array the "Key ID number" (spread value). And then lets make the Y axis the "Level Number" (your Frame number, or how ever you do levels).
So for example, collecting key #2 on level 4 will set the array value at (2,4) to 1.
To make sure a key never shows up again, just do a Loop the "number of Keys" times. Compare it to the array.
---
Start of Frame:
>>Run Loop "Key" (count of Keys) times
>>On Loop "Key"
+ If Value at -- (Loopindex"Key", "Level Number") in array equals 1
+ "Key ID" of "Key" == Loopindex"Key"
== Destroy "Key"
---
To make sure Doors never lock again, just create another array for the Doors, doing the same thing. After a door is unlocked, do a door loop to destroy the door.
Just take note that when you create more doors/keys, their "Spread Value" order may change. (changing their IDs)
I'm a bit tired right now, so if anything is unclear, just ask.
Re: Pick up keys only once through entire game.
So, does that mean I need to use an array extension of the sort? I'm trying not to use any extensions as possible so I can export to mostly everything without erorrs.
Although, maybe would saving the info in INI work? But then I'd probably have to find the SWF equivalent of INI if I wanted to export there.
Re: Pick up keys only once through entire game.
You can also use Global Values. Each door gets a Global Value. It is 0 when closed, and 1 when unlocked.
Marv
Re: Pick up keys only once through entire game.
Quote:
Originally Posted by nivram
You can also use Global Values. Each door gets a Global Value. It is 0 when closed, and 1 when unlocked.
Marv
True, but I got to leave global values open, in case I need to use them later. :-/
For the record, I am already using like 5 global values for other things that aren't items. Also, if I go to add more keys & more doors, that would just take away even more global values. :-/
Re: Pick up keys only once through entire game.
Global values are unlimited.
Marv
Re: Pick up keys only once through entire game.
Okay, this is what I have so far.
http://img510.imageshack.us/img510/6558/imagehh.png
http://imageshack.us/photo/my-images/510/imagehh.png/
If that's what you mean by 'using global values'.
This code seems to work if I do NOT destroy the keys. Only make them invisible. Unfortunately that's not what I want them to do.
In the code above, I need destroy the keys as well when the values match. But because the keys will get destroyed, I assume the values are reset. That is probably the reason the keys come back when I go back to the frame the keys are located.
So maybe there is something I'm missing, or something I need to change so it will always take effect? Maybe I need to save the values on another object that doesn't get destroyed?
Re: Pick up keys only once through entire game.
Just a heads up, the ini object works in Flash (regular ini) as well as the standard array object. For what you are trying to do, an array seems like the best choice, though you will need to make sure it is global to application if you want it to retain values over frames.
For actually saving the data though, I think in Flash you can only use ini, and not array unless someone can say for sure.
Re: Pick up keys only once through entire game.
In Flash, INI and HighScore are the only things you can use that saves on the hard drive. 100k max.
Marv
Re: Pick up keys only once through entire game.
How did the answers to using INI for SWF end up in a topic like this? o_O
Anyway, I think I'm getting tired of over thinking this situation with something I should do with using arrays. Instead I think I may take a different route with it. Instead of destroying the global objects, I'll just set their flags on, turn them invisible, and then reposition them off screen. This should give the same effect as I want, even though it truely does NOT destroy them, at least their data values are still saved if they are present somewhere.
I read somewhere that this is actually based on how game design works anyway. In a game about designing games I played for the DS, the objects couldn't be destroyed. They were either moved off the stage, swapped with another object, or just changed to a blank animation.
I think I may just take this road for the keys & doors. It seems the most logical without having to use extensions.
Re: Pick up keys only once through entire game.
Quote:
Originally Posted by N64Mario
How did the answers to using INI for SWF end up in a topic like this? o_O
Well, I read this:
Quote:
Originally Posted by N64Mario
So, does that mean I need to use an array extension of the sort? I'm trying not to use any extensions as possible so I can export to mostly everything without erorrs.
Although, maybe would saving the info in INI work? But then I'd probably have to find the SWF equivalent of INI if I wanted to export there.
Basically, I was just saying that the built in ini and array objects work in Flash, so exporting with those isn't an issue. Just that you can only save your data with the ini, not array.
Re: Pick up keys only once through entire game.
Quote:
Originally Posted by N64Mario
This should give the same effect as I want, even though it truely does NOT destroy them, at least their data values are still saved if they are present somewhere.
I read somewhere that this is actually based on how game design works anyway. In a game about designing games I played for the DS, the objects couldn't be destroyed. They were either moved off the stage, swapped with another object, or just changed to a blank animation.
I think I may just take this road for the keys & doors. It seems the most logical without having to use extensions.
I'm guessing you're talking about WarioWare DIY? I love that game. But that really isn't the economical "real" way to remove objects from play. The reason this method is OK in WarioWare is because there are only so few objects (less than 10) ever. With many objects, this model breaks down.
I don't see why you couldn't just destroy the keys.
When Flag=1
+ Player overlaps key
== Destroy key
Why won't that work?
Re: Pick up keys only once through entire game.
Quote:
Originally Posted by JimJam
Quote:
Originally Posted by N64Mario
This should give the same effect as I want, even though it truely does NOT destroy them, at least their data values are still saved if they are present somewhere.
I read somewhere that this is actually based on how game design works anyway. In a game about designing games I played for the DS, the objects couldn't be destroyed. They were either moved off the stage, swapped with another object, or just changed to a blank animation.
I think I may just take this road for the keys & doors. It seems the most logical without having to use extensions.
I'm guessing you're talking about WarioWare DIY? I love that game. But that really isn't the economical "real" way to remove objects from play. The reason this method is OK in WarioWare is because there are only so few objects (less than 10) ever. With many objects, this model breaks down.
I don't see why you couldn't just destroy the keys.
When Flag=1
+ Player overlaps key
== Destroy key
Why won't that work?
Yup, that's it. :)
The reason I decided to not destroy the keys and just move them off the stage is because their values are reset if destroyed. I've been told that I may need to use an array to save the data so that the keys won't ever come back again. But the only way I could do it without an array extension was to just move them away. :-/
If you want you can take a look at my MFA, and see what you can help me with. I think I actually do destroy some other items that aren't supposed to appear ever again. That's because some of those items will only appear once throughout the entire game.
As for the keys & locked doors, this method will be completely different. Since there will be more than one key and door eventually, I need a different method for handling them.
I should also note that I have made the keys & locked doors global objects. That's why their values don't get reset when I change to different stages, as long as they don't get destroyed.