Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Top down multi-level background images question (for moblie devices)
Started by nml2727 Sep 10 2019 06:23 AM

7 replies to this topic
mobile background image sprite multi-level
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

nml2727

[GLOBAL: userInfoPane.html]
nml2727
  • Observer

  • 4 posts
  • Corona SDK

Hi,

 

This will be my first Corona game.  I am familiar with programming but not much about best practices regarding game design. 

 

I am making a top down game (for mobile devices) where the player has to travel along a path and get from the start to the finish with enemies along the way.  The camera will follow the player as they travel along the paths.  There will be boundaries so the player can only travel where the path (or paths) lead to. 

 

I am planning to make several levels (20 to 30) which will have different paths. 

 

I am planning to make one large background image for each level.  

 

My question is 2 part:

 

1. How do I go about figuring out how big the background image should be?  I'd like the levels to only take about 5 or so minutes for the player to travel from start to finish.

 

2. Is the best way to make a separate image for each level?  I'm not sure if that will require an excessive amount of space or is that standard for games with multiple levels?  

 

Any advice would be really appreciated. 



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 893 posts
  • Corona SDK

Hello and welcome to the forums!

 

You weren't that clear, so my answer may be a hit or miss.

 

Without knowing anything about your game, other than that it uses top down perspective, there is no way to answer this first question accurately. You want to be careful with the size of your images (and image sheets) because large images require large amounts of hard drive space and they consume large amounts of texture memory. Additionally, you will find it hard to find individual images that will cover all possible Android screens.

 

Now, to possible solutions. When creating large maps, especially from top down perspective, one relatively easy and effective method is to create the levels using tiles. There is a good, free tile map creator called Tiled (https://www.mapeditor.org/) that you can use to draw your maps. Technically, you could have as small or as large maps as you'd want. Since the maps would consist of individual tiles, your texture memory or hard drive space requirements would not grow out of hand either.

 

There are a few ready made tile engines (or tile loaders) for Corona, e.g. Berry and PonyTiled.

 

If you setup a camera to follow the player and you center the map, then you could create vast maps without losing any performance (depending on what tile engine/loader you use and how they work). You can also add properties to tiles in Tiled, such as physics bodies that you could use to define the areas the player can go, etc.

 

The reason why I would recommend looking into tiles instead of large individual images is that if you were to create 20 to 30 large maps consisting of individual images, then your game will quickly bloat and making changes to the levels later on could prove very cumbersome.

 

Hope that helps.



[TOPIC: post.html]
#3

nml2727

[GLOBAL: userInfoPane.html]
nml2727
  • Observer

  • 4 posts
  • Corona SDK

Thanks for the quick reply!  Yes that does help a lot.  

 

So if I go the Tiled route, and create 30 different levels, but use mostly the same tiles, you are saying that when I export those separate levels and incorporate them into the Corona SDK, it is smart enough to know that all the levels came from the same set of tiles and won't use a lot of space?  

 

Regarding setting the properties directly in Tiled, could you give a very simple example of how I would then access that property from my main.lua file in Corona?



[TOPIC: post.html]
#4

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 893 posts
  • Corona SDK

Yes, every map created using tiled will have a reference to what tile sets (images) were used in creating it. You won't need duplicate image / image sheet files.

 

For the custom properties in Tiled, I'd recommend you to look into https://doc.mapeditor.org/en/stable/manual/introduction/. How you'd access them from your Corona project then depends entirely on what tile engine/loader you'd use, or whether you'd create your own.



[TOPIC: post.html]
#5

richard11

[GLOBAL: userInfoPane.html]
richard11
  • Contributor

  • 464 posts
  • Corona SDK

If you're going the Tiled route, you might want to consider Qiso too =). Isometric graphics are harder and more time consuming to design, but programmatically Qiso supports camera following, path-finding, and movement boundaries right out of the box so it might be a good fit for this.

https://qiso.qweb.co.uk

[TOPIC: post.html]
#6

nml2727

[GLOBAL: userInfoPane.html]
nml2727
  • Observer

  • 4 posts
  • Corona SDK

Thank you for the information.  I decided to give Tiled a try with PonyTiled.  So far it has not been a great experience.  

 

I keep getting  "attempt to index local 'data' (a nil value)" messages in ponytiled.lua:79 in function 'new'.  

 

Seems like I might be missing something it is expecting from Tiled?  I was under the impression that the only thing I needed to do from Tiled after making the map was export it as a .lua file.  Are there more steps involved in exporting the map to Corona that I might be missing?



[TOPIC: post.html]
#7

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 893 posts
  • Corona SDK

When posting about issues with your code, it is always useful to include a sample project that demonstrates your issue, or at the very least post your code.

function M.new(data, dir)
  local map = display.newGroup()
  dir = dir and (dir .. "/") or "" -- where does the map live?

  local layers = data.layers

Since your crash is occuring on line 79, it would suggest that you have not included the data table, or if you have, then there is something wrong with it. It could be that Tiled has since been updated and things have changed, or something else.

 

Have you tried looking at the sample project at https://github.com/ponywolf/ponytiled?



[TOPIC: post.html]
#8

nml2727

[GLOBAL: userInfoPane.html]
nml2727
  • Observer

  • 4 posts
  • Corona SDK

I did look through the project briefly, but I will go back through once more and take some more time on it. 

 

Just to make sure I'm understanding, when you say "have not included the data table", is that the same thing as the .lua file that is generated when I export the map from Tiled?  Or is it a different file related to the tile images themselves?




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: mobile, background, image, sprite, multi-level