Programming Help

General programming forum. Ask all of your Lua-related questions here

Re: Programming Help

Postby flankattack on Wed Jul 29, 2009 6:29 am

Anyone?
Current Project: Digital Sudoku - 1.2
flankattack
 
Posts: 25
Joined: Tue Jul 07, 2009 9:22 am
Location: New Zealand

Re: Programming Help

Postby Ivan on Thu Jul 30, 2009 9:56 am

Hey. There is a 'math' module which has 'math.floor' and 'math.rand'. Check out the official Lua documentation (not the AGen manual but the official Lua language documentation) to find out more.
Secondly, your code has a huge memory leak. You are drawing on the canvas once every 16 ms but you never 'clear' it. Therefore the canvas keeps on growing in size. I would recommend calling "meter:clear ( )" before you redraw the scene.
Next, I would suggest you have a separate table object for each bomb. You can store all bombs in a table like so:
bomblist = {} -- create a list of bombs
table.insert ( bomblist, bombobject ) -- add a bomb to the list
You can get the size of the list like so:
numberofbombs = #bomblist
Then, you can access your bombs via an index:
bomblist[4] -- returns the fourth bomb
table.remove ( bomblist, 4 ) -- removes the fourth bomb from the list
Just be careful because removing an object from the table like so, changes the indexes of all other objects in the table.
Study up on how tables work and you should get some interesting ideas.
Ivan
Site Admin
 
Posts: 111
Joined: Thu Dec 27, 2007 9:21 pm

Re: Programming Help

Postby flankattack on Fri Jul 31, 2009 1:01 am

Awesome! Thanks for that.
I'll work it into my code over the next few days.
Cheers.
Current Project: Digital Sudoku - 1.2
flankattack
 
Posts: 25
Joined: Tue Jul 07, 2009 9:22 am
Location: New Zealand

Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron