|
Post by B+ on Apr 7, 2021 16:15:15 GMT
Snake code reminded me of this, printing diagonally SNAKE,SNAKE... from bottom left corner to top right corner
'zmeyrus.bas Danilin copy 2021-01-25 and b+ mod ' b+ mod of Danilin Matrix Diagonal Snake" ' 2021-04-07 b+ simplify mod for JB as Block Snake
' NxN block is limited by SETUP Preferences specially rows ' @40 rows JB steals 4 rows: one for scroll bar and 3 for title bar!
' From bottom left corner you should read SNAKE,SNAKE.... diagonnally up or down to edge where it reverse back like snake, all the way to upper right corner.
n = 36 ' <<<< 36 is max 36x36 block that fits 40 row setup in preferences for main Window DIM a$(n, n) b$ = "SNAKE," FOR i = 1 TO 500 s$ = s$ + b$ NEXT x = n: y = 1: s = -1 ' <<<<<<<<<<<<<< oh dang! you do x,y backwards!!! 'lastx = (y - 1) * 16 + 4: lasty = (x - 1) * 16 + 8 DO scan DO scan k = k + 1 a$(x, y) = MID$(s$, k, 1)
'this line helped see direction of snake 'thic lastx, lasty, (y - 1) * 16 + 4, (x - 1) * 16 + 8, 4, &HAAFFFF00 'lastx = (y - 1) * 16 + 4: lasty = (x - 1) * 16 + 8 x = x + s: y = y + s LOOP UNTIL x > n OR y > n OR x < 1 OR y < 1 IF x < 1 AND y < 1 THEN x = 1: y = 2 IF x > n AND y > n THEN x = n - 1: y = n IF y < 1 THEN y = 1 IF x < 1 THEN x = 1: y = y + 2 IF x > n THEN x = n: IF y > n THEN x = x - 2: y = n s = -1 * s LOOP UNTIL k = n * n
FOR x = 1 TO n locate 1, x : Print x; FOR y = 1 TO n locate x* 2+ 5, y : print a$(y, x); NEXT NEXT
If you can't see it reduce n to 5 or 10, it should work for any n up to number of rows JB lets you see in one screen without scroll.
|
|
|
Post by tsh73 on Apr 7, 2021 18:38:03 GMT
Wha-wha-wha-whats going on? (EDIT Oh, that was Crazy Frog...)
(just had hard time to understand how SNAKE should be read)
'zmeyrus.bas Danilin copy 2021-01-25 and b+ mod ' b+ mod of Danilin Matrix Diagonal Snake" ' 2021-04-07 b+ simplify mod for JB as Block Snake
' NxN block is limited by SETUP Preferences specially rows ' @40 rows JB steals 4 rows: one for scroll bar and 3 for title bar!
' From bottom left corner you should read SNAKE,SNAKE.... diagonnally up or down to edge where it reverse back like snake, all the way to upper right corner.
n = 36 ' <<<< 36 is max 36x36 block that fits 40 row setup in preferences for main Window n = 20 DIM a$(n, n) b$ = "SNAKE," FOR i = 1 TO 500 s$ = s$ + b$ NEXT x = n: y = 1: s = -1 ' <<<<<<<<<<<<<< oh dang! you do x,y backwards!!! 'lastx = (y - 1) * 16 + 4: lasty = (x - 1) * 16 + 8 DO scan DO scan k = k + 1 a$(x, y) = MID$(s$, k, 1) locate x, y: print a$(x, y); call pause 50
'this line helped see direction of snake 'thic lastx, lasty, (y - 1) * 16 + 4, (x - 1) * 16 + 8, 4, &HAAFFFF00 'lastx = (y - 1) * 16 + 4: lasty = (x - 1) * 16 + 8 x = x + s: y = y + s LOOP UNTIL x > n OR y > n OR x < 1 OR y < 1 IF x < 1 AND y < 1 THEN x = 1: y = 2 IF x > n AND y > n THEN x = n - 1: y = n IF y < 1 THEN y = 1 IF x < 1 THEN x = 1: y = y + 2 IF x > n THEN x = n: IF y > n THEN x = x - 2: y = n s = -1 * s LOOP UNTIL k = n * n
end FOR x = 1 TO n locate 1, x : Print x; FOR y = 1 TO n locate x* 2+ 5, y : print a$(y, x); NEXT NEXT
sub pause mil t0=time$("ms") while time$("ms")-t0< mil scan wend end sub
|
|
|
Post by B+ on Apr 7, 2021 21:03:40 GMT
Yeah OK, let's spread it out better:
'zmeyrus.bas Danilin copy 2021-01-25 and b+ mod ' b+ mod of Danilin Matrix Diagonal Snake" ' 2021-04-07 b+ simplify mod for JB as Block Snake
' NxN block is limited by SETUP Preferences specially rows ' @40 rows JB steals 4 rows: one for scroll bar and 3 for title bar!
' From bottom left corner you should read SNAKE,SNAKE.... diagonnally up or down to edge where it reverse back like snake, all the way to upper right corner.
n = 36 ' <<<< 36 is max 36x36 block that fits 40 row setup in preferences for main Window n = 20 ' <<< OK so 36 too big for tsh73 DIM a$(n, n) b$ = "SNAKE," FOR i = 1 TO 500 s$ = s$ + b$ NEXT x = n: y = 1: s = -1 ' <<<<<<<<<<<<<< oh dang! you do x,y backwards!!! 'lastx = (y - 1) * 16 + 4: lasty = (x - 1) * 16 + 8 DO scan DO scan k = k + 1 a$(x, y) = MID$(s$, k, 1) locate 2*x + 1, y: print a$(x, y); call pause 50 x = x + s: y = y + s LOOP UNTIL x > n OR y > n OR x < 1 OR y < 1 IF x < 1 AND y < 1 THEN x = 1: y = 2 IF x > n AND y > n THEN x = n - 1: y = n IF y < 1 THEN y = 1 IF x < 1 THEN x = 1: y = y + 2 IF x > n THEN x = n: IF y > n THEN x = x - 2: y = n s = -1 * s LOOP UNTIL k = n * n
end
sub pause mil t0=time$("ms") while time$("ms")-t0< mil scan wend end sub
|
|
|
Post by B+ on Apr 8, 2021 3:39:09 GMT
Here is the 2nd half of cycle for continuous play:
'zmeyrus.bas Danilin copy 2021-01-25 and b+ mod ' b+ mod of Danilin Matrix Diagonal Snake" ' 2021-04-07 b+ simplify mod for JB as Block Snake ' 2021=04-07 b+ mod to continuous play Block Snake 2 (didn't need array)
' NxN block is limited by SETUP Preferences specially rows ' @40 rows JB steals 4 rows: one for scroll bar and 3 for title bar!
' From bottom left corner you should read SNAKE,SNAKE.... diagonnally up or down to edge where it reverse back like snake, all the way to upper right corner.
n = 20 ' <<< OK so 36 too big for tsh73 b$ = "SNAKE," FOR i = 1 TO 500 s$ = s$ + b$ NEXT x = n: y = 1: s = -1 ' <<<<<<<<<<<<<< oh dang! you do x,y backwards!!! [restart] DO scan DO scan k = k + 1 locate x * 2 + 10, y + 5: print MID$(s$, k, 1) call pause 50 x = x + s: y = y + s LOOP UNTIL x > n OR y > n OR x < 1 OR y < 1 if switch then IF x < 1 AND y < 1 THEN x = 2: y = 1 ' IF x > n AND y > n THEN x = n: y = n - 2 ' IF y < 1 THEN y = 1 : x = x + 2 ' IF x < 1 THEN x = 1 ' IF x > n THEN x = n : y = y - 2 ' IF y > n THEN y = n ' else IF x < 1 AND y < 1 THEN x = 1: y = 2 IF x > n AND y > n THEN x = n - 1: y = n IF y < 1 THEN y = 1 IF x < 1 THEN x = 1 : y = y + 2 IF x > n THEN x = n IF y > n THEN x = x - 2: y = n end if s = -1 * s LOOP UNTIL k = n * n cls if switch then x = n : y = 1 : s = -1 else x = 1 : y = n end if switch = 1 - switch k = 0 goto [restart]
sub pause mil t0=time$("ms") while time$("ms")-t0< mil scan wend end sub
|
|
|
Post by B+ on Apr 8, 2021 4:29:03 GMT
And here is a more snake like creature crawling back and forth diagonally:
'zmeyrus.bas Danilin copy 2021-01-25 and b+ mod ' b+ mod of Danilin Matrix Diagonal Snake" ' 2021-04-07 b+ simplify mod for JB as Block Snake ' 2021=04-07 b+ mod to continuous play as Block Snake 2 ' 2021-04-08 b+ mod OK make one snake crawl the distance Block Snake 3
' NxN block is limited by SETUP Preferences specially rows ' @40 rows JB steals 4 rows: one for scroll bar and 3 for title bar!
' From bottom left corner you should read SNAKE,SNAKE.... diagonnally up or down to edge where it reverse back like snake, all the way to upper right corner.
n = 10 ' <<< OK so 36 too big for tsh73 b$ = "SNAKE" dim c(4), r(4) x = n: y = 1: s = -1 ' <<<<<<<<<<<<<< oh dang! you do x,y backwards!!! [restart] DO scan DO cls k = k + 1 locate x *2 + 10, y + 5: Print "X" c(0) = x : r(0) = y for i = 0 to 4 if (c(i)>0) and (r(i)>0) then locate c(i) * 2 + 10, r(i) + 5: print MID$(b$, i + 1, 1); next for i = 3 to 0 step -1 c(i + 1) = c(i) : r(i + 1) = r(i) next call pause 250 x = x + s: y = y + s LOOP UNTIL x > n OR y > n OR x < 1 OR y < 1 if switch then IF x < 1 AND y < 1 THEN x = 2: y = 1 ' IF x > n AND y > n THEN x = n: y = n - 2 ' IF y < 1 THEN y = 1 : x = x + 2 ' IF x < 1 THEN x = 1 ' IF x > n THEN x = n : y = y - 2 ' IF y > n THEN y = n ' else IF x < 1 AND y < 1 THEN x = 1: y = 2 IF x > n AND y > n THEN x = n - 1: y = n IF y < 1 THEN y = 1 IF x < 1 THEN x = 1 : y = y + 2 IF x > n THEN x = n IF y > n THEN x = x - 2: y = n end if s = -1 * s LOOP UNTIL k = n * n cls k = 0 dim c(4), r(4) if switch then x = n : y = 1 : s = -1 else x = 1 : y = n end if switch = 1 - switch goto [restart]
sub pause mil t0=time$("ms") while time$("ms")-t0< mil scan wend end sub
|
|