Hi all.
After reading a post about how to develop a classic OutRun game from
http://codeincomplete.com/posts/2012/6/23/javascript_racer_v1_straight/, I have developed part of this code to Gideros / lua.
It works smoothly in Gideros Player but really slow in my Samsung Galaxy Ace. I guess main problem is that a simple port always redraws again all polygons of the road in every frame as actually sample javascript code does.
Better solution is to build an static set of array of polygons and change only color and textures.
Any suggestions or someone who had try similar issue? I attach my current testing Gideros project.
Comments
I think you'll need to manage things so that you are removing old children before adding new ones and maybe just adding the player once outside the update loop.
I will manage this, because original javascript code manages it for itself.
Thanks.
Glad to see someone picked up on this. I had a "very" quick look at the code and noticed the slowdown straight away. I think your using shapes to draw the road segments, you should get a massive performance boost, if you just pre allocate a pool of shapes and then just reorder them instead of allocating a new bunch of shapes each frame - also you won't have to worry about removing the old ones.
Hope you managed to get the rest of the part's implemented as this could be a decent showcase for Gideros.
Likes: fxone
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Gideros Player works ok and Samsung is working but not really well. I guest I will need implement a segment cache with the previous created shapes and just changes colors.
Anyway you could try if this prototype works smoothly in other real mobile or tablet devices.
After some research about how to improve rendering performance of segments, I think it is not so easy as simple changes color, because about 60 segments are created on each frame, but projections are calculated again.
Anyway I am not sure if create a shape pool (lua shape table) will increase the performance so much, so Does any one know if creating objects consumes a lot of CPU time and if Gideros is optimized in this sense.
I know the best option is to create a rendering plugin in C++ but this will be reimplement part of Gideros, something I want to avoid.
I hope for suggestions. Thanks.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
I guess pseudo-3d is better use C++ native as SDL not Gideros indeed.
Anyway I will share my code in github of this prototype game, so Gideros community can improve it or brainstorming about this issue.
Your effort is amazing and if others interested would try to optimize it, it could become something better.
Likes: SinisterSoft
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
https://deluxepixel.com
@OZApps, I have a filling you think you've missed a lot, trying to digging up all the old topics
Filling is what you put inside a hollow, like the meat filling in a pie
what you meant was feeling which is an emotion.
Darn, I ended up with correcting you
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
I know the difference and understand it completely, just my hands sometimes type the wrong word, and I'm too busy with the content to notice it
Likes: OZApps
https://github.com/jdbc2012/race
I am thinking how to store a track information: it means store when curves, hills and z axis information, may be a simple lua table.
How do you suggest to use Mesh for drawing segments?
Is there a way to convert Shapes into Mesh?
Just provide vertices coordinates and fill them with colors as you did with Shapes.
The performance improvement should be significant.
Anyway it is not enough for slow mobiles, but increases a lot the performance. I will try on Xcode for iOS.
Next optimization I can think of is either:
1) use pooling, as in place used segments in pool and reuse them later when needed
2) (which I think should be even better, but is tricky) use only one single Mesh object for everything.
If everything was a mesh, there will be only one object to render !!!
I will try (2), replacing rectangle and polygon childs by vertices and index on the mesh.
It seems performance are better, it could be a first approach to have a 2.5D engine. Of course for even better performance we could avoid segments do not belong to road, or have only a mesh to describe road + sides.
For math calculation, I guess we can use a C++ funcion providing a set of points and returning a set of points with the results.
I will try maths then.
Likes: fxone, tanerhun, OZApps, hgvyas123
So is it with C math already?
I have been studying lmathlib.c from lua 5.1.4 source code.
My first try will be replace Utils.lua with a simple call using LUA C API, that is calculate screen coordinates from world ones. I will use cmake to compile for Windows.
I guess using LuaJIT + FFI we can make projection maths with native C, so basic 3D as my prototype can be done using Gideros + LuaJIT.
The file testffi.lua (declared in the gproj file) is missing, and removing it crashes the gideros windows player with a visual C runtime error