Moduleless API

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Moduleless API

Post by Santos »

Ever wondered what the API would be like if all the functions were directly in the love table?

Code: Select all

love.getDistanceModel = love.audio.getDistanceModel
love.getNumSources = love.audio.getNumSources
love.getListenerOrientation = love.audio.getOrientation
love.getListenerPosition = love.audio.getPosition
love.getListenerVelocity = love.audio.getVelocity
love.getVolume = love.audio.getVolume
love.newSource = love.audio.newSource
love.pause = love.audio.pause
love.play = love.audio.play
love.resume = love.audio.resume
love.rewind = love.audio.rewind
love.setDistanceModel = love.audio.setDistanceModel
love.setListenerOrientation = love.audio.setOrientation
love.setListenerPosition = love.audio.setPosition
love.setListenerVelocity = love.audio.setVelocity
love.setVolume = love.audio.setVolume
love.stop = love.audio.stop
love.clear = love.event.clear
love.poll = love.event.poll
love.pump = love.event.pump
love.pushEvent = love.event.push
love.pushQuit = love.event.quit
love.wait = love.event.wait
love.enumerate = love.filesystem.enumerate
love.exists = love.filesystem.exists
love.getAppdataDirectory = love.filesystem.getAppdataDirectory
love.getLastModified = love.filesystem.getLastModified
love.getSaveDirectory = love.filesystem.getSaveDirectory
love.getUserDirectory = love.filesystem.getUserDirectory
love.getWorkingDirectory = love.filesystem.getWorkingDirectory
love.isDirectory = love.filesystem.isDirectory
love.isFile = love.filesystem.isFile
love.lines = love.filesystem.lines
love.loadLua = love.filesystem.load
love.mkdir = love.filesystem.mkdir
love.newFile = love.filesystem.newFile
love.newFileData = love.filesystem.newFileData
love.read = love.filesystem.read
love.remove = love.filesystem.remove
love.setIdentity = love.filesystem.setIdentity
love.write = love.filesystem.write
love.newFontData = love.font.newFontData
love.newGlyphData = love.font.newGlyphData
love.newRasterizer = love.font.newRasterizer
love.arc = love.graphics.arc
love.checkMode = love.graphics.checkMode
love.circle = love.graphics.circle
love.clear = love.graphics.clear
love.drawObject = love.graphics.draw
love.drawq = love.graphics.drawq
love.getBackgroundColor = love.graphics.getBackgroundColor
love.getBlendMode = love.graphics.getBlendMode
love.getCanvas = love.graphics.getCanvas
love.getCaption = love.graphics.getCaption
love.getColor = love.graphics.getColor
love.getColorMode = love.graphics.getColorMode
love.getDefaultImageFilter = love.graphics.getDefaultImageFilter
love.getFont = love.graphics.getFont
love.getWindowHeight = love.graphics.getHeight
love.getLineStyle = love.graphics.getLineStyle
love.getLineWidth = love.graphics.getLineWidth
love.getMaxPointSize = love.graphics.getMaxPointSize
love.getMode = love.graphics.getMode
love.getModes = love.graphics.getModes
love.getPixelEffect = love.graphics.getPixelEffect
love.getPointSize = love.graphics.getPointSize
love.getPointStyle = love.graphics.getPointStyle
love.getScissor = love.graphics.getScissor
love.getWindowWidth = love.graphics.getWidth
love.hasFocus = love.graphics.hasFocus
love.isWindowCreated = love.graphics.isCreated
love.isSupported = love.graphics.isSupported
love.line = love.graphics.line
love.newCanvas = love.graphics.newCanvas
love.newFont = love.graphics.newFont
love.newImage = love.graphics.newImage
love.newImageFont = love.graphics.newImageFont
love.newParticleSystem = love.graphics.newParticleSystem
love.newPixelEffect = love.graphics.newPixelEffect
love.newQuad = love.graphics.newQuad
love.newScreenshot = love.graphics.newScreenshot
love.newSpriteBatch = love.graphics.newSpriteBatch
love.newStencil = love.graphics.newStencil
love.point = love.graphics.point
love.polygon = love.graphics.polygon
love.pop = love.graphics.pop
love.present = love.graphics.present
love.print = love.graphics.print
love.printf = love.graphics.printf
love.push = love.graphics.push
love.quad = love.graphics.quad
love.rectangle = love.graphics.rectangle
love.reset = love.graphics.reset
love.rotate = love.graphics.rotate
love.scale = love.graphics.scale
love.setBackgroundColor = love.graphics.setBackgroundColor
love.setBlendMode = love.graphics.setBlendMode
love.setCanvas = love.graphics.setCanvas
love.setCaption = love.graphics.setCaption
love.setColor = love.graphics.setColor
love.setColorMode = love.graphics.setColorMode
love.setDefaultImageFilter = love.graphics.setDefaultImageFilter
love.setFont = love.graphics.setFont
love.setIcon = love.graphics.setIcon
love.setInvertedStencil = love.graphics.setInvertedStencil
love.setLine = love.graphics.setLine
love.setLineStyle = love.graphics.setLineStyle
love.setLineWidth = love.graphics.setLineWidth
love.setMode = love.graphics.setMode
love.setNewFont = love.graphics.setNewFont
love.setPixelEffect = love.graphics.setPixelEffect
love.setPoint = love.graphics.setPoint
love.setPointSize = love.graphics.setPointSize
love.setPointStyle = love.graphics.setPointStyle
love.setScissor = love.graphics.setScissor
love.setStencil = love.graphics.setStencil
love.shear = love.graphics.shear
love.toggleFullscreen = love.graphics.toggleFullscreen
love.translate = love.graphics.translate
love.triangle = love.graphics.triangle
love.newImageData = love.image.newImageData
love.getAxes = love.joystick.getAxes
love.getAxis = love.joystick.getAxis
love.getBall = love.joystick.getBall
love.getHat = love.joystick.getHat
love.getJoystickName = love.joystick.getName
love.getNumAxes = love.joystick.getNumAxes
love.getNumBalls = love.joystick.getNumBalls
love.getNumButtons = love.joystick.getNumButtons
love.getNumHats = love.joystick.getNumHats
love.getNumJoysticks = love.joystick.getNumJoysticks
love.isJoystickDown = love.joystick.isDown
love.getKeyRepeat = love.keyboard.getKeyRepeat
love.isKeyDown = love.keyboard.isDown
love.setKeyRepeat = love.keyboard.setKeyRepeat
love.getMousePosition = love.mouse.getPosition
love.getMouseX = love.mouse.getX
love.getMouseY = love.mouse.getY
love.isMouseDown = love.mouse.isDown
love.isMouseGrabbed = love.mouse.isGrabbed
love.isMouseVisible = love.mouse.isVisible
love.setMouseGrab = love.mouse.setGrab
love.setMousePosition = love.mouse.setPosition
love.setMouseVisible = love.mouse.setVisible
love.getDistance = love.physics.getDistance
love.getMeter = love.physics.getMeter
love.newBody = love.physics.newBody
love.newChainShape = love.physics.newChainShape
love.newCircleShape = love.physics.newCircleShape
love.newDistanceJoint = love.physics.newDistanceJoint
love.newEdgeShape = love.physics.newEdgeShape
love.newFixture = love.physics.newFixture
love.newFrictionJoint = love.physics.newFrictionJoint
love.newGearJoint = love.physics.newGearJoint
love.newMouseJoint = love.physics.newMouseJoint
love.newPolygonShape = love.physics.newPolygonShape
love.newPrismaticJoint = love.physics.newPrismaticJoint
love.newPulleyJoint = love.physics.newPulleyJoint
love.newRectangleShape = love.physics.newRectangleShape
love.newRevoluteJoint = love.physics.newRevoluteJoint
love.newRopeJoint = love.physics.newRopeJoint
love.newWeldJoint = love.physics.newWeldJoint
love.newWheelJoint = love.physics.newWheelJoint
love.newWorld = love.physics.newWorld
love.setMeter = love.physics.setMeter
love.newDecoder = love.sound.newDecoder
love.newSoundData = love.sound.newSoundData
love.getThread = love.thread.getThread
love.getThreads = love.thread.getThreads
love.newThread = love.thread.newThread
love.getDelta = love.timer.getDelta
love.getFPS = love.timer.getFPS
love.getMicroTime = love.timer.getMicroTime
love.getTime = love.timer.getTime
love.sleep = love.timer.sleep
love.step = love.timer.step
I dunno... I'm kinda liking it... it's so fresh and so clean, clean... you can't tell what's in what module from looking at the names though... and sometimes the module name gives a useful hint as to what the function does... but maybe different names could make things clear... and sometimes modules don't divide things cleanly on a conceptual level anyway... and maybe documentation could say what function is in what module... hmmmmmm...
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Moduleless API

Post by Plu »

Giving things cleaner names? You mean like maybe adding a category of sorts before the function name? :P

Like, maybe all the graphics functions could be grouped together, in something like love.graphics.functionName()? :P

This kinda reminds me of old-school PHP. Which was a huge mess, pretty much.
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: Moduleless API

Post by scutheotaku »

It's also worth noting that getting rid of modules would also remove the option to not include modules you're not using (though I doubt many LOVErs are bothering to do this anyway).
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Moduleless API

Post by slime »

scutheotaku wrote:It's also worth noting that getting rid of modules would also remove the option to not include modules you're not using (though I doubt many LOVErs are bothering to do this anyway).
Preventing the joystick module from loading can actually have a visible reduction in startup times. Anyone who intends to never add joystick support to their game should probably disable it, IMO.

Edit: here are the loading times for me in 0.9.0 (love.thread and love.timer get loaded before I can start timing):

Code: Select all

love.event: 0.11 ms
love.keyboard: 0.10 ms
love.joystick: 253.69 ms
love.mouse: 0.17 ms
love.sound: 0.11 ms
love.audio: 20.03 ms
love.image: 0.22 ms
love.font: 0.18 ms
love.window: 3.72 ms
love.graphics: 1.82 ms
love.math: 0.13 ms
love.physics: 0.28 ms
Last edited by slime on Fri Jun 21, 2013 9:05 am, edited 1 time in total.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Moduleless API

Post by raidho36 »

And it takes at least a second to launch a window. That is, it takes a second between white window pops up and game is starting to render stuff (an empty game with most stuff disabled that is). Can the window be hidden until game can actually render to it?
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Moduleless API

Post by slime »

raidho36 wrote:And it takes at least a second to launch a window. That is, it takes a second between white window pops up and game is starting to render stuff (an empty game with most stuff disabled that is). Can the window be hidden until game can actually render to it?
You can prevent the initial window creation by doing t.screen=nil in love.conf. If you do that then you will have to call love.graphics.setMode before any other love.graphics function, otherwise LÖVE will crash.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Moduleless API

Post by Santos »

Grouping functions together by a category before the function?! Whaaaat?!? :ultrahappy: Yeah, it is basically a huge mess. But, in its defence, I don't think most names need to be changed... love.rectangle, love.newSource, love.getTime etc. are all pretty unambiguous... and for some names, a name change makes it even nicer to read, compare love.mouse.getX with love.getMouseX... maybe "nicer" is debatable though, hehe. :ultraglee:

It could still be totally possible to disable modules, you'd just have no idea what you're disabling without referring to documentation. :rofl: But, to be fair, if you're going to disable a module, it's probably at least somewhat self-explanatory what disabling it entails.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Moduleless API

Post by raidho36 »

You can prevent the initial window creation by doing t.screen=nil in love.conf.
Wow, thanks, manual said nothing about it. That's gonna come really handy, I hate that white blank screen that does nothing at all and just sits there until the game is loaded. I use my own love.run function so triggering functions in right order is not an issue to me.

Actually, I took some measurements and it seems that set mode function itself causes about a second delay after it creates a screen. I guess I'll just have to live with that until it's fixed.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests