Object management in 'custom' level editors

This forum is currently in read-only mode.
From the Asset Store
Manage time and money, plan the best strategy to make all the customers happy in your restaurant, a hotel, cafe, or any
  • Ok so this is something I've been trying to break down to a science for a while now, but I'm having some trouble.

    How would you guys go about managing objects in a custom level editor?

    I've come up with a couple ways of doing this, but man, it gets complicated and sloppy really fast.

    My ideal..system..of object management in a custom level editor would be very similar to how it's done in Construct's built-in layout editor.

    There would be a listbox with small icons and names which represent each object. When you click on one of these icons, another list to the right would show the selected object's PVs. You would then be able to adjust these values, set the object's properties (angle and such, which I've already figured out) and place it on the map.

    Sounds incredibly simple, no? Well it's not.

    I'll explain how I did this in my past level editors, and see what you guys think. Keep in mind none of these methods were very good, but if you have any suggestions on how to improve them or know some completely different and better way of doing this, I'd love to hear!


    -Objects were placed on a "table" in the layout editor, on a separate layer you can hide or reveal.

    -Each object was in the family "E_Objects", and had only 2 PVs: Name, and Value. I made the value "Name" because you can't retrieve an object's name yet, so this value was set to it.

    -There's a separate object called "ObjectValues" which stores an object's data when selected. It goes something like this: (I will refer to "ObjectValues" object as OV)

    -"E_Object" is selected from the table: Set "OV" value 'Name' to "E_Object's" value 'Name'

    -Now you can use a single edit box on the left to type in something for the Object's value called 'Value'

    -Now you can place the object like so..

    Left clicked on grid: Create object by name OV.value('Name')

    Set E_Object's value 'Value' to editbox.text

    So. That method is actually pretty simple, but since you can't retrieve an object's PV's, I could only find a way to edit ONE value before the object was placed. Also, the editbox caused a lot of problems. Once you click it, all of my hotkeys would be entered into the editbox, and using it's action 'unfocus' would lock up all keyboard/mouse input and pretty much ruin everything.


    Trying to explain this would make little sense, which probably means it was a terrible method to begin with. But on a glossy surface level, it worked like this:

    There's a list box which, when created, would list all of the object's names. You can click on a name, and a list object to the right brings up it's PVs which were added via the event editor. You can click on one of the PVs names, and type in it's value via an edit box. Upon pressing enter, the PV name would have the editbox text appended to it, delimited by a comma. I then used the text manipulator object to turn these into substrings, which can then be individually retrieved to set the object's values when placed.

    Actually that sounds pretty good. Problem is I haven't gotten it to work yet. I might in the future, but I'm already having some problems with it and I'm not so confident it'll work out in the end.

    To top it off I'm using an array to save the level data. Each cell has multiple values (object properties) which are essentially substrings retrieved by the text manipulator object. It just makes things so much more complicated.

    Anyhow. If anyone has gotten something like this to work, or has any ideas, please let me know!


  • This is going to sound silly, but in my current project I'm using the image manipulator to place tiles, objects etc.

    For instance, to place my ground tiles I simply draw a black pixel in an image of say 32x32.

    I can then have the image manipulator test for that color, and say if the color at loop x 10, loop y 32 is black create the object ground tile at x of 10*10, and y of 32*10.... In a layout that is 320 x 320. 3200 would be *100 etc.

    Now that might sound limiting, but when you think about it you have 255 states for red, blue, and green, meaning you have as many options for items as you do for colors... literally millions when you take alpha into account.

    With that in mind not only can you create sprites by color, you can also give those sprites attributes like angle, size, and even private variables.

    All you have to do is create your own special palette, and figure what you want them to represent.

    No special level editor required, just any old image editor.

  • Interesting concept. Sounds really confusing though!

    Actually I've already figured out tiles/collision tiles/triggers, and the like. I've got it set up so you can change their angles and size and everything. That was pretty easy. The problem I'm having here is with sprite objects and their private variables. I don't think your method would work for what I'm trying to do. One example is an enemy spawner; I need to be able to type the name of the enemy the spawner will create, or atleast choose it from a list. The data would have to be stored in a private variable. Another example is destructible tiles/objects. I need to tell that tile/object which particles to create when it's destroyed, what item(s) to drop, how many hits it takes to destroy, what sound to play when hit, etc.

    I REALLY don't feel like basing that stuff on things like the object's angle or animation frame or something, although it is possible.

  • When working object oriented, you will have an easier life using one of the two object oriented tools: 's'-plugin or python

    In the third post on this page, lucid gives a very fine example of how 's' could help you solve any of your issues.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • When working object oriented, you will have an easier life using one of the two object oriented tools: 's'-plugin or python

    In the third post on this page, lucid gives a very fine example of how 's' could help you solve any of your issues.

    yeah, I agree!!!

    the level editor there, if you haven't taken a look is only 4 events. add all your objects to an array, create spatial info array (automatically generates an array with your choice of any combination x,y,z,angle,width,and height of all the objects in the array)

    and then save, your choice of encrypted or not

    at a later time I may add the option to save pv values as well, but that's a simple matter

    create an array to hold the pvs

    for each object in array, add the private variable to the new array. and save after that instead

    loading would just be the reverse. when you load you can tell s to automatically apply the spatial info array, and you'll have all your objects back in their original location, and in the array. and then you can just For Each Object in array, set pv to {"yourpvarray",loopindex}

    in s, it's loopindex, it's just li, but if you don't know that and you plan to use 's', better start them tutorials

  • I've been dreading the day I'd have to learn the S plugin Oh well, better now than never.

  • If you feel more comfortable by reading the following, you could also consider using Python:

    # creating a game object reference (that will run at start of layout)
    class GameObject(object):
        def __init__(self, item=None, type=None, name=None):
            self.reference = {}
            if item != None:
                self.reference['Type'] = type
                self.reference['Name'] = name
        def copy_from_item(self, item):
            self.reference['X'] = item.X
            self.reference['Y'] = item.Y
            self.reference['W'] = item.Width
            self.reference['H'] = item.Height
            self.reference['Angle'] = item.Angle
        def add_pv(self, pv_title, pv_value):
            self.reference[pv_title] = pv_value
    #calling a game object reference (most likely a separate script somewhere in the events)
    myCoolRef = GameObject(Sprite, 'Sprite', 'Bullet')
    myCoolRef.add_pv('will_spawn', 'SmokeTrail')
    myCoolRef.add_pv('Lifespan', int(Editbox.Text))
    EDIT: But I really think, 's' would be the better choice for this particular task, simply because it was made for something like that. Saving the informations is just a matter of one order (whereas in Python you would need to create your own writing routines) and the spatial info shortcut is also neat.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)