gaslouk
Full Member
Hi from beautiful Greece.
Posts: 130
|
Post by gaslouk on Sept 8, 2023 12:11:08 GMT -5
Hi.
This is the code of game sokoban but i can't make the level.
nomainwin
global maze global playerX, playerY global numBoxes dim boxX(6), boxY(6) dim targetX(6), targetY(6)
playerX = 1 playerY = 1
boxX(1) = 8 boxY(1) = 3 targetX(1) = 18 targetY(1) = 7
boxX(2) = 10 boxY(2) = 4 targetX(2) = 17 targetY(2) = 7
boxX(3) = 8 boxY(3) = 5 targetX(3) = 18 targetY(3) = 8
boxX(4) = 10 boxY(4) = 5 targetX(4) = 17 targetY(4) = 8
boxX(5) = 4 boxY(5) = 8 targetX(5) = 17 targetY(5) = 9
boxX(6) = 8 boxY(6) = 8 targetX(6) = 18 targetY(6) = 9
numBoxes = 6
open "Sokoban" for graphics_nsb_nf as #main #main "trapclose [quit]" #main "font ms_sans_serif 10" #main "when characterInput [movement]"
maze$ = " ##### " + _ " # # " + _ " #$ # " + _ " ### $## " + _ " # $ $ # " + _ " #### # ## # ###### " + _ " # # ## ### ..# " + _ " # $ $ ..# " + _ " ##### ## # ## ..# " + _ " # ## ######### " + _ " # # " + _ " ###### "
[gameLoop] gosub [initializeLevel] #main "flush" #main "backcolor white ; fill 0 0 640 480" #main "color black" ' Ορίζετε το χρώμα των τοίχων (μαύρο). mazeWidth = 16 ' Πλάτος του χάρτη.
for i = 1 to numBoxes if playerX = boxX(i) and playerY = boxY(i) then boxX(i) = boxX(i) + (playerX - oldX) boxY(i) = boxY(i) + (playerY - oldY) end if next i
for i = 1 to numBoxes if boxX(i) = targetX(i) and boxY(i) = targetY(i) then targetsFilled = targetsFilled + 1 ' Αύξηση της μεταβλητής targetsFilled κατά 1. end if next i
if targetsFilled = numBoxes then #main "down ; backcolor white ; home ; color black ; goto 10 10 ; title Sokoban - Κερδίσατε!" wait end if
for i = 1 to numBoxes #main "fill "; (targetX(i) - 1) * 40; " "; (targetY(i) - 1) * 40; " "; targetX(i) * 40; " "; targetY(i) * 40; " lightgreen" #main "box "; (targetX(i) - 1) * 40; " "; (targetY(i) - 1) * 40; " "; targetX(i) * 40; " "; targetY(i) * 40; " bf" next i
if oldX = -0 then oldX = 1:if oldY = -0 then oldY = 1:#main "fill "; (oldX - 1) * 40; " "; (oldY - 1) * 40; " "; oldX * 40; " "; oldY * 40; " white"
for i = 1 to numBoxes #main "fill "; (boxX(i) - 1) * 40; " "; (boxY(i) - 1) * 40; " "; boxX(i) * 40; " "; boxY(i) * 40; " blue" #main "box "; (boxX(i) - 1) * 40; " "; (boxY(i) - 1) * 40; " "; boxX(i) * 40; " "; boxY(i) * 40; " bf" next i
#main "fill "; (playerX - 1) * 40; " "; (playerY - 1) * 40; " "; playerX * 40; " "; playerY * 40; " red" #main "box "; (playerX - 1) * 40; " "; (playerY - 1) * 40; " "; playerX * 40; " "; playerY * 40; " bf"
oldX = playerX oldY = playerY
[loopHere] 'make sure #graph has input focus #main "setfocus" 'scan for events scan goto [loopHere] [movement] key$ = Inkey$ if key$ = "w" or key$ = "Up" then gosub [moveUp] if key$ = "s" or key$ = "Down" then gosub [moveDown] if key$ = "a" or key$ = "Left" then gosub [moveLeft] if key$ = "d" or key$ = "Right" then gosub [moveRight] ' Ελέγχετε αν υπάρχει διαθέσιμη είσοδος πριν προχωρήσετε στον επόμενο κύκλο. if inkey$ = "" then goto [loopHere] wait
[initializeLevel] ' Καλέστε αυτόν τον υπορουτίνα για να αρχικοποιήσετε το επίπεδο. mazeWidth = 30 ' Πλάτος του χάρτη.
for y = 1 to 12 for x = 1 to 30 if mid$(maze$, (y - 1) * mazeWidth + x, 1) = "#" then ' Αν ο χαρακτήρας στον πίνακα maze$ είναι "#", τότε σχεδιάστε τον τοίχο. #main "fill "; (x - 1) * 40; " "; (y - 1) * 40; " "; x * 40; " "; y * 40; " black" end if if mid$(maze$, (y - 1) * mazeWidth + x, 1) = " " then ' Αν ο χαρακτήρας στον πίνακα maze$ είναι κενό, τότε σχεδιάστε το δάπεδο. #main "fill "; (x - 1) * 40; " "; (y - 1) * 40; " "; x * 40; " "; y * 40; " white" end if next x next y
for i = 1 to numBoxes #main "fill "; (boxX(i) - 1) * 8; " "; (boxY(i) - 1) * 40; " "; boxX(i) * 40; " "; boxY(i) * 40; " blue" next i
for i = 1 to numBoxes #main "fill "; (targetX(i) - 1) * 40; " "; (targetY(i) - 1) * 40; " "; targetX(i) * 40; " "; targetY(i) * 40; " lightgreen" next i
#main "fill "; (playerX - 1) * 40; " "; (playerY - 1) * 40; " "; playerX * 40; " "; playerY * 40; " red"
return
[moveUp] ' Ελέγχος αν ο παίκτης μπορεί να κινηθεί προς τα πάνω (πάνω από την τρέχουσα θέση). if mid$(maze$, (playerY - 1) * mazeWidth + playerX, 1) <> "#" then playerY = playerY - 1 ' Κίνηση προς τα πάνω. end if return
[moveDown] if mid$(maze$, (playerY + 1) * mazeWidth + playerX, 1) <> "#" then playerY = playerY + 1 end if return
[moveLeft] if mid$(maze$, (playerX - 1) * mazeWidth + playerY, 1) <> "#" then playerX = playerX - 1 end if return
[moveRight] if mid$(maze$, (playerX + 1) * mazeWidth + playerY, 1) <> "#" then playerX = playerX + 1 end if return
[quit] close #main end
[numBoxes] dim boxX(6) dim boxY(6) dim targetX(6) dim targetY(6) targetsFilled = 0 wait
[reset] playerX = 1 playerY = 1
boxX(1) = 8 boxY(1) = 3 targetX(1) = 18 targetY(1) = 7
boxX(2) = 10 boxY(2) = 4 targetX(2) = 17 targetY(2) = 7
boxX(3) = 8 boxY(3) = 5 targetX(3) = 18 targetY(3) = 8
boxX(4) = 10 boxY(4) = 5 targetX(4) = 17 targetY(4) = 8
boxX(5) = 4 boxY(5) = 8 targetX(5) = 17 targetY(5) = 9
boxX(6) = 8 boxY(6) = 8 targetX(6) = 18 targetY(6) = 9
numBoxes = 6
wait
Any idea?
thanks Gaslouk.
|
|
|
Post by tsh73 on Sept 8, 2023 13:42:48 GMT -5
I really wonder that it runs at all, actually.
Do you invent language as you type? Because it is not valid LB drawing commands More precisely it is valid commands (fill, box) but used with lot's of extra parameters it likely silently ignores.
If not, what's supposed difference between
#main "fill "; (boxX(i) - 1) * 40; " "; (boxY(i) - 1) * 40; " "; boxX(i) * 40; " "; boxY(i) * 40; " blue" and
#main "box "; (boxX(i) - 1) * 40; " "; (boxY(i) - 1) * 40; " "; boxX(i) * 40; " "; boxY(i) * 40; " bf" ?
|
|
|
Post by tsh73 on Sept 8, 2023 15:07:57 GMT -5
Ok I implemented fill and box in a sense this program wants as functions (it's BASIC - you want it, you code it) and tried to substitute everywhere and fix a thing or two I noticed (player position, window size, some necessary jump to drawing code after move is made) Sorry I killed Greek letters in a process (old text editor took them as ANSI, since I have no idea, I did not paid attention till too late) Now it draws initial position and red square (player) moves with a "wasd" keys. Of cource there are bugs = it moves across walls Whoever fix this game, will be named "Player 1" 'nomainwin
global maze global playerX, playerY global numBoxes dim boxX(6), boxY(6) dim targetX(6), targetY(6)
playerX = 1 'out of field, so playerY = 1 playerX = 12 'googled first level initial position playerY = 9
boxX(1) = 8 boxY(1) = 3 targetX(1) = 18 targetY(1) = 7
boxX(2) = 10 boxY(2) = 4 targetX(2) = 17 targetY(2) = 7
boxX(3) = 8 boxY(3) = 5 targetX(3) = 18 targetY(3) = 8
boxX(4) = 10 boxY(4) = 5 targetX(4) = 17 targetY(4) = 8
boxX(5) = 4 boxY(5) = 8 targetX(5) = 17 targetY(5) = 9
boxX(6) = 8 boxY(6) = 8 targetX(6) = 18 targetY(6) = 9
numBoxes = 6
WindowWidth=640+4*40 WindowHeight=480+2*40
open "Sokoban" for graphics_nsb_nf as #main #main "trapclose [quit]" #main "font ms_sans_serif 10" #main "when characterInput [movement]"
#main "down" #main "fill yellow"
maze$ = " ##### " + _ " # # " + _ " #$ # " + _ " ### $## " + _ " # $ $ # " + _ " #### # ## # ###### " + _ " # # ## ### ..# " + _ " # $ $ ..# " + _ " ##### ## # ## ..# " + _ " # ## ######### " + _ " # # " + _ " ###### "
[gameLoop] gosub [initializeLevel] #main "flush" 'this will clear all level. it is not what we want '#main "backcolor white ; fill 0 0 640 480"
#main "color black" ' ????ete t? ???µa t?? t????? (µa???). mazeWidth = 16 ' ???t?? t?? ???t?.
[gameLoop1] for i = 1 to numBoxes if playerX = boxX(i) and playerY = boxY(i) then boxX(i) = boxX(i) + (playerX - oldX) boxY(i) = boxY(i) + (playerY - oldY) end if next i
for i = 1 to numBoxes if boxX(i) = targetX(i) and boxY(i) = targetY(i) then targetsFilled = targetsFilled + 1 ' ????s? t?? µetaЯ??t?? targetsFilled ?at? 1. end if next i
if targetsFilled = numBoxes then #main "down ; backcolor white ; home ; color black ; goto 10 10 ; \\ Sokoban - ?e?d?sate!" wait end if
for i = 1 to numBoxes #main fill$( (targetX(i) - 1) * 40, (targetY(i) - 1) * 40, targetX(i) * 40, targetY(i) * 40, " green") #main box$( (targetX(i) - 1) * 40, (targetY(i) - 1) * 40, targetX(i) * 40, targetY(i) * 40, " darkgreen") next i
if oldX = -0 then oldX = 1:if oldY = -0 then oldY = 1:#main fill$( (oldX - 1) * 40, (oldY - 1) * 40, oldX * 40, oldY * 40, " white")
for i = 1 to numBoxes '#main "fill "; (boxX(i) - 1) * 40; " "; (boxY(i) - 1) * 40; " "; boxX(i) * 40; " "; boxY(i) * 40; " blue" #main fill$((boxX(i) - 1) * 40, (boxY(i) - 1) * 40, boxX(i) * 40, boxY(i) * 40," blue") 'print fill$((boxX(i) - 1) * 40, (boxY(i) - 1) * 40, boxX(i) * 40, boxY(i) * 40," blue") '#main "box "; (boxX(i) - 1) * 40; " "; (boxY(i) - 1) * 40; " "; boxX(i) * 40; " "; boxY(i) * 40; " bf" #main box$( (boxX(i) - 1) * 40, (boxY(i) - 1) * 40, boxX(i) * 40, boxY(i) * 40, " darkblue") next i
#main fill$( (playerX - 1) * 40, (playerY - 1) * 40, playerX * 40, playerY * 40, " red") #main box$( (playerX - 1) * 40, (playerY - 1) * 40, playerX * 40, playerY * 40, " darkred")
oldX = playerX oldY = playerY
[loopHere] 'make sure #graph has input focus #main "setfocus" 'scan for events scan goto [loopHere] scan [movement] key$ = Inkey$ if key$<>"" then print key$ if key$ = "w" or key$ = "Up" then gosub [moveUp] if key$ = "s" or key$ = "Down" then gosub [moveDown] if key$ = "a" or key$ = "Left" then gosub [moveLeft] if key$ = "d" or key$ = "Right" then gosub [moveRight] ' ?????ete a? ?p???e? d?a??s?µ? e?s?d?? p??? p??????sete st?? ep?µe?? ?????. if Inkey$ = "" then goto [loopHere] goto [gameLoop1] 'we showld draw smth, are we? wait
[initializeLevel] ' ?a??ste a?t?? t?? ?p????t??a ??a ?a a?????p???sete t? ep?ped?. mazeWidth = 30 ' ???t?? t?? ???t?.
for y = 1 to 12 for x = 1 to 30 'print x, y, ">";mid$(maze$, (y - 1) * mazeWidth + x, 1);"<" if mid$(maze$, (y - 1) * mazeWidth + x, 1) = "#" then ' ?? ? ?a?a?t??a? st?? p??a?a maze$ e??a? "#", t?te s?ed??ste t?? t????. '#main "fill "; (x - 1) * 40; " "; (y - 1) * 40; " "; x * 40; " "; y * 40; " black" #main fill$( (x - 1) * 40, (y - 1) * 40, x * 40, y * 40, " black") end if
if mid$(maze$, (y - 1) * mazeWidth + x, 1) = " " then ' ?? ? ?a?a?t??a? st?? p??a?a maze$ e??a? ?e??, t?te s?ed??ste t? d?ped?. '#main "fill "; (x - 1) * 40; " "; (y - 1) * 40; " "; x * 40; " "; y * 40; " white" #main fill$( (x - 1) * 40, (y - 1) * 40, x * 40, y * 40, " white") end if next x next y
for i = 1 to numBoxes '#main "fill "; (boxX(i) - 1) * 8; " "; (boxY(i) - 1) * 40; " "; boxX(i) * 40; " "; boxY(i) * 40; " blue" 'obviously *8 is a typoo #main fill$( (boxX(i) - 1) * 40, (boxY(i) - 1) * 40, boxX(i) * 40, boxY(i) * 40, " blue") next i
for i = 1 to numBoxes '#main "fill "; (targetX(i) - 1) * 40; " "; (targetY(i) - 1) * 40; " "; targetX(i) * 40; " "; targetY(i) * 40; " lightgreen" ' " lightgreen" is not a valid color in LB #main fill$( (targetX(i) - 1) * 40, (targetY(i) - 1) * 40, targetX(i) * 40, targetY(i) * 40, " green") next i
'#main "fill "; (playerX - 1) * 40; " "; (playerY - 1) * 40; " "; playerX * 40; " "; playerY * 40; " red" #main fill$( (playerX - 1) * 40, (playerY - 1) * 40, playerX * 40, playerY * 40, " red")
return
[moveUp] ' ??????? a? ? pa??t?? µp??e? ?a ?????e? p??? ta p??? (p??? ap? t?? t?????sa ??s?). if mid$(maze$, (playerY - 1) * mazeWidth + playerX, 1) <> "#" then playerY = playerY - 1 ' ????s? p??? ta p???. end if return
[moveDown] if mid$(maze$, (playerY + 1) * mazeWidth + playerX, 1) <> "#" then playerY = playerY + 1 end if return
[moveLeft] if mid$(maze$, (playerX - 1) * mazeWidth + playerY, 1) <> "#" then playerX = playerX - 1 end if return
[moveRight] if mid$(maze$, (playerX + 1) * mazeWidth + playerY, 1) <> "#" then playerX = playerX + 1 end if return
[quit] close #main end
[numBoxes] dim boxX(6) dim boxY(6) dim targetX(6) dim targetY(6) targetsFilled = 0 wait
[reset] playerX = 1 playerY = 1
boxX(1) = 8 boxY(1) = 3 targetX(1) = 18 targetY(1) = 7
boxX(2) = 10 boxY(2) = 4 targetX(2) = 17 targetY(2) = 7
boxX(3) = 8 boxY(3) = 5 targetX(3) = 18 targetY(3) = 8
boxX(4) = 10 boxY(4) = 5 targetX(4) = 17 targetY(4) = 8
boxX(5) = 4 boxY(5) = 8 targetX(5) = 17 targetY(5) = 9
boxX(6) = 8 boxY(6) = 8 targetX(6) = 18 targetY(6) = 9
numBoxes = 6
wait
'"fill "; (targetX(i) - 1) * 40; " "; (targetY(i) - 1) * 40; " "; targetX(i) * 40; " "; targetY(i) * 40; " lightgreen" function fill$(x1,y1,x2,y2,color$) fill$="color ";color$;";backcolor ";color$;"; place "; x1; " "; y1; "; boxfilled ";x2; " "; y2 end function
function box$(x1,y1,x2,y2,color$) fill$="color white; backcolor ";color$;"; place "; x1; " "; y1; "; boxfilled ";x2; " "; y2 end function
|
|
|
Post by tsh73 on Sept 10, 2023 2:52:59 GMT -5
Sorry no takers? I take the prize then Do read the comments. 'nomainwin 'so the main takeaway from debugging this program is: ' ' USE DATA STRUCTURES THAT CORRESPOND YOUR DATA ' ' If you have rectangular field, use 2d array! ' maze$(playerX, playerY) ' is MUCH SIMPLER then ' mid$(maze$, (playerY-1) * mazeWidth + playerX ' especially then you start changing coordinates ' (and last most hard to find bug was that mazeWidth got changed mid-program).
' Of cource program should be worked upon ' It should not move crate then there is no place behind it ' (as of now, it allows moving into wall or other crate). ' Also, as of now program wants each crate to be placed on exact target - I think it should allow any target.
'Also, to simplify code, all "* 40" stuff should be moved 'to single place - there drawing takes place ' function fill$( ' function box$( 'but these functions is product of conversion to LB 'from more ?potent? version of BASIC ' But really, they should be converted just to ' function fill$(x,y, color$) ' or even ' sub fill x,y, color$ ' where x,y is logical coords (in a maze) ' and endpoint and size are calculated/applied inside.
global maze global playerX, playerY global numBoxes dim boxX(6), boxY(6) dim targetX(6), targetY(6)
playerX = 1 'out of field, so playerY = 1 playerX = 12 'googled first level initial position playerY = 9
boxX(1) = 8 boxY(1) = 3 targetX(1) = 18 targetY(1) = 7
boxX(2) = 10 boxY(2) = 4 targetX(2) = 17 targetY(2) = 7
boxX(3) = 8 boxY(3) = 5 targetX(3) = 18 targetY(3) = 8
boxX(4) = 10 boxY(4) = 5 targetX(4) = 17 targetY(4) = 8
boxX(5) = 4 boxY(5) = 8 targetX(5) = 17 targetY(5) = 9
boxX(6) = 8 boxY(6) = 8 targetX(6) = 18 targetY(6) = 9
numBoxes = 6
WindowWidth=640+4*40 WindowHeight=480+2*40
open "Sokoban" for graphics_nsb_nf as #main #main "trapclose [quit]" #main "font ms_sans_serif 10" #main "when characterInput [movement]" '#main "size 5"
#main "down" '#main "fill yellow"
maze$ = " ##### " + _ " # # " + _ " #$ # " + _ " ### $## " + _ " # $ $ # " + _ " #### # ## # ###### " + _ " # # ## ### ..# " + _ " # $ $ ..# " + _ " ##### ## # ## ..# " + _ " # ## ######### " + _ " # # " + _ " ###### " 'LB way of using cursor keys Up$ =chr$(0)+chr$(_VK_UP) Down$ =chr$(0)+chr$(_VK_DOWN) Left$ =chr$(0)+chr$(_VK_LEFT) Right$ =chr$(0)+chr$(_VK_RIGHT)
[gameLoop] gosub [initializeLevel] #main "flush" 'next line will clear all level. it is not what we want '#main "backcolor white ; fill 0 0 640 480"
#main "color black" ' ????ete t? ???µa t?? t????? (µa???). '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 'WTF!!! mazeWidth should be 30 'THIS WAS LAST ERROR ' mazeWidth = 16 ' ???t?? t?? ???t?. '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[gameLoop1] for i = 1 to numBoxes if playerX = boxX(i) and playerY = boxY(i) then boxX(i) = boxX(i) + (playerX - oldX) boxY(i) = boxY(i) + (playerY - oldY) end if next i
for i = 1 to numBoxes if boxX(i) = targetX(i) and boxY(i) = targetY(i) then targetsFilled = targetsFilled + 1 ' ????s? t?? µetaЯ??t?? targetsFilled ?at? 1. end if next i
if targetsFilled = numBoxes then #main "down ; backcolor white ; home ; color black ; goto 10 10" #main "\\ Sokoban - you win!" wait end if
for i = 1 to numBoxes #main fill$( (targetX(i) - 1) * 40, (targetY(i) - 1) * 40, targetX(i) * 40, targetY(i) * 40, " green") #main box$( (targetX(i) - 1) * 40, (targetY(i) - 1) * 40, targetX(i) * 40, targetY(i) * 40, " darkgreen") next i
if oldX = -0 then oldX = 1:if oldY = -0 then oldY = 1 'somehow clearing old user pos does not work after IF #main fill$( (oldX - 1) * 40, (oldY - 1) * 40, oldX * 40, oldY * 40, " white")
for i = 1 to numBoxes #main fill$((boxX(i) - 1) * 40, (boxY(i) - 1) * 40, boxX(i) * 40, boxY(i) * 40," blue") #main box$( (boxX(i) - 1) * 40, (boxY(i) - 1) * 40, boxX(i) * 40, boxY(i) * 40, " darkblue") next i
#main fill$( (playerX - 1) * 40, (playerY - 1) * 40, playerX * 40, playerY * 40, " red") #main box$( (playerX - 1) * 40, (playerY - 1) * 40, playerX * 40, playerY * 40, " darkred") oldX = playerX oldY = playerY
[loopHere] 'make sure #graph has input focus #main "setfocus" 'scan for events scan goto [loopHere] scan [movement] key$ = Inkey$ 'if key$<>"" then print key$ if key$ = "w" or key$ = Up$ then gosub [moveUp] if key$ = "s" or key$ = Down$ then gosub [moveDown] if key$ = "a" or key$ = Left$ then gosub [moveLeft] if key$ = "d" or key$ = Right$ then gosub [moveRight] ' ?????ete a? ?p???e? d?a??s?µ? e?s?d?? p??? p??????sete st?? ep?µe?? ?????. if Inkey$ = "" then goto [loopHere] goto [gameLoop1] 'we showld draw smth, are we? wait
[initializeLevel] ' ?a??ste a?t?? t?? ?p????t??a ??a ?a a?????p???sete t? ep?ped?. mazeWidth = 30 ' ???t?? t?? ???t?.
for y = 1 to 12 for x = 1 to 30 if mid$(maze$, (y - 1) * mazeWidth + x, 1) = "#" then ' ?? ? ?a?a?t??a? st?? p??a?a maze$ e??a? "#", t?te s?ed??ste t?? t????. #main fill$( (x - 1) * 40, (y - 1) * 40, x * 40, y * 40, " black") end if
if mid$(maze$, (y - 1) * mazeWidth + x, 1) = " " then ' ?? ? ?a?a?t??a? st?? p??a?a maze$ e??a? ?e??, t?te s?ed??ste t? d?ped?. #main fill$( (x - 1) * 40, (y - 1) * 40, x * 40, y * 40, " white") end if next x next y
for i = 1 to numBoxes '#main "fill "; (boxX(i) - 1) * 8; " "; (boxY(i) - 1) * 40; " "; boxX(i) * 40; " "; boxY(i) * 40; " blue" 'obviously *8 was a typoo #main fill$( (boxX(i) - 1) * 40, (boxY(i) - 1) * 40, boxX(i) * 40, boxY(i) * 40, " blue") next i
for i = 1 to numBoxes '#main "fill "; (targetX(i) - 1) * 40; " "; (targetY(i) - 1) * 40; " "; targetX(i) * 40; " "; targetY(i) * 40; " lightgreen" ' " lightgreen" is not a valid color in LB #main fill$( (targetX(i) - 1) * 40, (targetY(i) - 1) * 40, targetX(i) * 40, targetY(i) * 40, " green") next i
#main fill$( (playerX - 1) * 40, (playerY - 1) * 40, playerX * 40, playerY * 40, " red")
return
[moveUp] 'then filling a mase, we checked 'if mid$(maze$, (y - 1) * mazeWidth + x, 1) = "#" '=> 1)in this code, is some places playerY and playerX were messed up '=> 2) this check needs extra "-1" for playerY ' ??????? a? ? pa??t?? µp??e? ?a ?????e? p??? ta p??? (p??? ap? t?? t?????sa ??s?). if mid$(maze$, (playerY - 1-1) * mazeWidth + playerX, 1) <> "#" then playerY = playerY - 1 ' ????s? p??? ta p???. end if return
[moveDown] 'print playerY, playerX, ">";mid$(maze$, (playerY + 1-1) * mazeWidth + playerX, 1);"<" if mid$(maze$, (playerY + 1-1) * mazeWidth + playerX, 1) <> "#" then playerY = playerY + 1 end if return
[moveLeft] 'playerY and playerX are messed up ! 'if mid$(maze$, (playerX - 1) * mazeWidth + playerY, 1) <> "#" then if mid$(maze$, (playerY - 1) * mazeWidth + playerX-1, 1) <> "#" then playerX = playerX - 1 end if return
[moveRight] 'playerY and playerX are messed up ! 'if mid$(maze$, (playerX + 1) * mazeWidth + playerY, 1) <> "#" then if mid$(maze$, (playerY - 1) * mazeWidth + playerX+1, 1) <> "#" then playerX = playerX + 1 end if return
[quit] close #main end
[numBoxes] dim boxX(6) dim boxY(6) dim targetX(6) dim targetY(6) targetsFilled = 0 wait
[reset] playerX = 1 playerY = 1
boxX(1) = 8 boxY(1) = 3 targetX(1) = 18 targetY(1) = 7
boxX(2) = 10 boxY(2) = 4 targetX(2) = 17 targetY(2) = 7
boxX(3) = 8 boxY(3) = 5 targetX(3) = 18 targetY(3) = 8
boxX(4) = 10 boxY(4) = 5 targetX(4) = 17 targetY(4) = 8
boxX(5) = 4 boxY(5) = 8 targetX(5) = 17 targetY(5) = 9
boxX(6) = 8 boxY(6) = 8 targetX(6) = 18 targetY(6) = 9
numBoxes = 6
wait
'this command (as supposed to work) is not awailable in LB 'LB thing is "fill color" with named color 'or "fill nR nG nB" with 3 numbers 'So we create own function for that, to behave as ' "fill "; (targetX(i) - 1) * 40; " "; (targetY(i) - 1) * 40; " "; targetX(i) * 40; " "; targetY(i) * 40; " lightgreen" function fill$(x1,y1,x2,y2,color$) fill$="color ";color$;";backcolor ";color$;"; place "; x1; " "; y1; "; boxfilled ";x2; " "; y2 end function
'same for box ' #main "box "; (playerX - 1) * 40; " "; (playerY - 1) * 40; " "; playerX * 40; " "; playerY * 40; " bf" 'since I have no idea what "bf" is, let it be non-filled square function box$(x1,y1,x2,y2,color$) box$="color ";color$;"; place "; x1; " "; y1; "; box ";x2; " "; y2 end function
|
|
gaslouk
Full Member
Hi from beautiful Greece.
Posts: 130
|
Post by gaslouk on Sept 10, 2023 10:20:35 GMT -5
I am here but i am working now. Very good job Anatoly.
Gaslouk.
|
|