Re:Ask HN: What should I teach a class of low-income kids ab...
by AlexCyrlex on Friday March 29, 2013 @05:52AM
(#5459923)
Just out of curiosity, could you provide a link to a simple game written in ~10 (ten!) lines of code? My understanding was that for anything close to interactive game at least 50-100 lines of code are needed: to draw something, make it move and react to user input in a meaningful way.
I am not familiar with frameworks such as Scratch or pygame; still 10 lines of code look like too few for a game.
Re:Ask HN: What should I teach a class of low-income kids ab...
by lsiebert on Wednesday April 10, 2013 @04:38PM
(#5527989)
You can do a simple terminal program in 10 lines. 10 commands probably not, but this is still fairly readable.
in perl, a simple guessing game that runs in linux/unix
#!/usr/bin/perl $SIG{ALRM} = \×up; my $random_num = int (rand(10)); print "Guess my number (0-9) in less than 10 seconds!\nGuess: "; alarm 10; while(1){ my $guess = <>; if ($guess == $random_num){alarm 0;print "You Got it! Well done!\n"; last; } else { print "Nope; guess again: ";} } sub timesup {die "Uh oh! Time ran out while waiting!\n";}
From there you can go to the theme of "be a programmer of be programmed", i.e. everybody needs to know some coding. Tell them that math is not a prerequisite (a usual worry about programming) and show them some cool but simple game programming examples using Scratch, pygame and the like. In fact, it would be great if you can create a game during the presentation, with ~10 lines of code.