First mini LÖVE project

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

First mini LÖVE project

Post by mikembley »

Ive been using LÖVE for a while now, And i felt as though i needed to accomplish something and make progress in my ability to use this awesome engine.
So.. I thought i would make a sandbox for the physics, with it you are able to create static lines, dynamic circles and rectangles in a scrollable infinite* world.

This was mainly done as a concept for me, learning how to use tables** and data types, and how games are made from scratch without boiler plate code.
I realise my code is not neat and could most probably be optimized but again its part of my learning curve on making efficient code.

Things that i would like to learn:
How to destroy bodies (specifically table-wise)
String manipulation imo LUA sucks for this, Im used to PHP

So here it is DOWNLOAD

Controls:
Left Mouse and Drag = Create object (Size dependant on drag distance)
Right Mouse and Drag to screen sides = Scroll throughout infinite* world
Mouse Scroll = Change Tool
Escape = End sandbox

* = Infinite isnt strictly true, The drag can go on forever although the world width and height is defined by the physics world
** = I havent fully learnt how to use tables correctly, Im still stuck in my old array ways
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: First mini LÖVE project

Post by osgeld »

i havent had a chance to check this out yet, but just wondering what your struggling with on tables
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

Re: First mini LÖVE project

Post by mikembley »

I shove all of my physics bodies into a table "bodyTable" by means of "bodyTable[n]"

I wish to be able to destroy my body "bodyTable[n].body:destroy()" and then re-sort the table so that the destroyed body is no longer in my table thus not being indexed in my main body drawing loop

I think i tried table.remove(t) but it failed in the drawing loop :(
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: First mini LÖVE project

Post by rude »

Cool.

In drawBodies(), instead of using numeric for, you can use generic for. This way it will still work of you use table.remove().

Code: Select all

function drawBodies()
   for i,v in ipairs(bodyHolder) do
      -- stuff
   end
end
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

Re: First mini LÖVE project

Post by mikembley »

Thank you Rude, id seen that kind of loop before in one of the examples but I thought nothing of it, but now it seems rather useful/powerful!

By the way I think you should change your username to polite or kind, because your quite the opposite of rude :) heh
User avatar
Skofo
Party member
Posts: 146
Joined: Mon Dec 22, 2008 10:55 pm

Re: First mini LÖVE project

Post by Skofo »

Neat! Perhaps you could add a physics boundary, though, since creating a physics object outside of the world causes the game to crash (and not change the resolution back in GNOME).
Working on: Viator
Need a 64-bit Debian package for LÖVE? Here it is!
Post Reply

Who is online

Users browsing this forum: No registered users and 86 guests