|
Post by tsh73 on Apr 7, 2021 17:52:35 GMT
Anybody remembers this?
n = 20 dim x(n), y(n)
for i = 1 to 14 x(i) = int(rnd(0)*55)+1 y(i) = int(rnd(0)*20)+1 for j = 1 to i locate x(j), y(j) if i mod 2 then print "BADGER"; else print "badger"; next call pause 400 next
locate 1, 1 for i = 0 to 7 step .2 print tab(sin(i)*30 + 30);"Snaaaake!!!" call pause 50 next i
sub pause mil t0=time$("ms") while time$("ms")-t0< mil scan wend end sub
|
|
|
Post by tsh73 on Apr 7, 2021 17:54:23 GMT
|
|
|
Post by B+ on Apr 8, 2021 19:49:41 GMT
OK mushrooms added ;-))
' snakes, badgers AND mushrooms.txt b+ 2021-04-08 tsh73 challenge ;-)) ' ref: https://justbasiccom.proboards.com/thread/668/snake-badger
' !!! Setup > Preferences > Main Window: 80 cols min 40 rows min
n = 50 ' 14 + 36 badgers + snakes dim x(n), y(n), s$(n), rows(36), vs$(80, 36) ' x(n), y(n) is head of snake or badger ' s$(n) says snake or badger ' rows(36) for shuffling and dealing badgers their own random row ' vs$() Virtual Screen to track where everything is getting printed
' make sure we show 14 badgers neither overlapping each other or snakes! for i = 1 to 36 rows(i) = i next for i = 36 to 2 step -1 ' shuffle rows for drawing badger rows later r = int(rnd(0) * i) + 1 t = rows(i) rows(i) = rows(r) rows(r) = t next
' do snakes first because we can work random badgers around Snake river for i = 0 to 7.2 step .2 ' 36 steps one for each row we can show cnt = cnt + 1 y(cnt) = cnt x(cnt) = int(sin(i) * 30 + 30) s$(cnt) = "Snake!" locate x(cnt), y(cnt) : print s$(cnt); locate 80, cnt: Print "X"; for c = x(cnt) to x(cnt) + 5 vs$(c, y(cnt)) = "X" next next i
' now do 14 badgers around Snake River for i = 1 to 14 ' pick a line not used yet for a badger row = rows(i) y(i + cnt) = row s$(i + cnt) = "badger" [Again] col = int(rnd(0) * 74) + 1 'find spot where badge wont overlap river if (col + 7) <= x(row) or col >= x(row) + 7 then goto [continue] else goto [Again] end if [continue] x(i + cnt) = col for j = 1 to i locate x(cnt + j), y(cnt + j) if i mod 2 = 0 then print upper$(s$(cnt + j)); else print s$(cnt + j); for c = x(cnt + j) to x(cnt + j) + 5 vs$(c, y(cnt + j)) = "X" next next call pause 400 next call pause 2000 for y = 1 to 36 for x = 1 to 71 step 10 ok = 1 for i = x to x + 9 if vs$(i, y) = "X" then ok = 0 next if ok then locate x, y: print " mushroom"; : call pause 50 next next
sub pause mil t0=time$("ms") while time$("ms")-t0< mil scan wend end sub
I'd add onions and pepperoni but I didn't want to make everyone hungry.
|
|
|
Post by honky on Apr 9, 2021 11:38:31 GMT
B+, You have not forgotten to size arrays? dim rows(500): dim vs$(500,500): dim y(500): dim x(500): dim s$(500)
|
|
|
Post by B+ on Apr 9, 2021 17:36:13 GMT
B+, You have not forgotten to size arrays? dim rows(500): dim vs$(500,500): dim y(500): dim x(500): dim s$(500) Those dimensions look like they are for a graphics screen for pixels, this silly little project is just doing rows and columns for characters in the main Windows = 0 graphics, ie drawing with text, you can't even do colors! So I dimension according characters that: n = 50 ' 14 + 36 badgers + snakes dim x(n), y(n), s$(n), rows(36), vs$(80, 36) ' x(n), y(n) is head of snake or badger ' s$(n) says snake or badger ' rows(36) for shuffling and dealing badgers their own random row ' vs$() Virtual Screen to track where everything is getting printed Normally I would use cols and rows instead of x and y but tsh73 had started with x, y so I carried on with his, so it's his fault LOL!
|
|