• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Advice for Level Design?

NovaOzuka

Member
So I'm working on designing my first platformer level. Does anyone have any tips as to how I can accomplish this easily? The last thing I want is to add several lines of code to the player and enemy objects for tiles, as that would be tedious and time consuming. I was going to just make the level a background and make what the player is actually colliding with invisible, but the room is too long for that.

Let me know if you have any ideas!
 
D

Danei

Guest
Well, using tile collisions and using invisible/visible collision objects are the most common ways I know of to set up a platforming environment.

Tile collision does require some setting up, but it's not a huge undertaking. There are several tutorials that seem pretty popular, and once you have a general script, it's easy to add it to every entity that needs it.

Using objects, visible or not, tends to be more resource-intensive in large levels due to the number of instances that need to be maintained at a time, but there might be ways of optimizing it enough for your purposes using instance (de)activation or chunking. But that'll require setting up too.

There are other things you can do, like grid-based collision, but that's nearly the same thing as tile collision at the end of the day. There's also the physics system, but I don't know anything about it, and you'd need to want a very physics-y platformer in that case.

Any alternative I can think of is going to require at least as much time and tedium as tile collision, so I guess my conclusion is get ready to do some setting up and try tile collisions. ;)
 

NovaOzuka

Member
For platformer Mario is pretty much best starting point-
I need to remember to look at that when I can. Anyway, I was kind of thinking maybe I needed to make the first level have two rooms to get exactly what I wanted. Regardless, I did come up with something that might be a little crazy. What if I separated the part of the player's code that make it collide with the only coded tile I've made from the rest of the player's code? Could I rig it so it collides with anything with a certain variable?

Let's say I give all the tiles a variable called "col". Couldn't I have something like "if (other.col = 1)" and still have the player collide with the floor and walls? If that's the case, I wouldn't have to code nearly as much, and I can just copy the tile objects for as many tiles with the exact same properties. I would merely have to change the sprite for each tile as long as they all use the exact same code, and then the main problem would be lag. I suppose that I could deactivate anything that leaves the player's view, but then I would have to make any offscreen enemies respawn when the terrain reactivates
 

woods

Member
set your background to whatever setting you are after,
create movement code for the player,
create an invisible object for your collision and place it in the room over the platforms( you can give this a transparent sprite so you can see it inthe editor, then switch it to clear after you are finished)
create collision code for above,below and side for the player with that single object
add tweaks where you want

not really much code to get the basics started
 

NovaOzuka

Member
set your background to whatever setting you are after,
create movement code for the player,
create an invisible object for your collision and place it in the room over the platforms( you can give this a transparent sprite so you can see it inthe editor, then switch it to clear after you are finished)
create collision code for above,below and side for the player with that single object
add tweaks where you want

not really much code to get the basics started
As I already mentioned, I tried that, but the background got rescaled.
 

woods

Member
As I already mentioned, I tried that, but the background got rescaled.

make your room as big as your background.. have your camera follow the view with your player
 

NovaOzuka

Member
make your room as big as your background.. have your camera follow the view with your player
Woods, this is exactly what I already tried and didn't work. I said in the original post that the room is too long for the background to be made the same size as the room.
 
D

Danei

Guest
Why can't you resize the background to match the room size? Or better yet, set the background to tile horizontally and put your floor/wall platforms on a different layer?
 

woods

Member
sounds like you have the wrong size of image for your backdrop..... example.. a level for mario...(arbitrary numbers here for effect) is 300 high and 5000 long..... make the room and the background image the same size..

if your background image is not wide enough, either tile it like Danei suggests..
or stretch it... that'll make it look funny... youve already tried that


then the next option is...
make an appropriate size image for the width of the room you want


also make use of the views option.. that helps too
 

NovaOzuka

Member
Look. This is what's happening. I make an image the same size as the room. The game decides to make it smaller, which is why I can't just put invisible tiles. The way you guys keep saying makes it sound like that I made it too small. So in order for it to match the room without tiling the background, which I understandably can't do yet as it isn't finished, is to make the room shorter, which I don't feel comfortable doing. But that is beside the point. The background I can finish once the foreground is finished, which obviously means I need to make a tileset for the whole level due to aforementioned issues. I don't want to have to spend several lines of code on several different tiles, and I especially wouldn't have to code 5 or more tilesets.

That being said, I feel that I must repost this since it seemed to have got ignored.
Anyway, I was kind of thinking maybe I needed to make the first level have two rooms to get exactly what I wanted. Regardless, I did come up with something that might be a little crazy. What if I separated the part of the player's code that make it collide with the only coded tile I've made from the rest of the player's code? Could I rig it so it collides with anything with a certain variable?

Let's say I give all the tiles a variable called "col". Couldn't I have something like "if (other.col = 1)" and still have the player collide with the floor and walls? If that's the case, I wouldn't have to code nearly as much, and I can just copy the tile objects for as many tiles with the exact same properties. I would merely have to change the sprite for each tile as long as they all use the exact same code, and then the main problem would be lag. I suppose that I could deactivate anything that leaves the player's view, but then I would have to make any offscreen enemies respawn when the terrain reactivates
 
D

Danei

Guest
If you're using collision objects, it's common to use a parent object for basic collisions, and use child objects for anything that needs special interactions (jumpthrough platforms, for example). It looks like that's what your idea amounts to, and it's not crazy at all.

And yes, you would likely need to deactivate instances beyond a certain distance away, but this too is common.
 

NovaOzuka

Member
Okay, creating a child object seems to have done the trick. Now if I can just figure out how to temporarily deactivate instances out side the player's view, I'll practically be all set to build the first level.
 

woods

Member
im curious.. if you dont mind sharing your background image ;o)
how big is your room? and your view following the player?
 

NovaOzuka

Member
@woods The room itself, I believe had a width of 2560 originally, which was four screens long, and has a height of 1536, which is probably more than what I need. The view following the player is 640x480. As for the image, I don't have the original, not that it matters as I've only trimmed off currently blank space.
Metropolis City 1.png
Trying to make a cityscape, but obviously I'm far from finished, otherwise the 16x16 grid would be gone.
 
Top