|
Post by ai7921 on Apr 29, 2019 12:53:54 GMT -5
This game was originally programmed by Ben Jimenez, also the arrow keys is not working so I used w,a,s,z. I made minor changes to make it work.
' NO LEFT PUZZLE
'basic 2d game level wall/border example 'using native graphic commands 'programmed by Ben Jimenez 'use your arrow keys to move the player 'July 20,2011 'upadted Oct 15,2011
nomainwin
WindowWidth = 700 WindowHeight = 900
menu #main, "&File" , "Reset", [RESET], "E&xit", [quit] open "Border/Wall Example" for graphics as #main print #main, "trapclose [quit]" print #main, "fill white; flush" print #main, "font ms_sans_serif 0 16" #main "up;goto 20 30;size 3;down"
dim pxy$(88,88)
up$= chr$(119) ' w lft$=chr$(97) ' a rht$=chr$(115) ' s dwn$=chr$(122) ' z
[RESET] #main "cls" restore
'start postion of first wall piece x=10 y=40
Izquierda = 1 Arriba = 1 Derecha = 1 Abajo = 1
'draw border walls for r=1 to 17 'first row for c=1 to 17 'current row column loop read d$ pxy$(r,c)=d$
if d$="e" then #main "up;goto ";x+40;" ";y+40;";down;backcolor red;color red" #main "boxfilled ";x;" ";y end if
if d$="B" then 'if border piece then draw it #main "up;goto ";x+40;" ";y+40;";down;backcolor blue;color blue" #main "boxfilled ";x;" ";y end if
if d$="s" then 'save player start position px=x 'set current pen x position to player start x py=y ' set current pen y position to player start y ar=r 'remember current row location ac=c 'remember current column locaton end if
x=x+40 'increase column x location by 20 next c x=10 y=y+40 'increase row y location by 20 next r
#main "flush" 'save drawn board as segment
'draw player #main "up;goto ";px+20;" ";py+20;";down;backcolor brown;color brown" #main "circlefilled 12"
#main "when characterInput [checkkey]"
[main.inputLoop] 'wait here for input event ' #main "setfocus" wait
[quit]
close #main : end
[checkkey]
if Inkey$ = chr$(27) then goto [RESET] key$ = Inkey$ if len(key$) > 1 then goto [checkkey] select case key$ 'if wall/boarder found for next movement then no movement will be done.
case dwn$ 'down ******************* ABAJO ********************************
if pxy$(ar+1,ac)<>"B" then 'if next location is not a wall/border then move player if Abajo = 0 then goto [main.inputLoop] Izquierda = 1 Arriba = 0 Derecha = 0 Abajo = 1 #main "up;goto ";px+20;" ";py+20;";down;backcolor white;color white" #main "circlefilled 12"
py=py+40 #main "up;goto ";px+20;" ";py+20;";down;backcolor brown;color brown" #main "circlefilled 12"
ar=ar+1
end if
case rht$ ' ******************* DERECHA ********************************
Up = 0 Down = 1
if pxy$(ar,ac+1)<>"B" then 'if next location is not a wall/border then move player if Derecha = 0 then goto [main.inputLoop] Izquierda = 0 Arriba = 0 Derecha = 1 Abajo = 1 #main "up;goto ";px+20;" ";py+20;";down;backcolor white;color white" #main "circlefilled 12" px=px+40 #main "up;goto ";px+20;" ";py+20;";down;backcolor brown;color brown" #main "circlefilled 12" ac=ac+1
end if
case lft$ ' ******************* IZQUIERDA ********************************
if pxy$(ar,ac-1)<>"B" then 'if next location is not a wall/border then move player if Izquierda = 0 then goto [main.inputLoop] Izquierda = 1 Arriba = 1 Derecha = 0 Abajo = 0 #main "up;goto ";px+20;" ";py+20;";down;backcolor white;color white" #main "circlefilled 12" px=px-40 #main "up;goto ";px+20;" ";py+20;";down;backcolor brown;color brown" #main "circlefilled 12" ac=ac-1
end if
case up$ ' ******************* ARRIBA ********************************
if pxy$(ar-1,ac)<>"B" then 'if next location is not a wall/border then move player if Arriba = 0 then goto [main.inputLoop] Izquierda = 0 Arriba = 1 Derecha = 1 Abajo = 0 #main "up;goto ";px+20;" ";py+20;";down;backcolor white;color white" #main "circlefilled 12" py=py-40 #main "up;goto ";px+20;" ";py+20;";down;backcolor brown;color brown" #main "circlefilled 12" ar=ar-1
end if
end select #main "flush" #main "segment n" #main "delsegment ";n-2 if pxy$(ar,ac)="e" then notice "You escaped the maze!" end if goto [main.inputLoop]
'maze data data "B","B","B","B","B","B","B","B","B","B","B","B","B","B","B","B","B" data "B","x","x","x","x","x","x","x","x","x","x","x","B","x","x","x","B" data "B","x","B","x","B","B","B","x","B","B","B","x","B","x","B","x","B" data "B","x","x","x","B","x","x","x","B","x","x","x","x","x","x","x","B" data "B","B","B","x","B","x","B","x","B","x","B","x","B","x","B","x","B" data "B","x","x","x","x","x","x","x","x","x","B","x","x","x","x","x","B" data "B","x","B","B","B","x","B","B","B","x","B","x","B","x","B","B","B" data "B","x","x","x","x","x","x","x","x","x","B","x","x","x","x","x","B" data "B","x","B","x","B","B","B","x","B","x","B","x","B","x","B","x","B" data "B","x","B","x","x","x","x","x","x","x","x","x","B","x","x","x","B" data "B","x","B","x","B","x","B","x","B","B","B","x","B","x","B","x","B" data "B","x","B","x","x","x","x","x","x","x","B","x","x","x","x","x","B" data "B","x","B","x","B","x","B","x","B","x","B","x","B","B","B","x","B" data "B","x","x","x","x","x","B","x","x","x","x","x","x","x","B","e","x" data "B","x","B","x","B","x","B","B","B","x","B","B","B","x","B","B","B" data "B","x","x","x","B","x","x","x","x","x","x","x","x","x","x","s","B" data "B","B","B","B","B","B","B","B","B","B","B","B","B","B","B","B","B"
|
|