Search the Community
Showing results for tags 'minimalist'.
Found 1 result
Over on the Atari 8 bit forums, they are having a contest where they challenge programmers to "write a game in ten lines of basic"! http://atariage.com/forums/topic/234337-basic-ten-liners-contest-2015/?hl=+basic%20+contest I wondered if I it was possible to write an IntyBasic Game in 10 lines.... Only one way to find out! So I gave it a try.... The result is snake! (Click to animate) Here is the whole program: start: cls : for i = 0 to 19 : poke $200+i,(56*+1 : poke $200 + (20 * 11) + i,(56 * +1 : if i < 11 then poke $200+(20 * i),(56 * +1 : poke $213 + (20 * i) , (56 * + 1 ' line 1 next i : food = 0 : score = 0 ' line 2 dim snake(180) ' line 3 for i = 0 to 179 : snake(i) = 0 : next i : snake(0) = 130 : snake(1) = 131 : slen = 1 : #sdir = 1 : poke $200 + 130,(56 * + 2 : poke $200 + 131, (56 * + 2 ' line 4 loop: wait ' line 5 if food = 0 then food = RAND : if (food > 240) OR (peek($200 + food) <> 0) then food = 0 else poke $200+food,(38 * + 5 ' line 6 if cont1.left then #sdir = -1 else if cont1.right then #sdir = 1 else if cont1.up then #sdir = -20 else if cont1.down then #sdir = 20 ' line 7 if (frame AND $0f) = 0 then #adrs = snake(slen) + #sdir + $200 : if (peek(#adrs) AND $07f8) = (56 * then goto game_over else poke #adrs,(56 * + 2 : if #adrs = (food + $200) then slen = slen + 1 : snake(slen) = #adrs : food = 0 : score = score + 1 else poke $200 + snake(0),0 : for I = 0 to slen : snake(i) = snake(i+1) : next i : snake(slen) = #adrs ' line 8 goto loop ' line 9 game_over: print at 25, "game over" : print at 44, "score = " : print <3> score : wait : if cont2.key = 12 then goto game_over else goto start' line 10 Here is a longer, more readable version (essentially the same program spread over more lines with some comments...) rem snake program rem copyright 2015 rem Catsfolly CONST bluex = (56 * + 1 CONST redx = (56 * + 2 CONST greenf = (38 * + 5 CONST backtab = $200 dim snake(180) ' snake data (offset from start of backtab for each snake piece start: cls ' clear the screen for i = 0 to 19 poke backtab+i,bluex ' draw the top border poke backtab + (20 * 11) + i,bluex ' draw the bottom border if i < 11 then poke backtab+(20 * i),bluex : poke backtab + 19 + (20 * i) , bluex ' top and bottom borders next i food = 0 ' food position. 0 means no food on screen score = 0 ' score rem init snake for i = 0 to 179 : snake(i) = 0 : next i ' clear offsets (probably not necessary…) snake(0) = 130 : snake(1) = 131 ' put first 2 segments in the center of the screen slen = 1 ' there are two segments, number 0 and 1 #sdir = 1 ' direction is "1" (add one to the current address to get to the next square) poke backtab + 130,redx ' draw the first two segments poke backtab + 131, redx loop: wait rem if there is no food then try a random number. If the random number < 240 and the location at backtab rem + the number is blank, then draw the food there and set food to the random number if food = 0 then food = RAND : if (food > 240) OR (peek(backtab + food) <> 0) then food = 0 else poke backtab+food,greenF rem set the direction variable based on the controls (uses exact directions, so probably unplayable with a rem real intelliision controller if cont1.left then #sdir = -1 else if cont1.right then #sdir = 1 else if cont1.up then #sdir = -20 else if cont1.down then #sdir = 20 if (frame AND $0f) <> 0 then goto loop ' slow down the action #adrs = snake(slen) + #sdir + backtab ' get the address of the next square for the snake if (peek(#adrs) AND $07f8) = (56 * then goto game_over ' if its an x, goto game over poke #adrs, redx ' put an x at the new square rem if the new square is where the food was, make the snake longer, set food to zero, and inc the score rem otherwise clear the first square of the snake, and shift the addresses down in the array if #adrs = (food + backtab) then slen = slen + 1 : snake(slen) = #adrs : food = 0 : score = score + 1 else poke backtab + snake(0),0 : for I = 0 to slen : snake(i) = snake(i+1) : next i : snake(slen) = #adrs goto loop game_over: print at 25, "game over" print at 44, "score = " print <3> score : wait if cont2.key = 12 then goto game_over else goto start The game checks for exact up, down, left, and right values on the controls, so it might be difficult to play on real hardware. Here are the files: snake.bas snake_readable.bas snake.rom How about you? Why not take a break from your mega-epic-kroztastic-supergame project, and write a game 10 lines of basic? Catsfolly