The Daily Click ::. Forums ::. Klik Coding Help ::. The saving of destroyed objects in MMF/TGF. Please help.
 

Post Reply  Post Oekaki 
 

Posted By Message

Tim*



Registered
  26/01/2005
Points
  77
26th January, 2005 at 05:37:12 -

Hi, i'd like help to make this in a game:
Imagine a platformer (like Wario) where the player goes through the level, picking up coins and such, mabye missing a few, and then leaves the level. Afterwards he has to RETURN to the level, and the coins that he took when he went through it first should be gone (because he has already taken them). But it's really hard to make that!! How would you guys be able to do this?

 
I have the ENTIRE C&C: Tiberian Dawn soundtrack. Extracted from the original game, in all it's succulent beauty. Oh baby, it's true. PM me for details on how to get it if you want.

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
26th January, 2005 at 06:59:23 -

I don't know. I wanted to do the same, but I gave up.

 
Old member (~2004-2007).

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
26th January, 2005 at 07:21:04 -

My best bet is to save the coin position & number after the level is exited, via the array object & then load them back up with the array object, but the first time you enter the level, the array save file is the levels coins all in place. Then you just save over it as you leave the level.
Basic your making a level editor that saves & loads automaticly & the level design is based on what coins you collect.

This is something i never really thought of, though hope this helps.

Image Edited by the Author.

 
http://www.facebook.com/truediamondgame

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
26th January, 2005 at 07:30:57 -

Actually this is your lucky day. I did this exact same thing once before, but with enemies as well.

You can use an INI, an array, or some other such thing.

I personally used an INI when I did it, because for once it was the best choice in my opinion.

You basically need to think 'what kinds of objects do I need to save?'

In your case it's just one type of object - 'coins'.

So in our INI file we'll have a group called [obj - coins]

Now, at the start of the game, spread a value of 1 in 'Alterable Value A' of the coins.

This will give each coin a unique ID number in its value A.

Next, add an item in the INI (inside the 'obj - coins' group) and call it 'total'. Set the value to the total number of coins in the level.

When a coin is 'destroyed', set another item inside the group. Call it 'id: #' where # is the ID number of the object you destroyed. Set the value of this item to '1'.


So if we have a level with 30 coins, and you pick up coin numbers 5, 9, 22 and 11, you should have an ini file like this:

[obj - coins]
total = 30
id: 5 = 1
id: 9 = 1
id: 22 = 1
id: 11 = 1

Once the level starts, and the ID numbers have been assigned to all the coins, you want to use a fastloop to scan through these. It will loop once for each coin (in this case it will do so 30 times, because there are 30 coins). On each loop it looks for an item called 'id: #' - where # is the index of the loop. So loop number 1 looks for 'id: 1'... loop number 2 looks for 'id: 2' and so on right up to 'id: 30'.

If the value of one of these is '1', then it knows that coin has been destroyed before, so it destroys that coin again.


Fun! I hope I explained that okay.

 
191 / 9999 * 7 + 191 * 7

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
26th January, 2005 at 07:47:47 -

Well, it's harder tha I thought.

 
Old member (~2004-2007).

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
26th January, 2005 at 11:52:52 -

Lol, well it's easier once you're used to making level editors in MMF.

Once you've done that a few times you feel guilty NOT doing stuff like this in a game

 
191 / 9999 * 7 + 191 * 7

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
26th January, 2005 at 12:19:57 -

Use array or Ini, I prefer array

 
n/a

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
26th January, 2005 at 12:30:48 -

I normally prefer arrays.

If you're trying to build the levels straight in MMF using the frame editor (the most common way of making levels in TGF and MMF) then INI is probably nicer to use.

But to be honest you'll make a far better game by building a level editor. You can make immensely powerful games that way - they literally dwarf anything made the traditional way.

For games using a level engine like that, an INI is usually used to control the positions of almost every object and tile in the game, so it's immensely easy to just save state and recall it at any time. That's not just saving the coins that have been destroyed, but the decal tiles created, the sounds that were playing. EVERYTHING.

To put that in perspective, it's loading every bullet hole, every footprint, everything you could possibly want it to remember.

It takes longer, but it is sooo sweet. And you can do so much more. You can make stuff like physics relative to the tile you walk on (so ice is slippery, grass makes you move slower, water causes you to swim, a shoreline causes you to paddle, mud gets you stuck, toxic slime causes you damage), and even sounds (footsteps change depending on the surface you walk on, water ripples when you wade in it). And all the tiles are STILL just background objects!

You can even update tiles on the fly, so water randomly shimmers and glistens.

Lol, I love level engines

Image Edited by the Author.

 
191 / 9999 * 7 + 191 * 7

Tim*



Registered
  26/01/2005
Points
  77
30th January, 2005 at 04:39:16 -

lmao, you get a bit carried away. thanks for all the help boys!

 
I have the ENTIRE C&C: Tiberian Dawn soundtrack. Extracted from the original game, in all it's succulent beauty. Oh baby, it's true. PM me for details on how to get it if you want.

DistantJ [FZ Games]



Registered
  02/08/2004
Points
  855
14th February, 2005 at 16:18:45 -

God technique, Dines. That's exactly what I would have done. However I have never tried it, it's just the method I had in my head for the time. Since I'm never sure if the 'spread value' option will depend on the position of the object or is just random.

I'll explain what I mean. Say you did spread value to give each object it's number, what if the next time you returned to the frame, it gave the object a different number? Is there a specific order in which it distributes the values among items relating to their position in the playfield?

If this was the case, it would just destroy random ones. Guaranteed it'd destroy the amount you've collected, but not necessarily the same ones, so I'd go with the method of saving it's x and y co-ordinate and destroying the one which is at that position(if the object moves than just use 2 of its values to store it's x and y co-ordinates at the start of the frame and go with that instead).

 
http://www.fzgames.com

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
14th February, 2005 at 17:39:38 -

I think, though I'm not sure, that Spread a Value uses the order in which the objects were created.

 
http://www.davidn.co.nr - Games, music, living in America

en kerro



Registered
  21/10/2004
Points
  578
15th February, 2005 at 10:57:45 -

Thanks, Dines. I didn't know that. I'll use it in Forgotten Legends

 
Current Projects:
The Artillerys 10%
Forgotten Legends 8%
Earth Defender 20%
   

Post Reply



 



Advertisement

Worth A Click