Just thought I would make a quick post about what I’m doing. I have decided to rewrite/refactor all of Lime. My plan is that the front facing API/LDI won’t actually change so that you are able to drop the new code right into your project and keep going with it. There will be a couple of very small changes but it will be pretty much the same.
The main reason for this big change is that I hope the restructure (and more importantly the different OOP method) will save some memory to help speed everything up. However if this doesn’t actually speed things up I will still have a much better organised codebase, rather than the monster that it is now, which will allow for easier debugging and adding of new features.
I hope to have a workable version of this by tomorrow for anyone that wishes to try it. [import]uid: 5833 topic_id: 5222 reply_id: 305222[/import]
wow, by tomorrow? You are one lean mean coding machine. Refactoring is always a big deal for me because in the it will have to work the same way as before or better.
Care sharing your plans? Perhaps the hive mind can help you out here and there. [import]uid: 11334 topic_id: 5222 reply_id: 17391[/import]
The faster I get it done the faster you guys can tell me what I’ve broken And what else do I have to do, apart from my job and other projects
The main difference is how I handle objects (not in the Tiled sense, the OO kind)
In the current version of Lime I create my objects pretty much like this:
function newObject()
local self = {}
function self:sayMessage(message)
print(message)
end
return self
end
Which all works fine however what I didn’t realise was that with Lua every time one of these “objects” is created all the code is duplicated rather than being shared, and as all Tiles, Layers etc are objects like this that is a whole lot of code being stored in memory.
So instead of this I am moving over to using metatables. My new objects will look more like this:
Class = {}
Class\_mt = { \_\_index = Class }
function Class:new()
local self = {}
setmetatable(self, Class\_mt)
return self
end
function Class:sayMessage(message)
print(message)
end
This will mean that each new instance of a Class will automatically use the same shared code, hopefully saving a whole lot of memory.
I’m not entirely sure if this will actually help but as I say it should allow for a much better organised project, which is still a win. [import]uid: 5833 topic_id: 5222 reply_id: 17393[/import]
I can see how that will cut down the memory usage though I am not sure about the performance, are you displaying each tile as tile objects in the current design?
PS: Lime forum is gone. Might want to check with Corona about that [import]uid: 11334 topic_id: 5222 reply_id: 17397[/import]
Not sure how I overlooked them before, however I am new to Lua so I will blame that
Yup, each Tile created in the current version is an object of the first type detailed above. So is a Map, TileLayer, ObjectLayer, Object and Property Doing it the new way should help I hope.
I have the first version ready, it is just the visual stuff right now, no physics stuff. Camera stuff isn’t in yet either.
I’m not sure how I will sort out the versioning of this though just until it becomes the real version. Should it be Beta2.1 or something else?
The forum seems to be here now, may have been a mistake when they reshuffled things.
Edit -
Physics is now in. [import]uid: 5833 topic_id: 5222 reply_id: 17409[/import]
As I now have a version working with visuals and physics I figured I’d make a quick build and test it out on my device (a 2nd gen iTouch). And the results are…less than exciting
It is still unbearably slow on the device, but this still doesn’t have any visual/physical clipping going on which I do think will be the biggest speed boost.
On the plus side my code is much more organised now, which makes it all easier to understand for both myself and anyone else that is unlucky enough to have offered there assistance in fixing the speed issues
It’s 4am now so I guess I should go to bed, got to start the “day-job” in a few hours but after that I plan to keep bringing over the rest of the features so that this will be the de-facto Lime beta version. [import]uid: 5833 topic_id: 5222 reply_id: 17425[/import]
Also, do you happen to know if there is a way of using .net style properties in Lua? I’m guessing not so on the other hand is there a way of setting a public read-only variable? [import]uid: 5833 topic_id: 5222 reply_id: 17483[/import]
Wow. I was down with flu for a couple days and the whole world has changed in that time! Thanks for all your hard work. Look forward to trying this new version. [import]uid: 11904 topic_id: 5222 reply_id: 17658[/import]
I have this new version ready to upload for testing however I’m not sure what to do about version numbers. Should this be Beta 2.1? Or Beta number 2, version 1. [import]uid: 5833 topic_id: 5222 reply_id: 17666[/import]
I am hesitant to call it version 2 actually, it infers that there is already a version 1 in production. [import]uid: 11334 topic_id: 5222 reply_id: 17667[/import]
Thanks. Still not 100% so take the rest of this post with a grain of salt!
Why not continue on with the 19, 20, 21 approach? Until you open up beta we can call these alpha versions if you like. When you reach the stage where you are comfortable with an open beta then you can reset the numbering to something like Beta 1, beta 2 etc.
Look forward to trying this new version. [import]uid: 11904 topic_id: 5222 reply_id: 17668[/import]
Please keep a backup of your project in the 2.0 stage in case it all explodes going to 2.1
In theory near everything is the same, however a few places have changed ever so slightly that they may cause some problems.
Please just post here whatever problems you come up against and I will sort them out as soon as I can. [import]uid: 5833 topic_id: 5222 reply_id: 17672[/import]
I decided that at somepoint I would run out of fruit names (apparently Apple might already be taken) so it was better to cut my losses now and this way everything is easier to look at. For the curious, pretty much everything in Map, TileLayer, ObjectLayer, Tile, Object and TileSet was all in Lychee. As you can imagine, that was quite a bit
Plus looking at the code when fixing bugs just made me hungry. [import]uid: 5833 topic_id: 5222 reply_id: 17679[/import]