Tuesday, September 16, 2014

Teaching coding through games: gamecodization!

We might think that teaching coding is something boring and complicated. But when you base your exercises on games (you gamecodize :-D) then… your students get astonished!



When I wrote computer code in Introducing a new subject can be threatening for some people. Things get worse for those students not in favour of STEM matters.Then, how to make them buy your fabulous lessons about coding? Act as an illusionist.


First of all switch your digital board and open your IDE (I’ve used Basic256). Start speaking about video games: how long they think a game needs to be coded, types of games, etc. Let them express themselves about the topic.


Then start to explain what Tron is: a film by Disney which gave way to several games. Let them go on speaking about different aspects of the game while you start typing code. For sure you’ll listen to the silence (students suddenly shut up hypnotized by what you are doing) as you go on striking your keyboard, but break it to explain what you are doing and how (different aspects of coding, as main loops, debugging, variables, strategies, etc).


Some tips:


  1. Use the help window: they should realize they don’t need to know everything by heart. If doubts pop up a helping window can also pop up.
  2. Make some mistakes on purpose: that’ll give them a good view of what debuging and trial-and-error are.
  3. Show some hesitation and use the expression “let’s try…”
  4. Use a scaffolding approach, constructing the main algorithm, and adding new elements around it as you continue.




My basic version of Tron game needs about 10 minutes top to be coded. When you execute the final code and the students see the results they get way surprised by how easily you can make games.




The coding phases go like this:


  1. Create a main loop and listen to the keyboard. If ESC is pressed exit the loop.
  2. Insert the code for the motorbike (a point) to go down the screen when pressing the down arrow.
  3. Do the same for the rest of the keys.
  4. Move the point around, with no physical restraints.
  5. Make the algorithm detect the walls left by the point, and make them “real”.
  6. Let the player win when getting to the bottom right corner.
  7. Add random spheres as obstacles.


The lines of code look like this:




For more ideas about what games to code check the following list. MVC stands for model/view/controller, and AI for artificial intelligence. The grades have been given taking in count: that a student has to code them, and Basic’s features.



Difficulty
Text/graphic
MVC
Sprites
Data
AI
Animal, vegetable,
difficult
text
yes
no
matrix
basic
Arcanoid
difficult
graphic
yes
yes
matrix
no
Asteroids
medium
graphic
no
yes
array
no
Battleship
medium
both
no
no
matrix
no
Bejeweled
difficult
both
yes
yes
matrix
no
Biggest card
easy
both
no
no
array
no
Checkers
difficult
both
yes
no
matrix
yes
Connect four
medium
both
yes
no
matrix
yes
Conversation
easy
text
no
no
variable
no
Dodger
easy
graphic
no
yes
array
no
Escape the maze
easy
graphic
both
both
matrix
no
Guess the number
easy
text
no
no
variable
basic
Hang man
medium
both
no
no
array
no
Land on the moon
medium
graphic
no
yes
variable
no
Life's game
medium
graphic
yes
no
matrix
no
Marble, chips...
easy
text
no
no
variable
no
Master mind
medium
text
no
no
array
no
Math sequences
medium
text
no
no
array
no
Poker
medium
both
yes
no
matrix
medium
Pong
medium
graphic
no
yes
variable
no
Puzzle: match pairs
easy
both
yes
yes
matrix
no
Puzzle: sliding
medium
both
yes
yes
matrix
no
Simon says
easy
both
yes
no
array
no
Snake
difficult
graphic
yes
yes
matrix
no
Space invaders
difficult
graphic
no
yes
array
no
Text adventure
medium
text
yes
no
matrix
no
Three in a row
medium
both
yes
no
matrix
medium
Tic-tac-toe
easy
both
yes
no
matrix
basic
Tron
easy
graphic
no
no
variable
no