Randy_McShandy [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=93946 Issues detecting large sprites via mget <p>Hi,<br /> I'm sussing out some basic map collision utilizing fget(mget()) as one would for Pico-8 and I'm running into an issue where either large sprites aren't working correctly, or it's PEBKAC.<br /> Specifically, it seems checking flags on any sprite that isn't 16x16 doesn't return the correct values, and any larger map sprite only reports correct flags for its upper left 16x16 corner. Smaller sprites </p> <p>I've created a barebones sample to test this out after noticing in a proper project.<br /> The gray squares are 16x16 for visual alignment. Yellow is a 32x32 player sprite, with each collision point along its edges visualized with pink. The other colored sprites are directly part of the map and and go from 16x16, 32x32, and 64x64. On collision, the point of contact (with the player's edge points) is added to a global render list for its own visualization, simple pink dots as well. We can see on each sprite that the TL 16x16 is the only point of contact.</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="/media/93946/6_collision.png" alt="" /> <p>Outside of the provided image, I also have my cart now rendering the actual sprite contacted in the upper left of the screen to confirm it's hitting what it thinks it is. I also did some toying around with further visualizations to get an idea of where my collider/mget thinks we're hitting, but it all seems cogent.</p> <p>My biggest concern is the arguments to mget(). Pico-8 documentation simply suggests x,y coordinates without specifying <em>pixels</em> or <em>map tiles</em>, and any Picotron documentation doesn't really suggest things correctly.<br /> Out of curiosity, I added this snippet <a href="https://www.lexaloffle.com/bbs/?tid=141387">https://www.lexaloffle.com/bbs/?tid=141387</a> to see what it does with mget. It seems to pass plain pixel coords to mget() for sprite info, but it also doesn't seem to think I'm hovering over a sprite 99% of the time. Passing the <em>tile</em> coords instead is more fruitful, but produces the same issue. Am I wrong in assuming map tiles are 16x16? The map editor certainly suggests it, though curiously it also fails to render larger sprites beyond their 16x16 TL corner.</p> <p>Anyone else run into this, or <em>not</em> have this issue? I understand custom sprite sizes are new to Picotron so it's been difficult to find resources. Hope I covered everything well enough. Thanks!</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> function check_map_collision(actor) local hit_resolution = 8 checkpoints = {} -- generate a set of points on each edge of the actor for px = actor.x, actor.x+actor.w-1, hit_resolution do add(checkpoints, {x=px, y=actor.y}) end for px = actor.x, actor.x+actor.w-1, hit_resolution do add(checkpoints, {x=px, y=actor.y+actor.h-1}) end for py = actor.y, actor.y+actor.h-1, hit_resolution do add(checkpoints, {x=actor.x, y=py} ) end for py = actor.y, actor.y+actor.h-1, hit_resolution do add(checkpoints, {x=actor.x+actor.w-1, y=py}) end -- check map sprite flags at each point for collision for each in all(checkpoints) do -- find nearest map sprite increment mapx = (each.x)/16 mapy = (each.y)/16 sprite_at_point = mget(mapx, mapy) flags_at_point = fget(sprite_at_point, flag) if (flags_at_point &amp; (2^flag)) == 1 then -- collision happened at this edge point return {x=each.x, y=each.y} end end -- no collision! return nil end </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> https://www.lexaloffle.com/bbs/?tid=141704 https://www.lexaloffle.com/bbs/?tid=141704 Sat, 13 Apr 2024 23:37:04 UTC Transparency and map layers <p>Hi,<br /> Currently toying around with Picotron basics after some (but not too much) prior experience with Pico8.<br /> I'm trying to work with multiple layers and some degree of transparency between them but it's not quite working.</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="/media/93946/layers.png" alt="" /> <p>In the map screen, nearly all tiles are in the lowest layer; the top layer has only the single mushroom sprite on the far right. My assumption is that the default black in subsequent layers would act as transparency. I swear I had this working previously but am having trouble recreating it -- when I actually run the cart, the black of the upper layer acts as just solid black, only rendering the mushroom but nothing of the layer below (wizard character drawn at runtime).</p> <p>Based on Pico8 docs, I've got a palt(0, true) in my _init() with the understanding it should turn black to alpha, but it seems to make no difference. I also see that black should certainly act as the transparent color by default anyway?</p> <p>Anyone know what I'm doing wrong? Swapping layers renders that grassy layer as expected, with the lower layer (mushroom) totally hidden.</p> <p>Running 0.1.0d on Arch Linux (x86).<br /> Thanks.</p> https://www.lexaloffle.com/bbs/?tid=141293 https://www.lexaloffle.com/bbs/?tid=141293 Sun, 31 Mar 2024 01:54:52 UTC