User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17

Thread: Using arrays for level building over regular global object spawning

  1. #1
    Clicker Fusion 2.5 DeveloperSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,306
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Using arrays for level building over regular global object spawning

    I have been looking through a number of examples for level building on 1 frame, and loading them in the game engine on the 2nd frame. All (or at least most I came across) of them I tested use the Array object. However, I found that most of the time, the "background" elements are still active objects in order to save the locations they are positioned on the level frame. On the game engine frame, all of the active background elements exist anyway.

    So I was thinking. If the level structure are going to be active objects anyway, wouldn't be simpler to mark the level structures as global objects on their frame, save the ID's and X + Y positions of the objects in alterable values there, and have the engine frame just create those objects, and load everything from their X & Y positions? Or do the alterable values, flags of these objects somehow do not carry over to the next frame? If they are global objects, I would imagine every changed value of that object would remain that value when created on the game engine frame.

    Correct me if I'm wrong, unless the Array object has other advantages for loading multiple levels on the game engine frame that can't be done with global object value checks.

  2. #2
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Arrays are best for loading levels because they can easily be mapped to a grid system if it's tile based. Even if it wasn't tile based, you could use the array like a glorified list object saving data of every object in a level including positions, alterable values, flags, etc. All you would need to load your level is to use a few fastloops to go through the array to read the data and load all the objects.

    The background objects don't have to be actives. You can use the "add backdrop" action to place an active as a backdrop, then destroy the active.

    The main use of arrays is also to save and load the levels externally as arr files. So you can quickly build levels using a level editor and instantly import them into your game.

    As a level editor example file, having the first frame the editor and the second frame the testing frame, global objects could work. But in your actual game that's not how it's going to work. You won't have the editor in your game. You'll just have one frame that loads data from your levels externally using arrays. So there's no point in using global objects in your actual game.

  3. #3
    Clicker Fusion 2.5 DeveloperSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,306
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Hmm...... So lets say I don't want a level editor for the game. I could still just design the level in the first frame, with all the objects marked as global objects. Then in the engine frame, load the level based on whatever variables were used. There wouldn't be any external files to deal with.

    Though what you are suggesting where using arrays save and load .arr files. If there was no in game level editor, couldn't someone modify the said .arr file outside of the game to make it easier or harder? Or would the .arr files only be modified if a level editor exists for that game?

    Just tossing some ideas around, as I've experimented with numerous ways to loading level structures without using arrays. You would still get the same effect as you were just playing a regular platform game.

  4. #4
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The whole point of using arrays for loading is that you read the data externally so you can cycle between levels easily. If you're already going to build the levels in Fusion regardless then there's no need to have a separate level editor frame and a game frame if you're not going to save the levels externally. The only difference for you being that you wouldn't have to copy the code between levels, since the main engine code would be in one frame? But you would still need to have separate frames per level if you make multiple levels.

    So the main difference between an array method and your global object method is the number of frames in your game. An array method only uses one frame and will load the levels reading data from external array files. Your global object method would be copying objects from other frames into your game engine frame. However it wouldn't be a single frame so it's more complicated. Also having multiple levels using the same global objects could get messy, especially with instances of objects. It just seems like more of a hassle that way when you go past one level.

    Arr files aren't easily editable like text or ini files. From what I've tested they only really work in Fusion apps that use the array object. So for added security you could encrypt files with the Blowfish object to make sure no one can easily edit them further.

  5. #5
    Clicker Fusion 2.5 DeveloperSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,306
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Theoretically, I could store every level structure in 1 frame without the array object (could store the levels in their own layers), mark them as global, and then call certain level assets based on the loaded variables. So iwouldn't that still give the same effect as using an array?

    Using arrays would need to call the level assets from somewhere anyway, correct? I just don't see the point if both options are going to do the exact same thing

  6. #6
    Clicker Fusion 2.5 DeveloperiOS Export ModuleSWF Export Module
    Sumo's Avatar
    Join Date
    Jul 2008
    Posts
    642
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The array method has only one copy of every object in your game frame which keeps resources down to a minimum and will only create an object when needed.

    If you created a layer for each level, it will add all of the objects for each level together within one frame so you will eventually hit the object limit of 20,000. It would also be a waste of resources. I don't think you can edit the "create at start" property within the event editor so all objects would have to be created at start which messes with your global objects being ported to the next frame. There's not much control.

    A major thing to consider is that you lose the functionality of copies or instances of actives. While in a normal level it would be easy to quickly copy ground objects in a row as instances so they reference the same active object, you can't do that if you want their alterable values to be unique if they record their positions. So that means your object count will quickly get out of hand if every wall and floor object has to be a unique cloned object.

    You can run some tests yourself having multiple global objects on different layers on the same frame. Try adding instances and clones to see if there's a difference. To me though it seems like a roundabout method for loading levels when arrays can already streamline the process with a single fastloop for loading if you use the mod function.

  7. #7
    Clicker Fusion 2.5 DeveloperSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,306
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Well, I came up with this method months ago.
    https://community.clickteam.com/threads/101753-Loading-different-levels-in-1-frame-based-on-global-value-NO-extensions
    With this idea, the levels and engine would be included all in 1 frame. The level data is stored in an active object, and would just change depending on alterable values. Again, same idea, same concept for loading levels, but different method of doing it.

    The way I see it, there are many ways to approach loading levels depending what kind of game the person wants to develop. In an example game like Zeb, that game doesn't even use Arrays for levels. Every frame is its own level, only bad thing is have the engine be consistent for every frame. Not to mention I'm probably comparing something that was made in as old as The Games Factory. Probably realistically not what you want to do though.

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,277
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    I think the example you are referring to is using a simpler setup so a new user isn’t overwhelmed by more complex approaches. It is a pretty proven method to load levels from arrays. You are only making more work for yourself if you avoid them. Of course, this is only in the context of games that use tiled levels.

  9. #9
    Clicker Fusion 2.5 DeveloperiOS Export Module
    butterfingers's Avatar
    Join Date
    Apr 2012
    Location
    London
    Posts
    135
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    TBF though, the example you've posted here:
    https://community.clickteam.com/threads/101753-Loading-different-levels-in-1-frame-based-on-global-value-NO-extensions

    Is incredibly simplistic. You're not actually loading the level from anything, you're just manually setting the positions of the keys and doors through code.
    While you say "The level data is stored in an active object" it's not, most of it is manually setup in your "Load Level" code group.
    This is fine for something as simple as this, but what about if you wanted 3 types of enemy, collectables, different obstacles etc?
    If you're manually going to place all those with code, it's going to get very hard to visualise what's going on, and very hard to bug fix and so on.

    I'll be straight up, over the years I've often tried to find quick workarounds to avoid having to make a level editor/level loading system, but the simple fact of the matter is, you'll spend ages trying to build workarounds, when what you should just do is build an editor that saves and loads data from CSVs, Arrays, inis etc etc.

    Your each-level-on-a-different-layer-in-a-single-frame method is going to rapidly get messy (what if you need more than one layer to have foreground/background), and is going to be super inefficient as your game grows.

  10. #10
    Clickteam Clickteam
    Olivier's Avatar
    Join Date
    Jun 2006
    Posts
    2,996
    Mentioned
    9 Post(s)
    Tagged
    1 Thread(s)
    The alternative to writing a custom level editor, it to use Fusion's frame editor as your level editor. I'm explaining this method in the second part of the ChocoBreak HD tutorial. It can be found in Fusion's Help or online here: http://www.clickteam.com/creation_materials/tutorials/chocobreakhd/en/part2/

Page 1 of 2 1 2 LastLast

Similar Threads

  1. How can I save level accomplishment with Arrays?
    By Emerson3 in forum Fusion 2.5
    Replies: 1
    Last Post: 10th May 2016, 07:30 PM
  2. How do global arrays work?
    By PotatoMerchantz5 in forum Fusion 2.5
    Replies: 3
    Last Post: 18th January 2016, 10:13 PM
  3. Replies: 5
    Last Post: 23rd January 2015, 02:12 AM
  4. Suggestions for level building?
    By mobichan in forum XNA Export Module Version 2.0
    Replies: 0
    Last Post: 13th June 2011, 12:10 AM
  5. Sub Application can't use global arrays?
    By Konidias in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 12th September 2009, 04:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •