MaddoScientisto [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=70850 How to offset coordinates from the camera? <p>I've been using the camera(x,y) function to move my camera viewport but now I can't do UI because print() and such work off world coordinates rather than screen coordinates, is there something that would allow me to offset coordinates from the camera position?<br /> Something like screen.x, camera.x, etc</p> https://www.lexaloffle.com/bbs/?tid=141991 https://www.lexaloffle.com/bbs/?tid=141991 Sat, 27 Apr 2024 14:04:08 UTC Do table-based &quot;classes&quot; work differently compared to pico-8? <p>I've been using <a href="https://nerdyteachers.com/PICO-8/Guide/?Tables">this tutorial</a> as my principal information for programming, since there's no picotron specific resource.</p> <p>I'm experimenting with table-based classes, according to the guide I'm supposed to be able to create a base blueprint of an object and then instantiate it, but when I do so following the example, the object is not copied but instead it becomes a reference, because every change gets applied to the first object.</p> <p>I made a sample project, first I try the guide's way, then I try it in a way I know works</p> <div> <div class=scrollable_with_touch style="width:100%; 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>enemies = {} enemies2 = {} enemy = { type = 0, sp = 1, x = 0, y = 0, dx = 0, dy = 0, update=function(self) self.x += self.dx self.y += self.dy end, draw=function(self) spr(self.sp, self.x, self.y) end } goblin = enemy --copy enemy class goblin.sp = 2 goblin.type = 3 goblin.x = 6 goblin.y = 10 ogre = enemy --copy enemy class ogre.sp = 3 ogre.type = 4 ogre.x = 40 ogre.y = 50 function _init() add(enemies, enemy) add(enemies, goblin) add(enemies, ogre) add_enemy(16,16,4) add_enemy(32,32,5) add_enemy(64,64,6) end function add_enemy(new_x,new_y,sprIndex) add(enemies2, { type = 0, sp = sprIndex, x = new_x, y = new_y, dx = 0, dy = 0, update=function(self) self.x += self.dx self.y += self.dy end, draw=function(self) spr(self.sp, self.x, self.y) end }) end function _draw() for e in all(enemies) do e:draw() end for en in all(enemies2) do en:draw() end 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>If I define the object in the add function then each object acts as independent object, is this how tables are supposed to function?</p> <p> <table><tr><td> <a href="/bbs/?pid=147234#p"> <img src="/bbs/thumbs/pico64_tihuwubibu-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=147234#p"> class test</a><br><br> by <a href="/bbs/?uid=70850"> MaddoScientisto</a> <br><br><br> <a href="/bbs/?pid=147234#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=141921 https://www.lexaloffle.com/bbs/?tid=141921 Wed, 24 Apr 2024 09:11:18 UTC How to do map tile collision with multiple layers? <p>I'm drawing the map like this:</p> <div> <div class=scrollable_with_touch style="width:100%; 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>-- 2 is the layers count for i=2,1,-1 do map(fetch&quot;map/0.map&quot;[i].bmp) 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>And I can check for collisions for map tiles with <code>fget(mget(x/16,y/16))</code> to get the flag of the tile, all good here, except I can only check for collisions on the top layer, while every other layer is ignored.</p> <p>How can I check for the flags on every layer?</p> https://www.lexaloffle.com/bbs/?tid=141780 https://www.lexaloffle.com/bbs/?tid=141780 Wed, 17 Apr 2024 12:22:02 UTC