Log In  
Follow
kallanreed
Follow

I wrote a blog post about making a generic method dispatch helper for 'foreach'.
It's more of a novelty than something really worth adding to code. It's better to just use 'for x in all(XS)' instead.

Here's the mini summary:

function callm(method, ...)
 local params={...}
 return function(o)
  if type(o)=="table" then
   local m=o[method]
   if type(m)=="function" then
    m(o,unpack(params))
   end
  end
 end
end

function _draw()
 cls()
 foreach(drawable, callm("draw", 11))
end

Check it out: https://kallanreed.com/2021/10/17/pico-8-generic-dispatch-with-parameters/

P#98795 2021-10-17 17:56 ( Edited 2021-10-18 02:09)

I'm tying to build GOL on PICO-8, but the per-pixel manipulation is just too slow. Anything more than about 48x48 is unacceptably slow.
Initially I was reading/writing into temporary tables but that was really slow. This approach keeps all the state on the screen and in a sprite so there's about a quarter of the work from the table approach, but it's still slow.

I've started another experiment with peek4/poke4 but the coordinate wrapping is a total pain.

Cart #the_slow_life-0 | 2021-10-13 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#98583 2021-10-13 15:48

Cart #grave_concern_wip-3 | 2021-10-25 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6

My first attempt at a PICO-8 game.
I've never tried anything like this before, so it's been a fun learning experience.

This is my spooky side scroller hopefully wrapped up by Halloween.

Update 4)

  • Adding a fade on death as well as some basic palette twiddling to make it look a little nicer.
  • More music because I'm kind of tired of hearing it at this point.
  • Spikes and death! Although the collision detection is going to need some major overhaul.

Update 5)

  • More interactions
  • Starting enemies
  • More music
  • More map

Update 6)

  • Bats! Spiders! Spikes!
  • Death!
  • Pixel collision!
  • If you can get the "potion", you've "won" for now!

Update 7)

  • Health!
  • End-game and win condition
  • Spooky Scary Music!
  • Calling this one ready for Halloween!
P#98545 2021-10-12 17:58 ( Edited 2021-10-25 18:57)

Follow Lexaloffle:        
Generated 2021-10-25 19:24:34 | 0.065s | Q:13