Tutorials on building levels?

I’ve scoured the internet for tutorials and they have been very educational but I found there wasn’t much on for example creating a level and then a game camera that follows the player as he moves around the level. Is it difficult to do in Corona? The only templates I found that had levels like this were all made using level editors. Is it possible (practical) to do it without a level editor?

Can someone direct me to some basic code for a level that doesn’t fit on one single screen where the player can explore this level while the camera follows him? Appropriate for a platform game although even for a scrolling space shooter this would be better than simply increasing the amount of enemies based on for example score IMO.

You can build levels without using levels editors in Corona SDK.

Code for camera which follow character you can find in Sticker-Knight-Platformer in game.lua It uses ponytiled module for levels.

Post: Level module will be useful for you I think. 

Good luck:)

Well yes I’ve seen that, that’s why I asked specifically about doing it without level editors. Is that really the only way to do it in Corona? Is that what everyone uses?

Also in your game.lua I can’t see how you’ve set the size of the camera? If you wanted to add camera shake too would that be possible?

It is one way doing this I know about. May be try Perspective Virtual Camera System

You don’t set size of camera in game.lua. I think you can add shake effect usingponyfx.lua

Sticker Knight is based on using Tiled, a free tile map maker which provides a visual way to layout game levels. Corona, itself doesn’t have a visual layout tool and many people do not use a level editor.

You can create multiple background images that make a wide level and position them so they look seamless. There are size limits to images so you can’t really have a 10,000 pixel wide image. You can setup multiple backgrounds that when your camera moves, move at different speeds to create parallax if you want.  Once you have that, its simply a matter of creating your various objects using the various display.* APIs and position them where you want. If you’re using physics, add the physics bodies to them, all through code.

Rob

Oh right, so where do you set it then? I assume you must set it otherwise how will it know what size to be?

Parallax scrolling is the next step from what I’m describing. What I mean is you have a level and instead of seeing the whole level at once, you have a camera, or viewport set up to show only a small part of the level. Not sure how the camera is set up and it’s size etc.

Since all the tutorials I’ve been through so far are indeed set up so that you can see the entire map on one screen because that suited the type of game they were. ie they’re just single screen games and you can’t go anywhere else.

The camera is a virtual concept.  In the games I’ve made that use a camera concept, the whole screen is the viewport. You just move objects on or off screen as needed. Generally, this involves using a display.newGroup(), inserting your objects that you want to move around and then you move the whole group around and what comes on screen is in the camera view.

Rob

If you are comparing it to something like Unity, where you set the type of camera and either size/field of view, then there’s nothing like that in Corona - not built in anyway.

Corona’s screen is like a Unity UI Canvas set to Screen Space - Overlay. Basically objects are either within the ‘bounds’ of the screen and therefore the ‘camera’, or they aren’t.

If you wanted to zoom in Unity, you would change the size of the camera. In Corona, you would scale a group containing all of the objects so that more/less of them are visible on screen.

If you wanted to scroll the level right in Unity, you would move the camera right. In Corona, you would move the group containing all of the objects left.

Oh right I see, I didn’t realise that. So basically if the screen size is set to 320x480 in config.lua then if I make a level that is 1000x480 then by default it will be several times bigger than the camera?

in almost all programming environments (whether 2d or 3d) a “camera” is merely an abstraction (if even provided) - there really is no such thing as a camera, all that a “camera” represents is a transform between world coordinates and view coordinates, and you can easily make your own.

experiment:

take a sheet of 8.5"x11" paper and imagine that that is the extent of your world.  hand-draw some tiles and little sprites around it, if it helps.

now take a 3"x5" index card and cut the middle out of it, leaving only a narrow frame around the edge, and imagine that that is the extent of your view (ie, imagine this as your phone, the cutout area is its screen)

now position the index card on top of the paper and slide it around - that’s what a “camera” does.   (aside:  in 2D, “viewport” is perhaps a better term than “camera” since there’s no perspective or etc)

but now, let’s get practical, for programming purposes:  hold the index card fixed, because you can’t actually move the device with your code.  so instead, move the paper underneath in the opposite direction to which you wish the “camera” to move.  because what you can move is your world.  it’ll have exactly the same visual effect, and that’s how “cameras” are actually implemented.  (this is true even in 3D/OpenGL/Unity/etc, though the process is more ‘complicated’)

if it helps, simply name your master display group “camera”.  now you can move your “camera” (just remember the opposite directions)

@hasen6,

Hi.  If you can take some time to read these questions and provide clear and concise answers, you’ll get better assistance:

  1. What genre of game are you making?
  2. What games are similar to your idea?  (Be specific, links and or videos are helpful).
  3. Define what you mean by level.  (How big? Loaded all at once? Loaded over time and as needed?)
  4. Define what you mean by camera. (How does it behave?  Can you think of games that have a similar ‘camera’?  If so, provide video links from youtube or at least links to the game in GooglePlay/iTunes connect).

I know this probably seems like I’m asking a lot, and that the answers may seem ‘obvious’, but they are not.

You’ve asked two big questions (level editing and cameras) in one thread.  The concepts of levels and level design are specific to genres and games.  There is no universal level design methodology that fits all game styles.

I am not clear you know what a camera is (in the mathematical and rendering sense), and while you really don’t need to know, it is helpful to have at least a high level understanding.

(Above statement not meant to be insult or condescending.  The facts are: 1. Not everyone participating in the forums has a background in the fundamentals of rendering which is where you would learn about this concept in depth.  2. There is no agreed upon vocabulary for discussing them and this makes talking about topic difficult.)

I’m working on my own project today, but there is some relation to your questions.  So, based on the response I see and my own schedule I’ll see if I can’t give some concrete answers when I know more about what you’re really looking for.

Till then, be aware that SSK2 has a camera module.  You can see the code and assuming you understand basic Corona concepts like display groups, enterFrame listeners, and discrete and/or physics based movement you can figure it out.

(In my experience, cameras that track objects moved with transition.* do not work well.)

Finally, SSK2 has with a validation suite (tests), and includes four camera tests (SOURCE):

  • (8) Camera - Tracking
  • (9) Camera - Delayed Tracking (not a great feature; experimental really)
  • (10) Camera - Loose Rectangular Tracking
  • (11) Camera - Loose Circular Tracking

https://www.youtube.com/watch?v=_9ardhNwNRw&feature=youtu.be

That’s a really good explanation. I guess engines like Unity and Gamemaker Studio make it seem like it’s a real camera moving about. Having the background scroll in a scrolling shooter would seem obvious to program for me but to have it follow a player seems a bit more fiddly. But I guess it’s just always going in the opposite direction that the player is.

  1. I don’t have an exact game in mind yet, I just want to make a relatively simple game albeit one that I can actually release to the iOS store. I’ll probably make a vertically scrolling space shooter of some sort.

  2. Any simple vsseu really. Once I have the basic engine made I’ll work on it from there to make it something worthwhile.

  3. A level loaded at once.

  4. A camera following the player like in a simple platform game. Things like the slight delayed tracking and also camera shake would be interesting to learn about too.

I’m a lot clearer on everything after the explanations given here. It’s certainly a friendly and helpful community.

@hasen6,

  1. I don’t have an exact game in mind yet, I just want to make a relatively simple game albeit one that I can actually release to the iOS store. I’ll probably make a vertically scrolling space shooter of some sort.
  • You’ve conflicting goals here.  You want to learn, but want to sell the game too?  Better to learn and not release it.
  • Are you sure you can’t point to at least ONE game you’d like to make your game similar to?
  • http://shmup.wikia.com/wiki/Category:Vertically_Scrolling_Shooters
    • Video links:
      • Xevious (Great game to remake)
      • Vulgus
      • 1942 (Another great game to remake for learning; You can find assets for this online for free (search for Sprite Kit ))

 

 

  1. Any simple vsseu really. Once I have the basic engine made I’ll work on it from there to make it something worthwhile.

vsseu ?  Typo or acronym I don’t know.

 

  1. A level loaded at once.

Roger that.  Note A vertical scrolling space shooter does not use a ‘load at once’ level unless you scroll to the end and the level ends.  Also, this would have to be a small level or you may find it lags during loading.

 

  1. A camera following the player like in a simple platform game. Things like the slight delayed tracking and also camera shake would be interesting to learn about too.

I’ve built a couple of scrolling shooters and I never once thought about a camera.  I just have my backgrounds that I scroll at a certain speed. When I detect background1 is off screen I move it to the other side of background2 or 3 or 4 (depending on how many backgrounds). You have to use a repeating set of images to make this work.  If I have parallax backgrounds, they will move the same way as the background just a little bit faster and use the same “detect when off screen and reposition” technique.

For game objects I create them just off screen then their move code moves them across the screen as needed.

Rob

@Rob - Yeah, that’s why I’m trying to tease out exactly the game the OP wants to make. 

I see folks asking questions based on their assumptions regarding what they need, instead of simply asking,

How do I make this game (or one like it) and where can I learn more about how it is made using Corona?” 

i.e. The OP assumed that a camera is involved in making a shooter and depending on the shooter type, that may or may not be the case. :\

I gotta stop reading and answering the forums… but I found some possible leads for you on things to investigate for the purpose of learning:

There are a ton of these out there.  I tried these google searches:

  • vertical shooter corona 
  • vertical shooter tutorial corona 
  • vertical shooter tutorial corona github

VSSEU = Vertical scrolling Shoot 'Em Up.  :lol:

Yes I realise that, my question was also about general platform games. Just cameras generally. Not necessarily in regard to exactly the first game I will make now.

Thanks for all the replies. I’m clear now that the camera size basically equates to the screen size set in config.lua.

Still one thing I’m not clear on though is, the camera size is set by the screen size but how do you set the level size? I haven’t noticed in any code where that is set exactly. If I want to set the level to be larger than the ‘camera’ then I have to make it larger than the screen.