API Wars

General discussion about LÖVE, Lua, game development, puns, and unicorns.
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: API Wars

How massive, you made me wanna get ALL details.

BTW, not like it's going to break any of my games (since I don't have any).

@myself: I should update LUBE, and I should continue working on it....

rude
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: API Wars

Off the top of my head:
• load, update, draw and so forth are moved to the love-table. Now everything is in the love table.
• image:setCenter() goes bye-bye. Instead: love.graphics.draw(image, x, y, a, sx, sy, ox, oy)
• love.graphics.draws(image, x, y, a, sx, sy, ox, oy, rx, ry, rw, rh) -- Changed param order to match love.graphics.draw.
• love.graphics.draw can no longer be used to draw text. Love.graphics.print is the new way.
• Appearently, it seems that people want top-left as the default local origin. So be it.
• Radians. -- This will cause trouble, but is necessary.
• The physics API will not change per-se, but the simulations will probably differ.
On the plus side, there will be new features. I'll post part of the "API" later.

Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: API Wars

With my lua+sdl framework, "inmframe", I made a couple of design decisions along the lines of this thread that may or may not help:

There was no "load" callback as running the main script was a good enough entry point.

The global callback was actually one of two things. Either, the global table's "inm_oncycle" function, or a function passed to the function "inm.setcallback". That function reference was stored in the lua_state's registry table. It felt more flexible that way.

There was no "draw" callback, the entire video system was done after the oncycle callback was done up in C. This limited it to only tile and sprite based games. Speedy, but restrained.

rude
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: API Wars

Sneak-peak at some new stuff. This is not what's planned, but what's done. The list of planned things is much longer.

You get no explanations/comments for great mystery.

Code: Select all

imageData = love.image.newImageData( file )
imageData = love.image.newImageData( width, height )
imageData:setPixel( x, y, r, g, b, a )
imageData:mapPixel( function (x, y, r, g, b, a) return b, g, r, a end )
r, g, b, a = imageData:getPixel( x, y )
image = love.graphics.newImage( imageData )


Code: Select all

vb = love.graphics.newVertexBuffer( image, size, type, usage )
vb:add( x, y, s, t )
vb:add( x, y, s, t, r, g, b, a )
love.graphics.draw( vertexBuffer, x, y, a, sx, sy, ox, oy )
vb:clear()


Code: Select all

sb = love.graphics.newSpriteBatch( image, size, usage )
sb:add( x, y, a, sx, sy, ox, oy )
sb:adds(x, y, a, sx, sy, ox, ox, rx, ry, rw, rh )
love.graphics.draw( spriteBatch, x, y, a, sx, sy, ox, oy )
sb:clear()


Code: Select all

channel = love.audio.newChannel( volume, pitch )
channel:setPitch( p )
channel:setVolume( v )
love.audio.play( audible, channel )
love.audio.play( audible, volume, pitch )


Code: Select all

function love.run()
while true do
love.timer.step()
if love.update then love.update(love.timer.getDelta()) end
love.graphics.clear()
if love.draw then love.draw() end
for e,a,b,c in love.system.events() do
if e == love.event_quit then return end
love.handlers[e](a,b,c)
end
love.graphics.present()
end
end


bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: API Wars

what, you did all in lua?
I love the features, especially get/setPixel (don't know why, needed it just one). From what I understand you can also use your own love.run, thus you are going to be able to stop the screen from clearing?
Anyway, nice job, waiting for.. what? 0.6.0?

Kaze
Party member
Posts: 189
Joined: Sat Jul 19, 2008 4:39 pm
Location: Dublin, Ireland

Re: API Wars

Lookin' good.

osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: API Wars

theres some really cool stuff in there, and i look forward to using it

get / set pixel will be a great improvement, ive been halfassing it with my own pbm / raw file reader, but (and i dunno if this is on your list) being able to do simmilar with whole images would be cool too (ie taking a subsprite, ploping it on a "blank" image and applying the players equipment on it, diablo style, without having to do it EVERY frame on the screen in realtime)

as far as the love.run, im kinda mixed ... ive spent most of my lua game creation life with blah blah blah.running, or a infinite while loop, so im not opposed to it, it would actually make life easier in some respects, but i have sorta grown accustom to the individual function callbacks, and it actually makes it easier to organize script, from a dumb humon aspect

but things like clearing the screen before drawing to it, having to type it in, and the general blob it tends to make, regarding noobies in the latter, ...maybe im just lazy now but i almost (note almost) like the old way better, but personally it doesnt effect me, cause i just stick function names in the main script and go about my biz with includes however i damn well please lol

osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: API Wars

rude wrote:Ok, looks like top-left so far.
bartbes wrote:it will invalidate all previous-written games
Oh, hohohohoh. All games will be invalidated anyway. The next codename should be Chicxulub, because when I'm done with this version, all that's left of the API is an impact crater. The users that never use LÖVE again due to massive API break will be called Dinosaurs. (They eventually go extinct). HAHAHAhahahha ... hah. ha.
petsagouris wrote:Did I mention that I totaly respect what you are doing here. Well done!
That's cool.
I would suggest that the origin parameters are values instead of only constants such Top-Right. These values would be from 0 (left) to 1 (right) or -1 (left) or 1 (right).

I'd like for text to drawn from its upper left corner instead of from the lower left corner of the first line. The behavior strikes me as somewhat odd for multiple lines. Will there be a parameter for choosing the location of string drawing in the same manner, although perhaps with respect to the entire text mass instead of the first line only?

EDIT: right->left
Last edited by osuf oboys on Sun Feb 01, 2009 3:44 pm, edited 1 time in total.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.

rude
Posts: 1051
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: API Wars

osgeld wrote:but i have sorta grown accustom to the individual function callbacks
A default love.run will be provided. The callbacks will not be removed by default, but it will be possible to remove them (by overwriting love.run)

@osuf: There will not be any parameters to specify that sort of thing. There will be a default, and there will be a pixel offset. I agree that the default origin for Font should be top-left.

osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: API Wars

what about print("foo") in windows when running from the command prompt?

in linux, where i spend most of my time, i run love from the command prompt, and any print statements show up there, while my scripts are running, where on windows if i do the same there is no output in the cmd window

which makes debugging something on my laptop a royal treat, any hopes on getting that fixed?

Who is online

Users browsing this forum: No registered users and 12 guests