It looks like you're new here. If you want to get involved, click one of these buttons!
Hi beta-people
It's been a while since the last beta, sorry about that.
Codea is getting a lot of improvement now, though.
1.5.3 will focus on adding some missing, useful functions to the API (restart, alert, perhaps programmatically creating projects, and so on). As well as optimisations to common rendering scenarios — such as sprite()
This first release integrates an experimental new feature: automatic sprite batching. It is enabled by default, you can see the release notes for more information.
Basically it attempts to draw consecutive calls to sprite as a single mesh(), if possible. This should allow you to do things like render particle systems with sprite(), as well as speed up common uses like lots of the same enemy type being rendered over and over.
There's also been a lot of other optimisations to sprite() — I'm hoping that many people will find less of a need to implement their code using mesh() due to performance concerns. That is, I'm hoping that sprite() will be "good enough" for a lot of uses.
(mesh() is great, but it requires you to carefully structure your code to work with it. It's also less intuitive to use.)
If you'd like to see a demo of how sprite batching makes a difference, try out the following Gist:
https://gist.github.com/TwoLivesLeft/5692210
This renders 1600 sprites using a number of different methods (including mesh()). You can toggle on/off the different uses.
EDIT: Fixed link
Comments
UI bug: When I run a fullscreen app, the (new?) icon in the upper left to bring out the sidebar with the console output, when tapped, pops it out, then immediately hides it again. This happens anywhere from 5 to maybe 20 times - ie. I tap, expose/unexpose, I tap, expose/unexpose - then it "fixes" itself, and behaves like you would expect (tap, it exposes the sidebar. tap the close, sidebar goes away).
is there a way to kill that button entirely (and the buttons along the bottom)? FULLSCREEN_NO_BUTTONS (which isn't listed by the tooltip, but is in the docs) behaves weirdly - I get no buttons until I tap, then they all come back.
Nice to see the sprite optimization - I expect you've hit on a common case, this should be helpful in lots of stuff. I've been crazy busy with Amazon Web Services, so I've neglected my Codea work; there is no AWS library for lua. Hmm. Maybe I should make one... (The AWS API is very fragmented - it would be a chunk of work...)
Hi Simeon. Great news!
Problem with your gist: the project is pulled corrrectly, but:
- tabs are not in good order : i had to move the Juice class manually just after the main to have it compile.
- then i get the error:
error: [string "-- Juice..."]:78: attempt to call method 'draw' (a nil value).
It seems that you renames rect:draw into rect:drawObject. I created a :draw, then no error. But when i click a choice i get errors again.
So:
- either you didnt post the good final project.
- either it is a tab order problem: could you rename the tab in: T00... T01... Etc so they come in the appropriate order?
Oops! Hadnt seen the Juice thread yet! Sorry for posting this.
@Jmv38 drawObject is correctly named. The draw method is in the base class which invokes drawObject
I tried the alert(). Works fine in the setup(). Then i put it in touched(touch) and then when i touch the screen, it goes dim and codea freezes. Have to kill it manully.
@Bortels that's an odd one. The sidebar button has been there since 1.5 — does anyone else have this issue?
@Jmv38 thanks for reporting the alert() issue. I'll check it out
@Bortels just a thought — you're not calling displayMode(FULLSCREEN) at the start of draw()? That would cause the behaviour you're describing, as it would be resetting the fullscreen mode every frame.
@Jmv38 alert() issue in touched() should be fixed in the next build. It's an iOS 5.x specific bug that was easy to work around.
I am. Where should it be, in setup?
Yes (or on some action, such as a button press) — if you call it every frame it will keep resetting the screen mode back to full screen. Pressing the sidebar button simply toggles the displayMode, but your code is resetting it back immediately.
@Jmv38 out of curiosity, does the sprite batching make much difference on iPad 1? (You can try it in the gist I linked: https://gist.github.com/TwoLivesLeft/5692210)
I don't have an iPad 1 for testing at the moment. So I wonder if it makes a big difference there.
Edit: fixed link
This link is to Juice, which has only 1 sprite?
I tried with Spritely: with 400 sprites the fps oscillate between 50-60 fps, which is, i think, better than before. But to check it i should revert to the previous version of codea.
My other programs use meshes.
Sorry! Wrong link
This is the link: https://gist.github.com/TwoLivesLeft/5692210
There should be 1600 sprites
Here are the results:
- initial 4.0 fps.
- use string false: 7.7 fps.
- use mesh or use batch : 14.5 fps.
So is is about x2 improvement from the regular sprite usage (i always load them in memory). And using the mesh is not better.
Btw i had a memory crash while playing with the options (setting batch and mesh on).
When you create your mesh from sprite images, how do arrange them? There may be a lot of lost space when image sizes do not fit? Or do you use a smart algorithm to arrange them?
@Jmv38 Thanks for testing it out. Good to see there is some improvement! Codea won't auto-batch over multiple textures. It behaves similar to mesh in that there is one texture per batch.
I think the worst-case in the old version of Codea (1.5.2) would have been a lot slower than 4.0 fps on iPad 1, the string (and non-string) lookup mechanism was substantially improved in 1.5.3.
@Simeon: FYI, on a 4th gen iPad, here are the numbers I'm getting:
@Simeon: What do you think the chances are of including the feature to optionally disable tab compilation/execution in the next release? It's not critical, but my hope is that it might be a simple enough task that it wouldn't take too long to implement.
@toadkick I would like to but it's slightly tricky for a number of reasons — the actual functionality is not hard, but the colour schemes will need new states for disabled tabs and dependent projects will need to respect them. I'll keep it in mind, but I can't say for sure.
Just sent out beta 2. This includes Air Code — see the release notes for a brief overview of how it works. Let me know how it goes for you.
@Simeon: fair enough
BTW, AirCode works great, this is a very cool feature!
Aircode rocks. Having said that - it would be nice to be able to "re-attach" a session after you break out (in my case, to look at the docs).
I also notice it doesn't re-interpret setup() when you change it - I added a global to my draw loop (rotate(r)) - and it barfed, so I added "r=0" to setup() - no luck, even with ctrl-r.
This is a good opportunity to ask - are the docs online? I've been so busy at work I've been out of touch, and if they're up, I dunno where (and neither does Google, which is a seperate bad thing; the first link there, for Codea 1.5, has a page that says "Documentation", no link to anything) - before, docs online would be convenient, but with aircode - they're essential.
BUT - those are quirks. This is awesome. I hope I can make it work at work, where we have some pretty silly/draconian wireless policies on our setup. :-)
@Simeon: If you have a chance, would you mind explaining how you pulled this off (mainly on the Codea side, as I can see the page source from the browser side)? I am very interested in the implementation behind this.
The main reason I'm curious is because I'm also curious about whether bits of this could be integrated into the Codea API to allow us to do similar things from within our Codea programs.
@Bortels thanks for the feedback!
Air Code reloads the code in the current file when you make a change. It does re-interpret setup(), it just doesn't re-run it (or else it would restart your project on every code change). This allows you to edit code and see visual changes in the current state of the app. (And if you pause your app then Codea will frame-step on Air Code changes.)
Cmd+R (or Ctrl+R) from the code editor should have worked, that will restart the project, running setup() and so on. I wonder what the issue was.
Re-attaching would be good, the state is entirely URL based, so it should be possible to make it work when you re-launch Air Code. I'll look into it.
@toadkick it runs a web server in Codea, connections are handled by Objective-C code that parses the URL and figures out what projects to serve.
When a file is requested the editor document is populated with the file contents and sent to the browser.
When a file is edited in the browser an ajax.post request is made, Codea gets the updated file data and attempts to execute it (lua_pcall). If there are errors, the data is not written to the project. If no errors, then the project is updated — the Lua state will have already been updated from the pcall.
There is some fancy stuff going on in order to allow you to re-execute
MyClass = class()
tabs without overwriting the original class and failing to adjust existing instances. Basically when the changed code comes in, Codea uses a regex to find all class names from their code definitions. Before executing the changed code I check with Lua to see if the class has already been defined, and if so, strip the re-definition from the changed code. I was really happy that this aspect worked out. It lets you do things like alter thedraw()
function for a class and see all the existing instances update immediately.@Simeon: very clever (particularly the part about handling classes), thanks for the explanation!
Confirmed: Alert is ok with ios5.
I had a go with one iPad from another. I know that that's completely daft, but figured someone had to do it. When editing a line, the cursor position was not where it ought to be (the line in question was
camera(0,0,10,0,0,0,0,1,0)
) but was slightly to the right. (This was with the standard Safari browser.)Using Firefox on my desktop worked just fine.
I'd quite like to be able to add, delete, and rename tabs. It'd be really easy to cut-and-paste code from one project to another using this.
@Andrew_Stacey yes, the code editor isn't mobile compatible. Regarding file creation — there are plans to expand on the feature if Apple approves it. I'd like to have a tab bar with a split code view. But I don't want to spend too much time on this feature until I know whether it's allowed.
@Bortels sorry I missed your question — the docs are no longer online, but they are now all YAML source files. If anyone is interested in doing a quick YAML->HTML conversion on them I would be happy to put them up as a GitHub project or similar.
@toadkick we could expose a web server as a Codea API. That would be interesting.
@Simeon: I was thinking along the same lines
I tried a docs conversion in the past - but I don't recall them being in YAML format. It proved to be a far uglier task than I had figured on, and I got distracted by bright lights and pretty colors. Got a link to the YAML docs? I may try it again.
Thanks for the offer @Bortels — they used to be written in JSON, we moved to YAML because it is much easier to write and much more readable.
I've set up an open source project for the documentation here:
https://github.com/TwoLivesLeft/Codea-Documentation
Anyone who wants to help with conversion scripts, submit fixes or improve the documentation in any way, feel free to send a pull request.
@Simeon - I found one possible issue with Air Code (which is amazing).
I ran it on this sample code
https://gist.github.com/dermotbalson/5719306
It worked fine when I loaded the main tab, but as soon as I pressed Crtl-R, even without changing anything, the colours in the image went black.
It is probably because the image is drawn using a shader. This is a stencil (fragment) shader that uses one image to "cut out" part of a second image.
It's not serious, and I guess few people use shaders like this, so it may not be worth bothering with, but that's up to you.
I have quite a few other shader projects, and they all seemed to work ok.
@Ignatz thanks for the report, I've added it to my list. I'll probably only look at bug fixing Air Code if it actually gets approved. The first release is more of an experiment to see if it gets through and into a release version of Codea.
Alert() is great and was a must.
What about extending it a little bit?
I think of the following syntax:
button1,button2,... are strings, displayed as buttons under the message. The number of buttons is leaved to the user.
When the user hits button1 then callback(button1) is fired.
Would really be all we need to interract with the user.
@Simeon any feedback on my suggestion?
@Jmv38 I like your idea a lot — perhaps the callback should take the index of the button pressed (1, 2, 3 ...) instead of the name? That way you can change the button names without having to go and change your callback code.
An alternate API design might be
alert( message, title, { "Button Name" = function, "Button Name 2" = function } )
This is more stable (the button name is strongly associated with the callback, but it is harder to write.
Why not allowing both option? As for tables, we can index them with 1,2,3 or ''blabla1", etc...
My 'dumb programmer' experience is that it is easier for me to remember what i did if i use names, rather than numbers...
Thanks for considering my suggestion.
@Simeon @Jmv38: FWIW, I prefer to be provided with the index. Conceptually it's easier and generates simpler code.
EDIT: also, it's very easy to provide your own "constants", I don't think that design choice should be baked into the API. I prefer the interface to be very simple for alerts.
Anyway, whatever the final syntax, it will be fine for me as long as the functionnallity is there.
Since i can always encapsulate the function into my preferred syntax.
Not sure if this addition will make 1.5.3 or wether it will be in the next update.
Beta 3 is out — @Jmv38 let me know how your physics trouble goes.
This version is probably close to submission. I've decided against including the Juice library in this release. I'm still using it quite a lot and it's changing too quickly to be included at this point.
I'm very happy to see the addition of tween.delay, that should probably solve about 90% of my needs for deferred function calls
While I'm sad to see Juice go, I'm glad you're still cranking on it, and I can't wait to see the final result. I wish more SDKs offered libraries like this, it makes it so much easier to polish an app to a shine.
I'll join on the Sad about Juice. Very nice stuff in there. But I'll trust that by the time it makes its way into a release, it's going to be even... juicier.
Hello guys, i really feel stupid here but... can you have a look at this?
on my ipad the sprite doesnt seem to work in setContext(img): i get not boy in the red rectangle.
See: https://pbs.twimg.com/media/BNO8sAfCYAAqNjw.jpg
Is it a known bug? Or have i missed sthg obvious?
Thanks.
Ps: 1.5.3
looks like some kind of bug, same for me
if you add an ellipse to your custom image (just after drawing the boy), it works....
Thanks for confirm that is a problem @ignatz.
@Simeon can you correct that? The codea doc clearly says sprite is supposed to work within setcontext(img). Thanks
@Jmv38 thanks for finding the bug. I think it's an issue caused by the new sprite batching mechanism. Looking into it.
Fixed