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?
- imagine programming is like MINECRAFT
- THE FOUNDATIONS = the MINECRAFT WORLD
- how do you interact with the world?
- what exists in this world, and how do you access these things?
- what do you do with these things?
- the WORLD is DEEP, but it is not exactly necessary to know ALL THE DEEP to do stuff with things.
- but, you must KNOW how to do the things, meaning:
- understanding the lingo
- how to correctly tell the computer to do the thing you want it to do
- EXAMPLES:
- how does the computer really imagine NUMBERS and how does it DO ARITHMETIC?
- what does that mean for human-computer interactions?
- COOL HINT: some understanding of BINARY and HEXIDECIMAL will really help with PICO-8ing.
- how does the computer imagine the IMAGES we make using LINGO and the COORDINATE SYSTEM?
- understanding these things to some degree will help OPTIMIZING and DEBUGGING a game. you may be baffled by an ERROR, but FOUNDATIONAL KNOWLEDGE may help you figure out stuff.
- meaning, knowing general MATH and PHYSICS stuff will make you a stronger coder. with these FOUNDATIONS, you can BUILD stuff ON TOP
- DO NOT FRET OVER THE SINE & COSINE STUFF WE USED FOR ANGLES IN THE PRIOR VIDEO
- AGAIN: you need to KNOW what to TELL the computer (inputs; example SINE & COSINE) so that the computer may DO (outputs; example circle patterns on coordinate plane)
- knowing the math part is definitely helpful, but not the most important part you need to understand
- SINE and COSINE are USEFUL for converting angles and you can't ESCAPE that!
- ↓↓↓↓ this brings us to the first above-ground level of understanding ↓↓↓↓
1st level, GROUND FLOOR: awareness of the things in PICO-8, like functions and the tools that are available
- this is where these videos start off
- we type the THINGS and the computer does SOMETHING
- back to our MINECRAFT analogy...
- these VIDEOS thus far have taught you (MINECRAFT STEVE) to punch trees and dig a hole in the ground for night
- we've hinted at how to make sticks, but now we're gonna make a WORK BENCH! and maybe even a WOOD AXE
- ↓↓↓↓ once you get a hang of your tools, we can take it up a notch and talk about the ↓↓↓↓
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.
- in MINECRAFT terms,
- anything is possible. if you can DREAM it, it can be CRAFTED
- we're talking working with REDSTONE, baby
- sometimes you won't remember how to CRAFT something specific, but you know that it can be CRAFTED. so you check the WIKI for formulas.
- just like MINECRAFT though, you must CODE a LAME MUD HUT before you can do INSANE and AUTOMATED stuff with REDSTONE.
- you put IDEAS together, then you FIGURE OUT the CODE ARCHITECTURE to make this VISION a REALITY
- realizing your VISION means there will be different PARTS, and it is important to SUBDIVIDE these PARTS so into smaller PROBLEMS that you can solve with CODE
- here too falls the HONING of the CRAFT of PROGRAMMING
- especially with VIDEO GAMES which are complicated and are constantly simulating frames in real time
- this where TOOLS for COMPLICATED PROBLEM SOLVING comes in:
- methods for processing events
- implementing state machines
- tables and data and organization patterns
- path-finding
- ai
- interfaces
- etc.
- a lot of these PROBLEMS have been SOLVED though, because you are not the FIRST person to program EVER
- BABY STEPS
- you will always be COLLECTING KNOWLEDGE across ALL THREE LEVELS of UNDERSTANDING as you work
- you can't READ all the THINGS EVER, programming is an ART!
- and there are NECESSARY THINGS to know in ALL THREE LEVELS if you want to PRODUCE THINGS
RECAP:
- GROUND FLOOR:
- following the tutorials and getting the hang of things
- names of the functions and what they do
- conditional statements, loops, etc.
- understanding this stuff is easy and strightforward
- COOL HINT: READ THE DOCUMENTATION
- this will make it easier to UNDERSTAND what WEIRD CODE is DOING
- NEXT LEVEL and FOUNDATIONS
- these LEVELS are more difficult to UNDERSTAND
- COOL HINT: must keep WORKING!
- WORKING will require you to SOLVE PROBLEMS!
- PROBLEM SOLVING will make you THINK of COOLER and AMBITIOUS SYSTEMS to CREATE.
- GAMES ARE WEIRD
- there are TWO WOLVES inside GAME DEVELOPMENT: the TECHNICAL and ARTISTIC sides
- this requires turning on and off different parts of your brain
- it is easy to get lost in ONE of the SIDES which makes it HARDER to PROBLEM SOLVE
- CODING IS COMPLEX
- it requires:
- one kind of FOCUS
- one kind of ENGINEERING RIGOR (technical side)
- while CONVERSATIONS about AESTHETICS, THEMES, IDEAS (artistic side) happen, requiring a whole different HEADSPACE
- WHEN WE START TO TALK ABOUT HOW THE TECHINICAL CAN AFFECT THE ARTISTIC, the COMPLEXITY spreads squarely to both proverbial SIDES of the proverbial BRAIN
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.