Post by bluatigro on Jan 28, 2019 12:04:32 GMT
try to ecape the pit
by stering the stones
by stering the stones
'' bluatigro 28 jan 2019
'' the pit
global maxx , maxy
maxx = 20
maxy = 20
dim p( maxx , maxy )
global hx , hy , stone , stonest , faling , winx , winy , stonex , stoney , sec
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
winx = WindowWidth
winy = WindowHeight
nomainwin
stone = 1
faling = not( 0 )
open "The pit" for graphics as #m
#m "trapclose [quit]"
#m "fill black"
#m "getbmp bmp 0 0 1 1"
#m "background bmp"
notice chr$( 13 ) _
+ "Welkome in the pit :" + chr$( 13 ) _
+ "a game by BluaTigro ." + chr$( 13 ) _
+ chr$( 13 ) _
+ "You are in a pit" + chr$( 13 ) _
+ "stones are faling on you" + chr$( 13 ) _
+ "use the cursor keys to" + chr$( 13 ) _
+ "avoid the stones and" + chr$( 13 ) _
+ "steer the stones so" + chr$( 13 ) _
+ "that you escape the pit" + chr$( 13 ) _
+ "in a least amount of time ." + chr$( 13 ) _
+ chr$( 13 ) _
+ " HAVE FUN !!"
#m "getbmp empty 0 0 20 40"
#m "goto 0 0"
#m "backcolor black"
#m "down"
#m "boxfilled 20 20"
#m "up"
#m "goto 0 20"
#m "backcolor lightgray"
#m "down"
#m "boxfilled 20 40"
#m "up"
#m "getbmp stone 0 0 20 40"
for x = 0 to maxx
for y = 0 to maxy
#m "addsprite " ; p$( x , y ) ; " stone empty"
#m "spritexy " ; p$( x , y ) _
; " " ; winx / 2 - maxx / 2 * 25 + x * 25 _
; " " ; winy / 2 - maxy / 2 * 25 + y * 25
next y
next x
#m "backcolor yellow"
#m "goto 0 20"
#m "down"
#m "boxfilled 20 40"
#m "up"
#m "getbmp human 0 0 20 40"
#m "addsprite human human"
#m "when characterInput [key]"
#m "setfocus"
call restart
call drawpit
timer 250 , [tmr]
wait
[key]
lastkey$ = right$( Inkey$ , 1 )
wait
[tmr]
sec = sec + .25
if stonest = faling then
p( stonex , stoney ) = empty
if p( stonex , stoney + 1 ) = empty then
stoney = stoney + 1
else
stonest = not( faling )
end if
p( stonex , stoney ) = stone
else
stonex = hx
stoney = 0
stonest = faling
end if
if stonex = hx and stoney + 1 = hy then
timer 0
notice "YOU DIED !!" + chr$( 13 ) _
+ "time : " ; sec ; " sec."
close #m
end
end if
if hx < 3 or hx > maxx - 3 then
timer 0
notice "YOU ESCAPED !!" + chr$( 13 ) _
+ "time : " ; sec ; " sec."
close #m
end
end if
select case lastkey$
case chr$( _VK_LEFT )
if p( hx - 1 , hy ) = empty then
hx = hx - 1
else
if p( hx - 1 , hy - 1 ) = empty then
hx = hx - 1
hy = hy - 1
end if
end if
case chr$( _VK_RIGHT )
if p( hx + 1 , hy ) = empty then
hx = hx + 1
else
if p( hx + 1 , hy - 1 ) = empty then
hx = hx + 1
hy = hy - 1
end if
end if
case else
end select
while p( hx , hy + 1 ) = empty
hy = hy + 1
wend
lastkey$ = ""
call drawpit
wait
function p$( x , y )
p$ = "p" ; x ; "_" ; y
end function
sub restart
for x = 0 to maxx
for y = 0 to maxy
p( x , y ) = 0
if x < 3 and y > 10 then
p( x , y ) = stone
end if
if x > maxx - 3 and y > 10 then
p( x , y ) = stone
end if
if y > maxy - 3 then
p( x , y ) = stone
end if
next y
next x
hx = int( maxx / 2 )
hy = maxy - 3
sec = 0
end sub
sub drawpit
for x = 0 to maxx
for y = 0 to maxy
if p( x , y ) = stone then
#m "spriteimage " ; p$( x , y ) ; " stone"
else
#m "spriteimage " ; p$( x , y ) ; " empty"
end if
next y
next x
#m "spritexy human " _
; winx / 2 - maxx / 2 * 25 + hx * 25 ; " " _
; winy / 2 - maxy / 2 * 25 + hy * 25
#m "drawsprites"
end sub
[quit]
close #m
end