Level Creator with Mouse

0 favourites
  • 10 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hi guys,

    1) I'm trying to set up a level editor which will allow me to build a level using an array and my mouse. It'll start off with a black screen, and provide me with tiles to select on the right hand side of the screen. I will then pick a tile and start painting my level.

    Once this is done, I then want to be able to save the level I have made into an array, save it, and call it later.

    Please see my CAPX so far. CLICK HERE

    This is based on

    Subscribe to Construct videos now

    , and I have looked through the FAQs and searched quite a few times. My brain is telling me that the basic editor that I have set up is correct, but for some reason it isn't working (my brain or the software <img src="smileys/smiley36.gif" border="0" align="middle">).

    2) In any case, I wish to be able to expand on this at a later point, and eventually have a level randomly generate itself, but in a clever way with transitions, for example, water will not just be a square - the system will recognise water tiles, and surround it with edges, or gem blocks and bleed off into the surrounding dirt. This data will then be stored indefinitely until it's needed.

    3) Finally, the idea is to be able to use the path finder to have units navigate the terrain even as it's being changed.

    I wish to have a better understanding of arrays, and see how the system knows which tile correlates to which point in the array.

  • Move action 'set size to (levelheight, width)' below the actions where you set values to levelheight and width. Right now the array size is not setting up properly as you set those values AFTER you set the height/width variables. :)

  • OK, I've changed that... but when I click on tiles to change their colour (for now to just a red square) it's jumping all over the place and changing different squares. This leads me to believe the array isn't correctly linking to the tiles.

  • I made a couple of changes, tried to comment them into the events. Take a look :)

    dl.dropbox.com/u/19921470/Main.capx

    For printing the arrays (which is good idea to figure out what is going on) I'd recommend using some custom plugins like these:

    scirra.com/forum/log-text-objects-to-chrome-console_topic47859.html

    scirra.com/forum/plugin-debug-panel_topic48052.html

    I use the chrome plugin myself, works great!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks vee41, very impressive. Still trying to get my head around the changes, but from what I'm gathering, there doesn't appear to be a method of saving or loading.

    The line which you removed - "SetAnimationFrame to Shop.At((Tile.IID)%LevelWidth,(Tile.IID)/LevelWidth)" was designed to refresh the tile sprite frame to reflect that of the array, meaning that if the array x.10,y.20 = 1, it would set the corresponding tile to play frame 1. This means that the array can be saved as a string, and then loaded on startup.

    Does this make sense?

  • The line which you removed - "SetAnimationFrame to Shop.At((Tile.IID)%LevelWidth,(Tile.IID)/LevelWidth)" was designed to refresh the tile sprite frame to reflect that of the array, meaning that if the array x.10,y.20 = 1, it would set the corresponding tile to play frame 1. This means that the array can be saved as a string, and then loaded on startup.

    Does this make sense?

    Ahh, gotcha. Thought it was meant to do something like that but couldn't really figure it out. :)

    At the moment way I restructured it, painted values are saved into array. So if you paint few tiles as animation frame 2 value '2' is saved to corresponding location at the array. As of now, there isn't anyway to change frame you are painting, but this would be a simple variable you can change via button or something.

    What this array makes possible is that you can save/load levels. Right now there is no level generation from array, which should not be too hard to implement. Saving arrays as strings and loading them at startup is a good idea, there are some good examples of that around here :)

    Saving and loading could be implemented with arrays 'load' and 'asJson' functions, think I removed one of them as it wasn't really doing anything :) What you'd need is a save/load buttons which trigger these functions, and multiple arrays to save/load levels to/from.

    This is not really the simplest stuff, but once you get some basic principles down it should clear up nicely! :)

  • Great! I've read up on a few examples, but I can not figure out how to save and load. At the moment I'm just playing with keyboard commands to trigger these, and I'll have the mouse wheel choose the frame number, just to start things off...

    I'll give it a go. Hopefully it'll just click into my mind on what I'm doing :)

    Thanks a lot for your help!

  • Good luck, I added few features to this that could be basis for saving and loading: dl.dropbox.com/u/19921470/Main%20(1).capx

    Right now you are 'loading' and 'saving' map simple by pressing a button, if you wish to actually save data to a disk I recommend you take a look at the webstorage plugin. What you'd need to do is set the initial array values at the start of the layout, this way your map would load when the game starts. :)

  • I have removed the command "Tile set animation frame to 1" and have tried to re-introduce the code that will set the frame based on the underlying array number, but I'm not having much luck. Either the system appears to be painting the surrounding tiles, painting an ever changing pattern (somehow) or painting the entire board the same colour.

    I like what you've done with the Mouse.x and y positions coordinating with the array, but I'm not sure how I can re-use that data elsewhere.

    I am simply saving over the link in the first post. I feel I'm 1 line away from making this work as expected.

  • Oh, you did it. I was way off!!! <img src="smileys/smiley36.gif" border="0" align="middle" />

    Alright, I'll have a decent read of that, and figure out what I can do to swap, save, and load :)

    Thanks again!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)