ZoeB [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=38276 Fire Ant <p> <table><tr><td> <a href="/bbs/?pid=65494#p"> <img src="/bbs/thumbs/pico8_fireant-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=65494#p"> fireant</a><br><br> by <a href="/bbs/?uid=38276"> ZoeB</a> <br><br><br> <a href="/bbs/?pid=65494#p"> [Click to Play]</a> </td></tr></table> </p> <p>Here's a rough remake/demake of Fire Ant. It's my first PICO-8 project.</p> https://www.lexaloffle.com/bbs/?tid=34614 https://www.lexaloffle.com/bbs/?tid=34614 Mon, 01 Jul 2019 09:02:14 UTC Arrays of tables <p>Hi!</p> <p>I hope this is the right place to ask...</p> <p>So I gather I can make some enemies that have X-Y co-ordinates like this:</p> <div> <div style="max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>enemy = { x = 0, y = 0 } enemies = {} for i=1,5 do add(enemies, enemy) enemies[i].x = i * 5 enemies[i].y = i * 10 print(enemies[1].x) end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>(5 and 10 are arbitrary numbers for testing purposes.)</p> <p>I believe this would be an array of tables.</p> <p>I would have thought this would make 5 enemy co-ordinates, like this:</p> <p>enemies[1].x = 5<br /> enemies[1].y = 10</p> <p>enemies[2].x = 10<br /> enemies[2].y = 20</p> <p>...and so on. But it looks like it's overwriting every enemy's co-ordinates with the latest pair each time.</p> <p>Could someone please tell me what I'm doing wrong?</p> <p>Cheers!</p> https://www.lexaloffle.com/bbs/?tid=34595 https://www.lexaloffle.com/bbs/?tid=34595 Thu, 27 Jun 2019 21:18:39 UTC