hive.saysi.org

 

HIVE PICO-8 Tutorial

§5

5a: layers to understanding programming

HECTORING PEP-TALK: YOU ARE WISER NOW. Let's delve a little deeper into your BASIC PROBLEM SOLVING techniques

UNDERSTANDING comes in 3 layers:

0th level, THE FOUNDATIONS: what even is the realm of possibility?

1st level, GROUND FLOOR: awareness of the things in PICO-8, like functions and the tools that are available

NEXT LEVEL: using the functions in different, but common ways to solve common problems, and also using these foundations and awareness to invent new behaviors in the game engine.

RECAP:



Merit Badge Challenge 5a

FREEBIE! This sticker is just for you!





5b: dealing with errors & other flavors of problems

errors.p8 (right click + save as)

--[[ -- working version

x,y,oops,grit,grot=0,0,20,1,1
patt=▥

cls(14)
function _update()
 if btn(❎) then
   if oops > 0 then
   grit+=0.01
   grot=rnd(5)
   oops-=1
  end
  x+=cos(time()/grot)*grit
  else
   oops=20
   fillp(patt)
   rectfill(0,0,128,128,12)
   fillp()
   if flr(x)>0 then x-=.5
   elseif flr(x)<0 then x+=.5 end
  end
  if btn(🅾️) then
   patt=flr(rnd(0b1111111111111111))+0b0.1
   fillp(flr(patt))
   rectfill(0,0,128,128,0xec)
   fillp()
  end
  y+=sin(time()/2)*4
end

function _draw()
 --cls(8)
 spr(0,x+60,y+100)
end

--]]
-->8
--[ [ -- broken version

x,y,oops,grit,grot=0,0,20,1,1
patt=▥

cls(14)
fuction _updat()
 if btn(❎) then
   if oops > 0 then
   grit+=0.01
   grot=rnd(5)
   oops-=1

  x+=cos(time()/grot)*grit
  else
   oops="20"
   fillp(patt)
   rectfill(0,0,128,128,12)
   fillp()
   if flr(x)>0 then x-=.5
   elseif flr(x)<0 then x+=.5 end
  end
  if btn("🅾️") then
   patt=flr(rnd(0b1111111111111111))+0b0.1
   fillp(flr(patt))
   rectfill(0,0,128,128,0xec)
   fillp()
  end
  y+=sin(time()/2)*4
end

function _draw()
 --cls(8)
 spr(0,x+60,y+100)
end

--]]



Merit Badge Challenge 5b ★★★★

QUIZ! What are the 3 main types of errors? Give examples of each. What is the first thing you do when troubleshooting?



Merit Badge Challenge 5b+ ★★★★

EXTRA CREDIT SIDEQUEST make a simulation using functions used, but not explained, in the broken example.