Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to allow player generated levels?
Started by d.mach Oct 17 2019 12:59 AM

- - - - -
5 replies to this topic
player levels level editor user generated content
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 967 posts
  • Corona SDK

I wonder if it is possible to allow players to generate own levels which they later can trade or make available for others to play somehow?

 

Are there any best practices on how to achieve this? Where can levels be stored, so others can get them?

 

Any help and ideas welcome.

 



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,240 posts
  • Corona SDK

There are countless ways of accomplishing this. What the best way is really depends on what kind of game you are working with.

 

The most ingenious approach that I've seen was one game (can't remember its name) that had quite a simple level structure which allowed for creating levels solely out of ~8-12 character strings. Disclaimer: while I found this algorithm based approach to be ingenious, it is far from beginner friendly. So, if you have a character that can be anything between 0 and 9 or from a to z, then two subsequent characters can make 36 x 36 = 1296 combinations. The game used these to position a few display objects on the screen, such as the player starting location, level type and art style, level finish, etc. So, the players didn't actually need to download or upload anything, all they needed was to share the ~8-12 character string that the game would use to create the level.

 

 

Now, a more standard and perhaps the most common way would be to setup a server and a database, see LAMP stack. Your app would connect to a database on your server via a PHP or some other script and it would upload and download the levels from there. You'd need to setup some data validation and security to make sure that only playable levels can be uploaded and that any unwanted connections are ignored, etc. If you save custom levels as json files in your app's documents folder locally, then you can easily send and receive the levels as text strings, with no need for any file transfers.



[TOPIC: post.html]
#3

remiduchalard

[GLOBAL: userInfoPane.html]
remiduchalard
  • Contributor

  • 306 posts
  • Corona SDK

Hello,

 I have done that for one game. If you want I can send you the code.

In my game, I made level design with json file.

All object have a uid and when I want to display it with my json, I make an object with the uid, the x, the y, the scale, the rotate. Everything it s define like this.

In my game I have unit who spawn in a special order. In an array, I write the uid of the unit, the delay and where it spawn.

I hope you understand how to make everything display with a json.

How the user generate the json?

On map editor, the user have only visual button. He select the unit to display with a button and then click where he want the unit to spawn. I record the uid of the unit, then the x and the y and when he spawn the unit.

For map object, the user can't do it but it s the same thing.

At the end of the map editor. The user can choose to save the game and have to write a string for the savegame name. Then the file is send to a server.

When a user want to play this level, he have to write the level name, the game will search on the server the json file and load it.

 

Map editor for player are very simple but it can be really help full for you to make a very powerfull one for you. Like this you will be able to create new level in a few minutes. With the keyboard you can write the id of the object. Click on the screen to set the x, y... I have done that to my game and it really help me for the level design.

 

Good luck



[TOPIC: post.html]
#4

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 967 posts
  • Corona SDK

Thanks for your fast and detailed input! Much appreciated!

 

Can you please tell me more about how to use a server? What is the best option here and what are the costs?



[TOPIC: post.html]
#5

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,240 posts
  • Corona SDK

I would recommend setting up LAMP on Amazon Web Services. It may sound and seem intimidating at first, but there are great and easy to follow tutorials for how to set one up, e.g. https://aws.amazon.com/getting-started/projects/launch-lamp-web-app/ or just google "amazon aws lamp stack" and you'll find step by step video tutorials as well.

 

The reason why I'd recommend AWS is because 1) it is secure, 2) it is easily scalable if and when needed, 3) it is also affordable. If, for instance, you don't expect a lot of traffic, you should be able to get by with AWS free tier, so your annual costs might be around $10 plus your personal time.

 

LAMP simply means Linux, Apache, MySQL and PHP. Your main interests would be with the MySQL and PHP parts. From your app, you'd make a network request that connects to the PHP script on your AWS server. The PHP script will then either add a new level to the database or download a level from the database. You should check a PHP + MySQL tutorial for that.

Then there's the stuff about data validation and such, but you can get into that once you get a grasp of the basics.


  • pixec likes this

[TOPIC: post.html]
#6

d.mach

[GLOBAL: userInfoPane.html]
d.mach
  • Contributor

  • 967 posts
  • Corona SDK

Thank you for your useful help! Much appreciated!




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: player, levels, level, editor, user, generated, content