Last active
June 28, 2022 08:55
-
-
Save Achie72/e9323a8e96218c02ff7a86093e7a2ccd to your computer and use it in GitHub Desktop.
Check Semi Solids with Flag 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Created for my Ko-fi article about my game | |
-- dev journey with my retro platformer | |
-- https://ko-fi.com/post/ENGHUN-Unnamed-Project--Making-Abilites-Look-B-X8X2DH3X2 | |
-- Code is In progress, heavily not optimized | |
-- and geared towards readability until PICO_8 | |
-- token counts come into play | |
function collide_floor(obj,width,height) | |
--only check for ground when falling. | |
if obj.ay<0 then | |
return false | |
end | |
local landed=false | |
--check for collision at multiple points along the bottom | |
--of the sprite: left, center, and right. | |
-- notice here the fget(tile, 2) check | |
-- fget fetches the given flag for the given tile on the | |
-- sprite map. | |
for i=1,width-1,2 do | |
local tile=mget((obj.x+i)/8,(obj.y+(height))/8) | |
if fget(tile,0) or fget(tile,2) or (fget(tile,1) and obj.ay>=0) then | |
landed=true | |
end | |
end | |
return landed | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment