Codea 3.6.1 (353)

@Bri_G ah that should be require 'codea.legacy':export() my bad

I’m about to submit an updated builds with some fixes and additional legacy command support (some of them might still not work yet)

@skar

The 2D physics API is now a bit different, making it more flexible:

Here’s a basic example until I get a better one ready:

-- Basic 2D physics

function setup()
    -- You now create a 2D physics world
    world = physics2d.world()
    
    -- Use the world to create bodies (type, x, y)
    ground = world:body(STATIC, 0, -4)
    -- Add shapes to bodies
    ground:box(10, 1)
    
    -- You can add multiple shapes a body now as well
    thing = world:body(DYNAMIC, 0, 0)
    -- boxes use width, height, x, y, rotation
    thing:box(2, 0.25, 0, 0, 45)
    thing:box(2, 0.25, 0, 0, -45)
    thing:circle(1)
    
    cam = camera.ortho(10, -100, 100)
end

function draw()
    background(50)
    
    cam:apply()
    -- update the physics simulation
    world:step(time.delta)
    -- draw physics (for debugging)
    world:draw()
    
end

@John In one of you updates, can you get showKeyboard() working. I was going to do keyboard testing, but I can’t get the keyboard to show. I tried the require legacy line thinking that would allow it, but it didn’t.

@dave1707 sure, there are some features like that I haven’t gotten around to adding yet

@John In your 2D physics example above, why is there a red and green line in the center of the objects. Also, the color of the circle changes after awhile.

PS. All I can say is this is going to be fun. It’s like learning Codea all over again.

great thanks for the physics example, i wonder what can i do with the shapes? resize or destroy them? or do i have to destroy the whole body?

@dave1707 from what i can tell the lines are the axis of the body for seeing rotation, the color changes to denote sleeping or awake

@skar I modified the 2D code so it did different things and you’re correct, the lines show rotation and the color change looks like it’s for sleeping.

@John - on the physics demo - just a minor query about intention really. I note there are no buttons to capture screen etc, will they be included later or have you something else in mind. Reason I ask is the we don’t seem to be able to capture project icons?

Edit - just added viewer.mode = fullscreen which brought up the parameter and output windows but no buttons.

Further edit - your life is going to be hell from now on - good luck with that!!!

Changing the class system … seems that will ensure that many if not most Codea 3 programs will not run directly on 4. Which is OK, I guess. middleclass has a few capabilities that the C3 class doesn’t have, but not many. What was your main motivation for the switch?

Seems like making the class name optional will lead to a little trouble and confusion. Maybe not too much … mostly just means name and __tostring will be weird, I guess …

@John @Simeon Is Codea 3.x going away at some point or will both 3.x and 4.x be available. If both will be available, could something be added at the beginning of a project to say what version 3.x or 4.x the project should run at. I’m not looking forward to converting 750+ projects to 4.x code.

@Bri_G the standard capture and project icon features will come back when a proper sidebar is put in. Viewer api is currently viewer.fullscreen() but will probably revert to what we had before

@RonJeffries I can put the old class system in the legacy support script, and optional named in middleclass doesn’t seem to have any ill effects from what I can tell

@dave1707 3.x isn’t going anywhere and the current version select option is temporary and will be moved to a per project system in the near future

@skar you can modify, add, and delete body colliders/shapes at will. You can also use 2D physics with scenes (examples will be coming soon)

lol i thought this is kind of funny, playing around with the new camera and if you go inverse with the first parameter the circle shape becomes a square

speaking of the camera though, the second and third parameters don’t seem to do anything, and shouldn’t ortho have 4 parameters for the 4 sides?

@skar - is that because you are simply inverting the transparent image background?

@John - thanks for clarification, and related update to 3.6(340). Tried it out on the physics demo and it worked. Tried it out on my latest play project and it fired up an error related to font(). Also scrolling the error message noted a colour change in the error message (image attached) - is this expected? Looks like a partial listing in white.

@John off the wall a bit - but I’m still going to ask it:

Is there any way that we can check from within Codea what the version number is? What I’m trying to get round is if we can program projects accordingly - for instance


if cVersion < 4 then
     viewer.mode = FULLSCREEN
else
     viewer.fullscreen()
end

You obviously need to parse code accordingly and error check accordingly. It’s probably asking too much of you but it would make development, from a user point of view easier.

@Bri_G This is what I was told when I inquired about 3.x and 4.x. So we might know what version we’re running.

3.x isn’t going anywhere and the current version select option is temporary and will be moved to a per project system in the near future

@John - another quick one, when I use style.push().fill() you get the colour picker up. You can also get the colour picker up if you use fill() alone (not preceded by style.) and the fill in the latter case looks syntactically correct.

Further, if you place the fill() statement at the end of draw() function the project runs correctly, but if you place it at the front of the draw() function all subsequent fill statements don’t work, I just get a black screen with the Codea 4 furniture.

Edit: if you start a line with style.fill() you don’t get the colour picker but you can type in the rgb values and the colour is used.

@skar The camera class in 4.x automatically calculates aspect ratio, so only the height of the orthographic projection is required. The other two parameters are zNear and zFar which for 2d games are usually set from some negative to positive value to include things in front and behind the zero plane (i.e. z = 0)

@Bri_G not sure about the error (maybe add to the feedback spreadsheet), but those subsequent white messages look like touch objects that have been printed with print()?

I’ll add a version variable (something like CODEA_VERSION)

The editor currently does not support 4.x syntax out of the box, so some stuff will misbehave

The blank draw function might just be due to an error causing the rest of the function to abort (since fill() is not valid in 4.x without using the legacy compatibility script)

I’ll be checking and updating the google doc as I go through and resolve feedback: https://docs.google.com/spreadsheets/d/1Iwudoq6RcDEkpwP_P7hHv4PPizemyQ7OCHrLEyNfPDc/edit?usp=sharing

hmm so how do you move the x,y of the ortho camera? if i could see the source code for the modules it would save a lot of time for you answering all these questions as i encounter each feature i want to convert in my boilerplate

@skar

There’s an undocumented trick for camera:apply() which pops the latest matrix off the stack and uses that for the camera position/orientation

matrix.push().translate(x, y)
cam:apply()

I’ve attached the binding code. It’s c++ and almost 8,000 lines for just the bindings (not much actual engine code really); so knock yourself out

      19 ./PhysicsBindings.hpp
    1175 ./SceneBindings.cpp
    2213 ./AssetBindings.cpp
     259 ./SoundBindings.cpp
      19 ./TimeBindings.hpp
     427 ./InputBindings.cpp
      43 ./RenderBindings.hpp
     276 ./ParameterBindings.cpp
      19 ./InputBindings.hpp
    2443 ./RenderBindings.cpp
      19 ./ParameterBindings.hpp
      28 ./SceneBindings.hpp
     906 ./PhysicsBindings.cpp
      27 ./AssetBindings.hpp
      19 ./SoundBindings.hpp
      33 ./TimeBindings.cpp