catsfolly Posted February 8, 2015 Share Posted February 8, 2015 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 10 Quote Link to comment Share on other sites More sharing options...
Kiwi Posted February 9, 2015 Share Posted February 9, 2015 I'm thinking there is no limit how much you can put on one line in IntyBASIC. Once I finish my ULTRAMEGA-EPIC-KROZTASTIC SUPER SECRET DUPER GAME Colecovision game, or take a short break from... I may have an idea for the 10 lines game challenge. 2 Quote Link to comment Share on other sites More sharing options...
intvnut Posted February 9, 2015 Share Posted February 9, 2015 (edited) I guess if you want to be a real bastard, you can encode a game as one really long DATA statement containing the machine code for any game you like. Something tells me that that's not entirely within the spirit of the contest. ;) EDIT: I finally clicked and read the rules, and they've thought of that, putting limitations on line length and forbidding machine code entirely. You have to stay within the language and can't go too nuts on line length. The game checks for exact up, down, left, and right values on the controls, so it might be difficult to play on real hardware. Actually, I thought the cont1.left / cont1.right / etc. checked the direction bits, so the worst that would happen is that left/right win when you edge into the diagonals, but up/down get a decent slice anyway. (If I read your code correctly.) Left and Right will get about 37.5% of the disc range each, while Up and Down each get 12.5%. Checking for exact cardinal directions is far worse, giving each input direction only 6.25% of the disc range, and 75% of the disc range gets rejected as invalid input. I'm sure someone could do a decent, simplified Simon in 10 lines. My own ECS BASIC version was a bit longer than that; however, ECS BASIC only allowed one statement per line. Edited February 9, 2015 by intvnut 1 Quote Link to comment Share on other sites More sharing options...
fsuinnc Posted February 9, 2015 Share Posted February 9, 2015 I think this is amazing. 1 Quote Link to comment Share on other sites More sharing options...
Kiwi Posted February 10, 2015 Share Posted February 10, 2015 (edited) I took a break from my epic game and make an attempt to this challenge. Some things can't be stacked like if statements, sometimes label and wait. This is 20 lines. Sorry, kinda over my head. reset:cls:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:Ena=1:Enx=19:Eny=100:count=0:sc=0: loop: print at Enx+Eny color 7," ":print at ypos color 7," ":if sc=10 then EnTmax=8 if tick=1 then if cont1.up AND ypos>40 then ypos=ypos-20 if tick=1 then if cont1.down AND ypos<160 then ypos=ypos+20 if tick=1 then if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=0:Lasy=ypos:print at Lasx+Lasy color 2," -" if Enx+Eny=Lasx+Lasy then print at Lasx+Lasy color 3," ":Lasa=0:sc=sc+1:Lasx=0:Lasy=0:Enx=19:Eny=20+20*count if Entick=1 then Enx=Enx-1 if Enx=0 then Goto GameOver if tick=2 AND Lasa=1 then Lasx=Lasx+1:print at Lasx+Lasy color 2," -" if Lasx=17 then Lasa=0:print at Lasx+Lasy color 3," " print at ypos color 7,">":print at Enx+Eny color 4,"0":if sc=20 then EnTmax=6 tick=tick-1:Entick=Entick-1:if sc=40 then EnTmax=3 if tick=0 then tick=6:count=count+1:if count=8 then count=0 if Entick=0 then Entick=EnTmax: if sc=80 then EnTmax=3 wait goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B0 then goto reset goto GameOver Here's the gifo of the game in action. <-click to animate Here's the binary NB.bin It's what I programmed on the graphing calculator back in high school. You're on an epic mission. You the sole ship, while the others quivers at home waiting for their impending doom, will attempt to defend this planet. You can't let a single meteor get by you. You have to shoot the meteor, otherwise the planet is in grave peril danger into extinction. You definitely do not want that to happen do you? Now start shoot'n brave space warrior!!!! Enjoy. I need to work on sleeping. Edited February 10, 2015 by Kiwi 3 Quote Link to comment Share on other sites More sharing options...
catsfolly Posted February 10, 2015 Author Share Posted February 10, 2015 I took a break from my epic game and make an attempt to this challenge. Some things can't be stacked like if statements, sometimes label and wait. This is 20 lines. Sorry, kinda over my head. reset:cls:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:Ena=1:Enx=19:Eny=100:count=0:sc=0: loop: print at Enx+Eny color 7," ":print at ypos color 7," ":if sc=10 then EnTmax=8 if tick=1 then if cont1.up AND ypos>40 then ypos=ypos-20 if tick=1 then if cont1.down AND ypos<160 then ypos=ypos+20 if tick=1 then if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=0:Lasy=ypos:print at Lasx+Lasy color 2," -" if Enx+Eny=Lasx+Lasy then print at Lasx+Lasy color 3," ":Lasa=0:sc=sc+1:Lasx=0:Lasy=0:Enx=19:Eny=20+20*count if Entick=1 then Enx=Enx-1 if Enx=0 then Goto GameOver if tick=2 AND Lasa=1 then Lasx=Lasx+1:print at Lasx+Lasy color 2," -" if Lasx=17 then Lasa=0:print at Lasx+Lasy color 3," " print at ypos color 7,">":print at Enx+Eny color 4,"0":if sc=20 then EnTmax=6 tick=tick-1:Entick=Entick-1:if sc=40 then EnTmax=3 if tick=0 then tick=6:count=count+1:if count=8 then count=0 if Entick=0 then Entick=EnTmax: if sc=80 then EnTmax=3 wait goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B0 then goto reset goto GameOver Here's the gifo of the game in action. ShootingGame.gif<-click to animate Here's the binary NB.bin It's what I programmed on the graphing calculator back in high school. You're on an epic mission. You the sole ship, while the others quivers at home waiting for their impending doom, will attempt to defend this planet. You can't let a single meteor get by you. You have to shoot the meteor, otherwise the planet is in grave peril danger into extinction. You definitely do not want that to happen do you? Now start shoot'n brave space warrior!!!! Enjoy. I need to work on sleeping. Pretty Cool. It's a complete game. I've gotten up to 20 points so far. I'll bet that if you used sprites instead of backtab, you could make it shorter (since you wouldn't have to erase things...) Enjoy your sleep! Catsfolly 1 Quote Link to comment Share on other sites More sharing options...
intvnut Posted February 10, 2015 Share Posted February 10, 2015 (edited) I took a break from my epic game and make an attempt to this challenge. Some things can't be stacked like if statements, sometimes label and wait. This is 20 lines. Sorry, kinda over my head. reset:cls:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:Ena=1:Enx=19:Eny=100:count=0:sc=0: loop: print at Enx+Eny color 7," ":print at ypos color 7," ":if sc=10 then EnTmax=8 if tick=1 then if cont1.up AND ypos>40 then ypos=ypos-20 if tick=1 then if cont1.down AND ypos<160 then ypos=ypos+20 if tick=1 then if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=0:Lasy=ypos:print at Lasx+Lasy color 2," -" if Enx+Eny=Lasx+Lasy then print at Lasx+Lasy color 3," ":Lasa=0:sc=sc+1:Lasx=0:Lasy=0:Enx=19:Eny=20+20*count if Entick=1 then Enx=Enx-1 if Enx=0 then Goto GameOver if tick=2 AND Lasa=1 then Lasx=Lasx+1:print at Lasx+Lasy color 2," -" if Lasx=17 then Lasa=0:print at Lasx+Lasy color 3," " print at ypos color 7,">":print at Enx+Eny color 4,"0":if sc=20 then EnTmax=6 tick=tick-1:Entick=Entick-1:if sc=40 then EnTmax=3 if tick=0 then tick=6:count=count+1:if count=8 then count=0 if Entick=0 then Entick=EnTmax: if sc=80 then EnTmax=3 wait goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B0 then goto reset goto GameOver Here's the gifo of the game in action. ShootingGame.gif<-click to animate Here's the binary NB.bin It's what I programmed on the graphing calculator back in high school. You're on an epic mission. You the sole ship, while the others quivers at home waiting for their impending doom, will attempt to defend this planet. You can't let a single meteor get by you. You have to shoot the meteor, otherwise the planet is in grave peril danger into extinction. You definitely do not want that to happen do you? Now start shoot'n brave space warrior!!!! Enjoy. I need to work on sleeping. You can get rid of several IF statements with 'branchless code' tricks. The statement 'tick=1' evaluates to $FFFF when true and $0000 when false. cont1.blah evaluate to different non-zero values when true, and 0 when false. So these two lines: . if tick=1 then if cont1.up AND ypos>40 then ypos=ypos-20 if tick=1 then if cont1.down AND ypos<160 then ypos=ypos+20 . can be written as a single non-if statement of doom: . ypos = ypos + (tick = 1) AND (((cont1.down <> 0) AND (ypos < 160) AND 20) - ((cont1.up <> 0) AND (ypos > 40) AND 20)) . And these two: . tick=tick-1:Entick=Entick-1:if sc=40 then EnTmax=3 if tick=0 then tick=6:count=count+1:if count=8 then count=0 . ...become... . count=(count-(tick=1)) AND 7 : tick=(tick+6)%7 : Entick=Entick-1 :EnTmax = ((sc=40) AND 3)+((sc<>40) AND EnTmax) . At least, I think that's right. :-) Edited February 10, 2015 by intvnut 3 Quote Link to comment Share on other sites More sharing options...
catsfolly Posted February 10, 2015 Author Share Posted February 10, 2015 Ouch! Looks like I can't write a one line subroutine in IntyBasic. This one line version gives me an error: initrob: procedure : rx(i) = (160 * i) : ry(i) = (rand AND $3f) + 15 : #rxv(i) = 1 - (2 * i) : end While the 3 line version works fine: initrob: procedure rx(i) = (160 * i) : ry(i) = (rand AND $3f) + 15 : #rxv(i) = 1 - (2 * i) end Catsfolly "We could try it, but it was never designed to work that way, Captain!" - Mr. Scott Quote Link to comment Share on other sites More sharing options...
Kiwi Posted February 10, 2015 Share Posted February 10, 2015 This is the 0x0F lines version of the game with one bug fixed and better progression of difficulty. Also one bug fix that the laser won't go through rocks "Pacman vs Ghost" style. I use frame%1000=1 to cut down the if's statements. Oddly that the exec variable would reset back to 0. I think cls the one that reset the variable. reset:cls:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:Ena=1:Enx=19:Eny=100:count=0:sc=0: loop:print at Enx+Eny color 7," ":print at ypos color 7," ":if tick=1 then if cont1.up AND ypos>40 then ypos=ypos-20 if tick=1 then if cont1.down AND ypos<160 then ypos=ypos+20: if tick=1 then if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=0:Lasy=ypos:print at Lasx+Lasy color 2," -" if Enx+Eny=Lasx+Lasy OR Enx+Eny=Lasx+Lasy-1 then print at Lasx+Lasy color 3," ":Lasa=0:sc=sc+1:Lasx=0:Lasy=0:Enx=19:Eny=20+20*count if Entick=1 then Enx=Enx-1 if Enx=0 then Goto GameOver if tick=2 AND Lasa=1 then Lasx=Lasx+1:print at Lasx+Lasy color 2," -" if Lasx=17 then Lasa=0:print at Lasx+Lasy color 3," " print at ypos color 7,">":print at Enx+Eny color 4,"0":tick=tick-1:Entick=Entick-1:if tick=0 then tick=6:count=count+1:if count=8 then count=0 if Entick=0 then Entick=EnTmax: if frame%1000=1 then EnTmax=EnTmax-1 wait goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B0 then goto reset goto GameOver NB.bin I did copy and paste the branchless codea. It caused the ship to jump around. I'll try that again later. I'm going to try doing a sprite version to see if the game gets smaller. 1 Quote Link to comment Share on other sites More sharing options...
intvnut Posted February 10, 2015 Share Posted February 10, 2015 I did copy and paste the branchless code. It caused the ship to jump around. I'll try that again later. I'm going to try doing a sprite version to see if the game gets smaller. It's entirely possible I missed a required pair of parentheses somewhere. I may get a chance later to mess around with it myself, but right now I haven't the time. Quote Link to comment Share on other sites More sharing options...
Kiwi Posted February 10, 2015 Share Posted February 10, 2015 reset:cls:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:Ena=1:Enx=19:Eny=100:count=0:sc=0: loop:print at Enx+Eny color 7," ":print at ypos color 7," ":if tick=1 then if cont1.up AND ypos>40 then ypos=ypos-20 else if tick=1 then if cont1.down AND ypos<160 then ypos=ypos+20 else if tick=1 then if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=0:Lasy=ypos:print at Lasx+Lasy color 2," -" if Enx+Eny=Lasx+Lasy OR Enx+Eny=Lasx+Lasy-1 then print at Lasx+Lasy color 3," ":Lasa=0:sc=sc+1:Lasx=0:Lasy=0:Enx=19:Eny=20+20*count if Entick=1 then Enx=Enx-1 if Enx=0 then Goto GameOver if tick=2 AND Lasa=1 then Lasx=Lasx+1:print at Lasx+Lasy color 2," -" if Lasx=17 then Lasa=0:print at Lasx+Lasy color 3," " print at ypos color 7,">":print at Enx+Eny color 4,"0":tick=tick-1:Entick=Entick-1:if tick=0 then tick=6:count=count+1:if count=8 then count=0 if Entick=0 then Entick=EnTmax: if frame%1000=1 then EnTmax=EnTmax-1 wait goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B1 then goto reset goto GameOver NB.bin I think 14 lines is the best I could do with this version of this game. I looked at cat's cont statement and added else and stack the cont statement. The game works fine. I changed the button in Gameover loop to B1, so you don't skip the score screen if you're holding button B0 once the game is over. Now I'm going to do a sprite version and see how many lines I can do it with sprites. 2 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 10, 2015 Share Posted February 10, 2015 reset:cls:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:Ena=1:Enx=19:Eny=100:count=0:sc=0: loop:print at Enx+Eny color 7," ":print at ypos color 7," ":if tick=1 then if cont1.up AND ypos>40 then ypos=ypos-20 else if tick=1 then if cont1.down AND ypos<160 then ypos=ypos+20 else if tick=1 then if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=0:Lasy=ypos:print at Lasx+Lasy color 2," -" if Enx+Eny=Lasx+Lasy OR Enx+Eny=Lasx+Lasy-1 then print at Lasx+Lasy color 3," ":Lasa=0:sc=sc+1:Lasx=0:Lasy=0:Enx=19:Eny=20+20*count if Entick=1 then Enx=Enx-1 if Enx=0 then Goto GameOver if tick=2 AND Lasa=1 then Lasx=Lasx+1:print at Lasx+Lasy color 2," -" if Lasx=17 then Lasa=0:print at Lasx+Lasy color 3," " print at ypos color 7,">":print at Enx+Eny color 4,"0":tick=tick-1:Entick=Entick-1:if tick=0 then tick=6:count=count+1:if count=8 then count=0 if Entick=0 then Entick=EnTmax: if frame%1000=1 then EnTmax=EnTmax-1 wait goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B1 then goto reset goto GameOver NB.bin I think 14 lines is the best I could do with this version of this game. I looked at cat's cont statement and added else and stack the cont statement. The game works fine. I changed the button in Gameover loop to B1, so you don't skip the score screen if you're holding button B0 once the game is over. Now I'm going to do a sprite version and see how many lines I can do it with sprites. I would suggest this for line 4 (removing line 5 and line 9, and entick=entick-1 from line 8 ): entick=entick-1:if entick=0 then entick=entmax else if Entick=1 then Enx=Enx-1:if Enx=0 then Goto GameOver At line 13 you could put "else goto gameover" saving yet another line (remove 14) After "wait" in line 11 you could put "wait:goto loop" removing line 12. (I couldn't resist to help a little) 3 Quote Link to comment Share on other sites More sharing options...
Kiwi Posted February 10, 2015 Share Posted February 10, 2015 (edited) I definitely wish I could stack stuff on top of wait statement. Only if I want the game to run on crack . It doesn't seem to pick up the wait statement if is being stacked on or on the stack. Sprite version of the same game. It's a bit harder since you have to be more precise. Guess what!! It's 9 lines with no more than 200 letters a line. reset:cls:frame=0:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:LasC=2:Ena=1:Ens=1:Enx=160:Eny=60:#count=0:sc=0: loop:if #count=2000 then Ens=Ens+1:#count=0 if cont1.up AND ypos>10 then ypos=ypos-2 else if cont1.down AND ypos<100 then ypos=ypos+2 else if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=30:LasC=2:Lasy=ypos: if COL1 AND $0004 then Enx=180:Eny=10+RAND/3:Lasa=0:Lasy=0:LasC=0:sc=sc+1 if Enx<8 then goto GameOver sprite 0,24+$300,$100+ypos,$00F7:sprite 1,Lasx+$300,$100+Lasy,$68+LasC:sprite 2,Enx+$300,$100+Eny,$0083:Enx=Enx-Ens:#count=#count+1:if Lasa=1 then Lasx=Lasx+3:if Lasx>200 then Lasa=0:LasC=0 wait goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B1 then goto reset else goto GameOver Only flaw that each rock destroyed now cost 2 points instead of 1point.Definitely awesome I was able to achieve this goal. Catsfolly was right, sprite does take less lines. NB.bin It's 2KB too! This is fun!! At line 13 you could put "else goto gameover" saving yet another line (remove 14) This one works. Now I have nine lines. 1 more lines available for me to abuse. (I couldn't resist to help a little) Every bit of help, helps a lot. . Thanks. Edited February 11, 2015 by Kiwi 4 Quote Link to comment Share on other sites More sharing options...
Kiwi Posted February 11, 2015 Share Posted February 11, 2015 This is my final version reset:cls:frame=0:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:LasC=2:Ena=1:Ens=1:Enx=160:Eny=60:#count=0:sc=0:sprite 3,8+$300,$300+64,$047D:sprite 4,8+$300,$B00+32,$047D loop:if #count=600 then Ens=Ens+1:#count=0 if cont1.up AND ypos>10 then ypos=ypos-2 else if cont1.down AND ypos<100 then ypos=ypos+2 else if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=30:LasC=2:Lasy=ypos: if COL1 AND $0004 then Enx=180:Eny=10+RAND/3:Lasa=0:Lasy=0:LasC=0:sc=sc+1 if Enx<8 then goto GameOver sprite 5,90+$300,$100+32,$0076:sprite 6,64+$300,$100+67,$0076:sprite 7,120+$300,$100+45,$0076:if frame%4=0 then Enx=Enx-Ens sprite 0,24+$300,$100+ypos,$00F7:sprite 1,Lasx+$300,$100+Lasy,$E8+LasC:sprite 2,Enx+$300,$100+Eny,$0083:#count=#count+1:if Lasa=1 then Lasx=Lasx+3:if Lasx>200 then Lasa=0:LasC=0 wait goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B1 then goto reset else goto GameOver I replaced the "laser" with twin "laser" to make this game a bit easier. The speed now ramp more smoothly. I added a planet and 3 stars to spice up the graphics a bit. NBfinal.bin Now I need to go back to build my EPIC KROZTASTIC SUPER MEGA SECRET GAME!!! BAHAHAHAHA!!! *thunderclaps* 4 Quote Link to comment Share on other sites More sharing options...
catsfolly Posted February 11, 2015 Author Share Posted February 11, 2015 Cool. 10 lines and it even has a background! Looking forward to your SUPER MEGA SECRET GAME!!!! Catsfolly 3 Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted February 11, 2015 Share Posted February 11, 2015 Cool. 10 lines and it even has a background! Looking forward to your SUPER MEGA SECRET GAME!!!! Catsfolly But, but, but... if it's so SUPER MEGA SECRET, how will we ever know about it?? 1 Quote Link to comment Share on other sites More sharing options...
catsfolly Posted February 11, 2015 Author Share Posted February 11, 2015 But, but, but... if it's so SUPER MEGA SECRET, how will we ever know about it?? I'm guessing that when he finishes it, he'll let us all in on the secret. (KInda like P. and P.I., and T.A.O.F.B - super secret games that you have hinted at...) Catsfolly 1 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 11, 2015 Share Posted February 11, 2015 I definitely wish I could stack stuff on top of wait statement. Only if I want the game to run on crack . It doesn't seem to pick up the wait statement if is being stacked on or on the stack. I think you reported before a bug with WAIT intermixed with colon in one line. I've checked again and I don't see the bug, I hope you could make up a sample of a program working with WAIT alone and a sample of a program not working with WAIT with colons. Quote Link to comment Share on other sites More sharing options...
Kiwi Posted February 11, 2015 Share Posted February 11, 2015 reset:cls:frame=0:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:LasC=2:Ena=1:Ens=1:Enx=160:Eny=60:#count=0:sc=0:sprite 3,8+$300,$300+64,$047D:sprite 4,8+$300,$B00+32,$047D loop:if #count=600 then Ens=Ens+1:#count=0 if cont1.up AND ypos>10 then ypos=ypos-2 else if cont1.down AND ypos<100 then ypos=ypos+2 else if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=30:LasC=2:Lasy=ypos: if COL1 AND $0004 then Enx=180:Eny=10+RAND/3:Lasa=0:Lasy=0:LasC=0:sc=sc+1 if Enx<8 then goto GameOver sprite 5,90+$300,$100+32,$0076:sprite 6,64+$300,$100+67,$0076:sprite 7,120+$300,$100+45,$0076:if frame%4=0 then Enx=Enx-Ens sprite 0,24+$300,$100+ypos,$00F7:sprite 1,Lasx+$300,$100+Lasy,$E8+LasC:sprite 2,Enx+$300,$100+Eny,$0083:#count=#count+1:if Lasa=1 then Lasx=Lasx+3:if Lasx>200 then Lasa=0:LasC=0 wait:goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B1 then goto reset else goto GameOver A wait before goto loop will cause the bug and the code for wait didn't seems to work. NBwaitbeforegoto.bin I did look at Catfolly's 10 lines source code and see where he placed it. reset:cls:frame=0:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:LasC=2:Ena=1:Ens=1:Enx=160:Eny=60:#count=0:sc=0:sprite 3,8+$300,$300+64,$047D:sprite 4,8+$300,$B00+32,$047D loop:wait:if #count=600 then Ens=Ens+1:#count=0 if cont1.up AND ypos>10 then ypos=ypos-2 else if cont1.down AND ypos<100 then ypos=ypos+2 else if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=30:LasC=2:Lasy=ypos: if COL1 AND $0004 then Enx=180:Eny=10+RAND/3:Lasa=0:Lasy=0:LasC=0:sc=sc+1 if Enx<8 then goto GameOver sprite 5,90+$300,$100+32,$0076:sprite 6,64+$300,$100+67,$0076:sprite 7,120+$300,$100+45,$0076:if frame%4=0 then Enx=Enx-Ens sprite 0,24+$300,$100+ypos,$00F7:sprite 1,Lasx+$300,$100+Lasy,$E8+LasC:sprite 2,Enx+$300,$100+Eny,$0083:#count=#count+1:if Lasa=1 then Lasx=Lasx+3:if Lasx>200 then Lasa=0:LasC=0 goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B1 then goto reset else goto GameOver This works. Having the wait after the loop: will be picked up. This freed up 1 line. And the secret game I'm working on is for a gift to friend of mine. After I finish, I'll show it. Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 11, 2015 Share Posted February 11, 2015 reset:cls:frame=0:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:LasC=2:Ena=1:Ens=1:Enx=160:Eny=60:#count=0:sc=0:sprite 3,8+$300,$300+64,$047D:sprite 4,8+$300,$B00+32,$047D loop:if #count=600 then Ens=Ens+1:#count=0 if cont1.up AND ypos>10 then ypos=ypos-2 else if cont1.down AND ypos<100 then ypos=ypos+2 else if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=30:LasC=2:Lasy=ypos: if COL1 AND $0004 then Enx=180:Eny=10+RAND/3:Lasa=0:Lasy=0:LasC=0:sc=sc+1 if Enx<8 then goto GameOver sprite 5,90+$300,$100+32,$0076:sprite 6,64+$300,$100+67,$0076:sprite 7,120+$300,$100+45,$0076:if frame%4=0 then Enx=Enx-Ens sprite 0,24+$300,$100+ypos,$00F7:sprite 1,Lasx+$300,$100+Lasy,$E8+LasC:sprite 2,Enx+$300,$100+Eny,$0083:#count=#count+1:if Lasa=1 then Lasx=Lasx+3:if Lasx>200 then Lasa=0:LasC=0 wait:goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B1 then goto reset else goto GameOver A wait before goto loop will cause the bug and the code for wait didn't seems to work. NBwaitbeforegoto.bin I did look at Catfolly's 10 lines source code and see where he placed it. reset:cls:frame=0:ypos=62:Entick=12:EnTmax=12:tick=8:Lasa=0:Lasx=1:LasC=2:Ena=1:Ens=1:Enx=160:Eny=60:#count=0:sc=0:sprite 3,8+$300,$300+64,$047D:sprite 4,8+$300,$B00+32,$047D loop:wait:if #count=600 then Ens=Ens+1:#count=0 if cont1.up AND ypos>10 then ypos=ypos-2 else if cont1.down AND ypos<100 then ypos=ypos+2 else if cont1.B0 AND Lasa=0 then Lasa=1:Lasx=30:LasC=2:Lasy=ypos: if COL1 AND $0004 then Enx=180:Eny=10+RAND/3:Lasa=0:Lasy=0:LasC=0:sc=sc+1 if Enx<8 then goto GameOver sprite 5,90+$300,$100+32,$0076:sprite 6,64+$300,$100+67,$0076:sprite 7,120+$300,$100+45,$0076:if frame%4=0 then Enx=Enx-Ens sprite 0,24+$300,$100+ypos,$00F7:sprite 1,Lasx+$300,$100+Lasy,$E8+LasC:sprite 2,Enx+$300,$100+Eny,$0083:#count=#count+1:if Lasa=1 then Lasx=Lasx+3:if Lasx>200 then Lasa=0:LasC=0 goto loop: GameOver:print at 206 color 7,"GameOver":print at 221,(sc/100%10+16)*8+6:print at 222,(sc/10%10+16)*8+6:print at 223,(sc%10+16)*8+6:if cont1.B1 then goto reset else goto GameOver This works. Having the wait after the loop: will be picked up. This freed up 1 line. And the secret game I'm working on is for a gift to friend of mine. After I finish, I'll show it. I see now what's the bug the WAIT: is taken as a label, I'll solve it for next version of IntyBASIC in the meanwhile just put a space between WAIT and the semicolon 3 Quote Link to comment Share on other sites More sharing options...
carlsson Posted February 12, 2015 Share Posted February 12, 2015 I've never used IntyBASIC, but I'd probably use at least one IF statement in intvnut's if-less code to make it more clear: if tick=1 then ypos=ypos + (cont1.down<>0 and ypos<160 and 20) - (cont1.up<>0 and ypos>40 and 20) I realize that cont1.down<>0 as well as ypos<160 will evaluate to either $FFFF or 0, and if you make a binary AND between the result and your desired value, either you get your value or nothing. If IntyBASIC in the future added syntactic sugar like the SGN function, you could make it a bit more pretty (?!): if tick=1 then ypos=ypos + (sgn(cont1.down) * sgn(ypos<160) * 20) - (sgn(cont1.up) * sgn(ypos>40) * 20) I didn't read up on whether IntyBASIC works with signed or unsigned integers, i.e. if $FFFF really is a two-complement representation of -1 or if it represents 65535. If it is treated as -1, the binary AND statement above likely won't work as expected? 1 Quote Link to comment Share on other sites More sharing options...
+nanochess Posted February 12, 2015 Share Posted February 12, 2015 I've never used IntyBASIC, but I'd probably use at least one IF statement in intvnut's if-less code to make it more clear: if tick=1 then ypos=ypos + (cont1.down<>0 and ypos<160 and 20) - (cont1.up<>0 and ypos>40 and 20) I realize that cont1.down<>0 as well as ypos<160 will evaluate to either $FFFF or 0, and if you make a binary AND between the result and your desired value, either you get your value or nothing. If IntyBASIC in the future added syntactic sugar like the SGN function, you could make it a bit more pretty (?!): if tick=1 then ypos=ypos + (sgn(cont1.down) * sgn(ypos<160) * 20) - (sgn(cont1.up) * sgn(ypos>40) * 20) I didn't read up on whether IntyBASIC works with signed or unsigned integers, i.e. if $FFFF really is a two-complement representation of -1 or if it represents 65535. If it is treated as -1, the binary AND statement above likely won't work as expected? Hmmm! It could work. BTW, SGN function could be a nice addition for a future IntyBASIC Quote Link to comment Share on other sites More sharing options...
intvnut Posted February 12, 2015 Share Posted February 12, 2015 (edited) I've never used IntyBASIC, but I'd probably use at least one IF statement in intvnut's if-less code to make it more clear: if tick=1 then ypos=ypos + (cont1.down<>0 and ypos<160 and 20) - (cont1.up<>0 and ypos>40 and 20) I realize that cont1.down<>0 as well as ypos<160 will evaluate to either $FFFF or 0, and if you make a binary AND between the result and your desired value, either you get your value or nothing. If IntyBASIC in the future added syntactic sugar like the SGN function, you could make it a bit more pretty (?!): if tick=1 then ypos=ypos + (sgn(cont1.down) * sgn(ypos<160) * 20) - (sgn(cont1.up) * sgn(ypos>40) * 20) I didn't read up on whether IntyBASIC works with signed or unsigned integers, i.e. if $FFFF really is a two-complement representation of -1 or if it represents 65535. If it is treated as -1, the binary AND statement above likely won't work as expected? Of course, in order for * to be more efficient than AND in the generated code, the IntyBASIC compiler would have to be smart enough to know that these particular uses of SGN only return 0 or -1, and so would implement the Boolean logic with simple branches (or convert it back into a bitwise AND). In general, SGN can return -1, 0 or 1. If IntyBASIC only took that more general case into account (without optimizing for the special cases where it only returns 0 or -1), then the resulting code would perform less well, since it needed to handle the three-way dispatch for SGN(foo) * whatever. In the most general case, IntyBASIC wouldn't generate any specialized code for SGN(foo) * whatever, and would penalize your execution time with the cost of a full multiply. That would be rather painful on the Intellivision. All that said, I was no stranger to using * and + to implement Boolean logic on certain BASIC dialects 30 years ago, especially on my TI Home Computer. Edited February 12, 2015 by intvnut 1 Quote Link to comment Share on other sites More sharing options...
intvnut Posted February 12, 2015 Share Posted February 12, 2015 (edited) I didn't read up on whether IntyBASIC works with signed or unsigned integers, i.e. if $FFFF really is a two-complement representation of -1 or if it represents 65535. If it is treated as -1, the binary AND statement above likely won't work as expected? Oh, and IntyBASIC is a 2s complement integer BASIC. No floating point / real number representation. -1 is $FFFF is effectively 65535. So, (-1 AND x) = x. And for a 16-bit * 16-bit into 16-bit integer, signed vs. unsigned doesn't matter. 65535 * x will give the same result as -1 * x, assuming the language only keeps the lower 16 bits of the result (which I believe is the case). EDIT: I believe the comparison operators are signed (ie. x < y does a signed compare), but otherwise I'm not certain which constructs in the language actually are about signedness vs. not. Addition / subtraction don't care. Multiplication doesn't care. Not sure the policy on division. EDIT 2: Here's an example showing 65535 and -1 are the same wrt. to multiplication, but that comparisons are signed: CLS WAIT #X = 65535 #Y = 42 #Z = #X * #Y #A = -1 #B = 42 #C = #A * #B PRINT AT 0, <5> #Z PRINT AT 20, <5> #C IF #X < #Y THEN PRINT AT 40, "X < Y" ELSE PRINT AT 40, "X >= Y" IF #A < #B THEN PRINT AT 60, "A < B" ELSE PRINT AT 60, "A >= B" here: GOTO here And the output: Edited February 12, 2015 by intvnut Quote Link to comment Share on other sites More sharing options...
catsfolly Posted February 15, 2015 Author Share Posted February 15, 2015 This is Robot Blast! Beta version... (click to animate...) Shoot the robots. When 10 robots escape from the screen, the game is over. It is technically 10 lines long, but I think the line length would disqualify me for any contests.... (IntyBasic allows for long lines...) title: cls : print at (20* 3 + 5) COLOR 5,"ROBOT BLAST!" : print at (20*11 + 1) ,"S: FREE: /10" : DEFINE 0,10,gramchars : wait : X=80 : Y = 50 : shottimer=0 : ex = 80 : ey = 50 : #etimer = 30 : #rv = 1 : free = 0 : dim #rx(2) : dim ry(2) : dim #rxv(2) : dim ron(2) : for i = 0 to 1 : #rx(i) = ((160 * * i) : ry(i) = (rand AND $3f) + 15 : ron(i) = 0 : next i loop: wait : #rxv(0) = #rv/8 + 1 : #rxv(1) = 0 - #rxv(0) : for i = 0 to 1 : #rx(i) = (#rx(i) + #rxv(i)) AND $07ff : next i : newy = (rand AND $3f) + 15 : if (#rx(0) > (200 * ) then ry(0) = newy : free = free + ron(0) : ron(0) = 0 else ron(0) = 1 : if (#rx(1) > (200 * ) then ry(1) = newy : free = free + ron(1) : ron(1) = 0 else ron(1) = 1 IF cont1.left THEN X=X-2 else if cont1.right then X=X+2 if cont1.up then Y=Y-2 else if cont1.down then Y=Y+2 if shottimer = 0 then if cont2.B0 then shottimer = 60: sdx = X : sdy = y else sdy= 120 else shottimer = shottimer -4 : if shottimer = 0 then test = (COL3 AND 2) + (COL4 AND 4) : if test = 0 then goto nohit else ex = sdx : ey = sdy : #etimer = 0 : #rv = #rv+1 : #exa = $0800 + (5 * + 6 : if test = 4 THEN ron(1) = 0 : #rx(1) = (201 * : #exa = #exa - 5 else ron(0)=0 : #rx(0) = 201 * 8 nohit: if #etimer > 29 then Sprite 5,0,0,0 : Sprite 6,0,0,0 : SPRITE 7,0,0,0 else #etimer = #etimer + 2 : #einc = ((#etimer - (((frame AND 1) * 2) * #etimer)) + ey) AND $7f : SPRITE 5,(ex - #etimer) + $0100 + $0200, #einc +$0100,#exa : SPRITE 6,(ex + #etimer) + $0100 + $0200, #einc +$0100,#exa : SPRITE 7,ex + $0100 + $0200, #einc +$0100,#exa SPRITE 3,sdx - (shottimer - 4) + $0100 + $0200, ((sdy + shottimer/4) AND $7f) +$0100,$0800 + 2 + (6 * : SPRITE 4,sdx + (shottimer - 4) + $0100 + $0200, ((sdy + shottimer/4) AND $7f) +$0100,$0800 + 2 + (6 * : SPRITE 1,#rx(0)/8 + $0100 + $0200, ry(0)+$0100,$0800 + 6 + (#rx(0) AND (3 * ) SPRITE 2,#rx(1)/8 + $0100 + $0200, ry(1)+$0500,$0800 + 1 + (3 * - (#rx(1) AND (3 * ) : SPRITE 0,X + $0300, (Y AND $7f)+$0100,$0800 + 7 + (4 * : print at (20*11 + 3) color 7, <5> #rv-1 : print at (20 * 11 + 14), <2> free gover_loop: if free < 10 goto loop else print at (20 * 3 + 4) COLOR 7, " GAME OVER " : if cont2.key <> 12 then goto title else wait : goto gover_loop gramchars: data 7198,2078,10303,1032, 7198,2078,10303,2060, 7198,2078,10303,4106, 7198,2078,10303,536, $1818,$e718, $18e7,$1818, 13312, 23086, 22126, 52, 15360, 32382, 32382, 60 It currently starts out slow and gets ridiculously fast. And it uses all the motion objects... robotblast.rom robotblast.bas (Readable version coming soon...) Catsfolly 6 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.