Difference between revisions of "Tuto tiny-ecs beatemup Part 1 Setup"

From GiderosMobile
 
(6 intermediate revisions by the same user not shown)
Line 24: Line 24:
  
 
== Files and Folders ==
 
== Files and Folders ==
This is how I would organise my files and folders:
+
This is how I organise my files and folders:
  
''Gideros_Game_Template1'' (''root'')
+
''Gideros_BeatThemUp'' (''root'')
 
* ''Plugins''
 
* ''Plugins''
 +
** Bump
 
** JSON
 
** JSON
** Require
 
 
* ''Files''
 
* ''Files''
 +
** '''_C''' (''folder'') ECS Components
 +
** '''_E''' (''folder'') ECS Entities
 +
** '''_S''' (''folder'') ECS Systems
 
** '''audio''' (''folder'')
 
** '''audio''' (''folder'')
 
** '''classes''' (''folder'')
 
** '''classes''' (''folder'')
Line 39: Line 42:
 
**main.lua (''file'')
 
**main.lua (''file'')
  
 +
The underscore (_) allows us to group the ECS folders.
  
Let's add our first Classes/functions. In the folder '''classes''' add these two:
+
In the folder '''classes''', you should already have:
 
* '''[[Media:buttonMonster.lua]]''' for player control and keyboard navigation '''(tip: right click and save link as)'''
 
* '''[[Media:buttonMonster.lua]]''' for player control and keyboard navigation '''(tip: right click and save link as)'''
* to save data persistently, in the ''classes'' folder, create a file called "'''save_prefs.lua'''" and copy the following:
+
* "'''save_prefs.lua'''" to save data persistently (please see code below)
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
require "json"
 
require "json"
Line 66: Line 70:
  
 
== Assets ==
 
== Assets ==
To build your personalized Game Template you will need some assets like sounds, fonts, ...
+
At the time of writing I cannot upload the assets to the Wiki so I will host the files on GitHub.
  
In this tutorial I will use my own assets and you will need to replace them with yours in both files and code.
+
You can download the assets for this tuto at this address:
 +
 
 +
'''https://github.com/mokalux/gideros_wiki_repository/tree/main/tuto_beu_cbump_tecs_assets'''
 +
 
 +
and the zip file ("''Download raw file''"):
 +
 
 +
'''https://github.com/mokalux/gideros_wiki_repository/blob/main/tuto_beu_cbump_tecs_assets/tuto_beu_cbump_tecs_assets.zip'''
  
 
== Next? ==
 
== Next? ==
That should be enough to get us started. In the next part we will code our ''init.lua'' file.
+
In the next part we will look at our ''init.lua'' and ''main.lua'' files.
  
  
'''Next: [[Tuto Gideros Game Template1 Part 2 Init]]'''
+
'''Next: [[Tuto tiny-ecs beatemup Part 2 Init and Main]]'''
  
  
 
'''[[Tutorial - tiny-ecs beatemup]]'''
 
'''[[Tutorial - tiny-ecs beatemup]]'''
 
{{GIDEROS IMPORTANT LINKS}}
 
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 02:22, 25 November 2024

Setup

As mentionned in the introduction, we will use the Gideros Game Template1.

So make a copy of your Gideros Game Template1 and rename it to anything you want, eg.: "Gideros_BeatThemUp".

Project Properties

  • Scale Mode: Fit Width (or anything else really :-) )
  • Logical Dimensions: 360 * 640 px
  • Orientation: Landscape Left
  • FPS: 60 VSync On

Feel free to configure the other tabs.

Plugins

  • Bump: to handle collisions
  • JSON: to save user preferences to disk

We need to add the "plugin" for tiny-ecs, please grab it Media:tiny-ecs.lua (tip: right click and save link as) and put it in the "classes" folder.

Note: the file is supposed to be tiny-ecs.lua but MediaWiki puts a Capital letter :-(

We will add more Classes later on.

Files and Folders

This is how I organise my files and folders:

Gideros_BeatThemUp (root)

  • Plugins
    • Bump
    • JSON
  • Files
    • _C (folder) ECS Components
    • _E (folder) ECS Entities
    • _S (folder) ECS Systems
    • audio (folder)
    • classes (folder)
    • fonts (folder)
    • gfx (folder)
    • scenes (folder)
    • init.lua (file)
    • main.lua (file)

The underscore (_) allows us to group the ECS folders.

In the folder classes, you should already have:

  • Media:buttonMonster.lua for player control and keyboard navigation (tip: right click and save link as)
  • "save_prefs.lua" to save data persistently (please see code below)
require "json"

function saveData(filepath, value)
	local contents = json.encode(value)
	local file = io.open(filepath, "w") -- create file
	file:write(contents) -- save json string in file
	io.close(file)
end

function getData(filepath)
	local value
	local file = io.open(filepath, "r")
	if file then
		local contents = file:read("*a") -- read contents
		value = json.decode(contents) -- decode json
		io.close(file)
	end
	return value
end

Assets

At the time of writing I cannot upload the assets to the Wiki so I will host the files on GitHub.

You can download the assets for this tuto at this address:

https://github.com/mokalux/gideros_wiki_repository/tree/main/tuto_beu_cbump_tecs_assets

and the zip file ("Download raw file"):

https://github.com/mokalux/gideros_wiki_repository/blob/main/tuto_beu_cbump_tecs_assets/tuto_beu_cbump_tecs_assets.zip

Next?

In the next part we will look at our init.lua and main.lua files.


Next: Tuto tiny-ecs beatemup Part 2 Init and Main


Tutorial - tiny-ecs beatemup