tastyl [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=52973 Struggling with map() and fget() <p>I'm new to PICO-8, and am trying to get a basic top-down movement system. So far I have 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>left = btn(⬅️) right = btn(➡️) up = btn(⬆️) down = btn(⬇️) xspd = (num(right) - num(left)) * player.speed yspd = (num(down) - num(up)) * player.speed if fget(player.x + xspd, player.y) == 0 then xspd = 0 end if fget(player.x, player.y + yspd) == 0 then yspd = 0 end player.x = player.x + xspd player.y = player.y + yspd</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p><code>num()</code> takes in a boolean, and outputs a number (true being 1, false being 0)<br /> The problem I have, is that I'm trying to stop the player if they hit a wall (The wall's sprite having flag 0), and I'm not sure what to do. Does anyone know what's going on?</p> https://www.lexaloffle.com/bbs/?tid=49146 https://www.lexaloffle.com/bbs/?tid=49146 Thu, 01 Sep 2022 19:13:23 UTC