peter
20-11-2013, 14:37
Hi,
This is here a ThinBasic_abc.dll heavy test.
Is a small game with 18 maps and some stupid enemies.
The Zip file includes everything what we need. (source code is also within)
How do I play ?
Use your arrow keys to move your Picker. (Little boy)
Get all the pills and stars. After that, go on the blinking tile. (Exit)
Here you will read, Press N for the the next level. Do it!
As I said, there are 18 Maps. Each of this Maps is very easy to play. Play it!
Every played Map is automatically stored. (lastlevel.bin)
Thus, you can take a rest, untill to the next day. (When you want this day.)
Uses "ui"
#INCLUDE "abc.inc"
#INCLUDE "bass.inc"
#DEFAULT BOUNDCHECK Off
DWord hdc, hwnd
hwnd = Canvas_Window("ThinBasic",xMiddle(768),yMiddle(708),768,708)
Canvas_Attach(hwnd,0,%TRUE)
hdc = Canvas_GetDC()
SetHandleDC hdc
InitBass
Long xBoy,yBoy,zBoy,rBoy,xExit,yExit,zExit,aExit,xShrink,yShrink,zShrink,play
Long ras,pills,yPill,xPill,zPill,x,y,z,p,rx,zAtom,yStar,xStar,zStar,eras
Long xExp,yExp,zExp,iExp,m,iStop,press,flash,zFlash,ms,h1,h2,h3
Long s1,s2,s3,s4,s5,s6,s7,s8,s9,sa,sb,sc,sd,se,sf,w1,w2,w3,w4,w5
Single vFlash,vExp,vStar,vAtom,vShrink,vBoy,vPill
Dim map1(1200) As Byte
Dim map2(1200) As Byte
Dim map3(1200) As Byte
Dim xEny(4) As Long
Dim yEny(4) As Long
Dim rEny(4) As Long
Dim zEny(4) As Long
Dim vEny(4) As Single
Dim iName As String*16
s1= LoadBmp "game/gfx/char.bmp",60
s2= LoadBmp "game/gfx/atom.bmp",16
s3= LoadBmp "game/gfx/boyd.bmp",16
s4= LoadBmp "game/gfx/boyu.bmp",16
s5= LoadBmp "game/gfx/boyr.bmp",16
s6= LoadBmp "game/gfx/boyl.bmp",16
s7= LoadBmp "game/gfx/exitani.bmp",16
s8= LoadBmp "game/gfx/pillani.bmp",8
s9= LoadBmp "game/gfx/bummani.bmp",16
sa= LoadBmp "game/gfx/starani.bmp",16
sb= LoadBmp "game/gfx/shrani.bmp",16
sc= LoadBmp "game/gfx/fire.bmp",16
sd= LoadBmp "game/gfx/boyf.bmp",8
se= LoadBmp "game/gfx/layout.bmp",1
sf= LoadBmp "game/gfx/font32.bmp",91
w1= LoadSound "game/wavs/success.wav"
w2= LoadSound "game/wavs/caim.wav"
w3= LoadSound "game/wavs/drown.wav"
w4= LoadSound "game/wavs/hit.wav"
w5= LoadSound "game/wavs/grab.wav"
If FileExists "game/lastlevel.bin" Then
h1= OpenFile "game/lastlevel.bin"
ReadByte h1,m,4
CloseFile h1
Else
m=1
End If
h1= OpenFile "game/maps/map" + m + "-1.txt"
h2= OpenFile "game/maps/map" + m + "-2.txt"
h3= OpenFile "game/maps/map" + m + "-3.txt"
ReadByte h1,map1,1200
ReadByte h2,map2,1200
ReadByte h3,map3,1200
CloseFile h1
CloseFile h2
CloseFile h3
Sub BoyBumm()
If yExp >0 Then
Sprite s9,xExp,yExp,zExp
If play=0 Then
PlaySound w4
play=1
End If
vExp +=.5
If vExp >=1 Then
vExp=0
zExp +=1
If zExp =16 Then
yExp =0
iExp =1
End If
End If
End If
End Sub
Sub InitEny()
For y=0 To 29
For x=0 To 39
z=(y*40+x)+1
If map3(z)=62 Then
xEny(p)=x*64
yEny(p)=y*64
rEny(p)=-1
p +=1
ElseIf map3(z)=63 Then
xEny(p)=x*64
yEny(p)=y*64
rEny(p)=-1
p +=1
ElseIf map3(z)=64 Then
xEny(p)=x*64
yEny(p)=y*64
rEny(p)=-1
p +=1
ElseIf map3(z)=65 Then
xEny(p)=x*64
yEny(p)=y*64
rEny(p)=-1
p +=1
End If
If p=5 Then Exit Sub
Next
Next
End Sub
Sub ScanEnemy()
If eras >0 Then Exit Sub
For x=1 To 4
z=((yEny(x)*40+xEny(x))/64)+1
If map3(z)=62 And map3(z+1)=111 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z)=63 And map3(z-1)=111 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf map3(z)=64 And map3(z-40)=111 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf map3(z)=65 And map3(z+40)=111 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf (map3(z)=62 And map3(z+40)=111) Or (map3(z)=63 And map3(z+40)=111) Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf (map3(z)=62 And map3(z-40)=111) Or (map3(z)=63 And map3(z-40)=111) Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf (map3(z)=64 And map3(z-1)=111) Or (map3(z)=65 And map3(z-1)=111) Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf (map3(z)=64 And map3(z+1)=111) Or (map3(z)=65 And map3(z+1)=111) Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z)=62 Then
If map1(z)=105 And map3(z+1)=32 And map3(z+40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
ElseIf rx=2 Then
rEny(x)=4
map3(z)=32
map3(z+40)=65
End If
ElseIf map1(z)=105 And map3(z+1)=32 And map3(z-40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
ElseIf rx=2 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
End If
ElseIf map1(z)=105 And map3(z+40)=32 And map3(z-40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=4
map3(z)=32
map3(z+40)=64
ElseIf rx=2 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
End If
ElseIf map3(z+40)=32 And map3(z+1) >32 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf map3(z-40)=32 And map3(z+1) >32 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf map3(z+1) >32 And map3(z+40) >32 And map3(z-40) >32 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf map3(z+1) >32 And map3(z+40) >32 And map3(z-40) >32 Then
rEny(x)=-1
ElseIf map3(z)=62 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
End If
ElseIf map3(z)=63 Then
If map1(z)=105 And map3(z-1)=32 And map3(z-40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
ElseIf rx=2 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
End If
ElseIf map1(z)=105 And map3(z+40)=32 And map3(z-40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=4
map3(z)=32
map3(z+40)=64
ElseIf rx=2 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
End If
ElseIf map1(z)=105 And map3(z-1)=32 And map3(z+40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
ElseIf rx=2 Then
rEny(x)=4
map3(z)=32
map3(z+40)=65
End If
ElseIf map3(z+40)=32 And map3(z-1) >32 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf map3(z-40)=32 And map3(z-1) >32 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf map3(z-1) >32 And map3(z+40) >32 And map3(z-40) >32 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z-1) >32 And map3(z+40) >32 And map3(z-40) >32 Then
rEny(x)=-1
ElseIf map3(z)=63 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
End If
ElseIf map3(z)=64 Then
If map1(z)=105 And map3(z-40)=32 And map3(z+1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
ElseIf rx=2 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
End If
ElseIf map1(z)=105 And map3(z-40)=32 And map3(z-1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
ElseIf rx=2 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
End If
ElseIf map1(z)=105 And map3(z-1)=32 And map3(z+1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
ElseIf rx=2 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
End If
ElseIf map3(z-40) >32 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf map3(z-40) >32 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z-40) >32 And map3(z+1) >32 And map3(z-1) >32 And map3(z+40)=32 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf map3(z-40) >32 And map3(z+1) >32 And map3(z-1) >32 Then
rEny(x)=-1
ElseIf map3(z)=64 And map3(z-40)=32 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
Else
rEny(x)=-1
End If
ElseIf map3(z)=65 Then
If map1(z)=105 And map3(z+40)=32 And map3(z+1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=4
map3(z)=32
map3(z+40)=65
ElseIf rx=2 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
End If
ElseIf map1(z)=105 And map3(z+40)=32 And map3(z-1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=4
map3(z)=32
map3(z+40)=65
ElseIf rx=2 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
End If
ElseIf map1(z)=105 And map3(z+1)=32 And map3(z-1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
ElseIf rx=2 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
End If
ElseIf map3(z+40) >32 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf map3(z+40) >32 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z+40) >32 And map3(z+1) >32 And map3(z-1) >32 And map3(z-40)=32 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf map3(z+40) >32 And map3(z+1) >32 And map3(z-1) >32 Then
rEny(x)=-1
ElseIf map3(z+40)=32 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
End If
End If
Next
End Sub
Sub SetEny(e As Long)
vEny(e) +=.5
If vEny(e) >=1 Then
vEny(e)=0
zEny(e) +=1
If zEny(e)=16 Then zEny(e)=0
End If
End Sub
Sub ShowEnemy()
For z=1 To 4
If rEny(z)= -1 Then
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
ElseIf rEny(z)=1 Then
xEny(z) +=2
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
ElseIf rEny(z)=2 Then
xEny(z) -=2
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
ElseIf rEny(z)=3 Then
yEny(z) -=2
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
ElseIf rEny(z)=4 Then
yEny(z) +=2
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
End If
Next
eras +=2
If eras=64 Then eras=0
End Sub
Sub ShowMaps()
For y=0 To 29
For x=0 To 39
z=(y*40+x)+1
If map1(z)=34 Then Sprite s1,x*64,y*64,1
If map1(z)=107 Then Sprite s1,x*64,y*64,2
If map1(z)=105 Then Sprite s1,x*64,y*64,2
If map2(z)=91 Then Sprite s2,x*64,y*64,zAtom
If map2(z)=121 Then Sprite s7,x*64,y*64,0
If map2(z)=81 Then Sprite sa,x*64,y*64,zAtom
Next
Next
vAtom +=.5
If vAtom >=1 Then
vAtom=0
zAtom +=1
If zAtom=16 Then zAtom=0
End If
End Sub
Sub InitBoy()
For y=0 To 29
For x=0 To 39
z=(y*40+x)+1
If map3(z)=111 Then
xBoy = x*64
yBoy = y*64
End If
If map2(z)=91 Or map2(z)=81 Then
pills +=1
End If
If map2(z)=121 Then
xExit = x*64
yExit = y*64
End If
Next
Next
End Sub
Sub CheckBoy()
If ras >0 Or rBoy >=5 Then Exit Sub
z=((yBoy*40+xBoy)/64)+1
If map3(z) >=62 And map3(z) <=65 Then
rBoy=6
xExp=xBoy
yExp=yBoy
ElseIf map2(z)=121 And aExit=1 Then
xShrink=xBoy
yShrink=yBoy
map3(z)=32
rBoy=5
ElseIf map2(z)=91 Then
xPill=xBoy
yPill=yBoy
Pills -= 1
map2(z)=32
map3(z)=32
rBoy=0
PlaySound w2
ElseIf map2(z)=81 Then
xStar=xBoy
yStar=yBoy
Pills -= 1
map2(z)=32
map3(z)=32
rBoy=0
PlaySound w5
ElseIf KeyDown(39) <0 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=111
rBoy=1
ElseIf KeyDown(37) <0 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=111
rBoy=2
ElseIf KeyDown(38) <0 And map3(z-40)=32 Then
map3(z)=32
map3(z-40)=111
rBoy=3
ElseIf KeyDown(40) <0 And map3(z+40)=32 Then
map3(z)=32
map3(z+40)=111
rBoy=4
Else
rBoy=0
End If
End Sub
Sub DrawBoy()
If rBoy=0 Then
Sprite s3,xBoy,yBoy,0
ElseIf rBoy=1 Then
xBoy +=2
Sprite s5,xBoy,yBoy,zBoy
vBoy +=.5
If vBoy >=1 Then
vBoy=0
zBoy +=1
If zBoy=16 Then zBoy=0
End If
ras +=2
If ras=64 Then ras=0
ElseIf rBoy=2 Then
xBoy -=2
Sprite s6,xBoy,yBoy,zBoy
vBoy +=.5
If vBoy >=1 Then
vBoy=0
zBoy +=1
If zBoy=16 Then zBoy=0
End If
ras +=2
If ras=64 Then ras=0
ElseIf rBoy=3 Then
yBoy -=2
Sprite s4,xBoy,yBoy,zBoy
vBoy +=.5
If vBoy >=1 Then
vBoy=0
zBoy +=1
If zBoy=16 Then zBoy=0
End If
ras +=2
If ras=64 Then ras=0
ElseIf rBoy=4 Then
yBoy +=2
Sprite s3,xBoy,yBoy,zBoy
vBoy +=.5
If vBoy >=1 Then
vBoy=0
zBoy +=1
If zBoy=16 Then zBoy=0
End If
ras +=2
If ras=64 Then ras=0
End If
End Sub
Sub PillsAni()
If ypill >0 Then
Sprite s8,xpill,yPill,zPill
vPill +=.5
If vPill >=1 Then
vPill=0
zPill +=1
If zPill=8 Then
zPill=0
yPill=0
End If
End If
End If
End Sub
Sub NoPills()
If Pills=0 Then
If pills=0 And aExit=0 Then PlaySound w1
aExit=1
End If
End Sub
Sub ExitActiv()
Static vExit As Single
If aExit=1 Then
Sprite s7,xExit,yExit,zExit
vExit +=.5
If vExit >=1 Then
vExit=0
zExit +=1
If zExit=16 Then zExit=0
End If
End If
End Sub
Sub BoyShrink()
If yShrink >0 Then
Sprite s9,xShrink,yShrink,zShrink
If iStop=0 Then
PlaySound w4
iStop=1
End If
vShrink +=.5
If vShrink >=1 Then
vShrink=0
zShrink +=1
If zShrink=16 Then
yShrink=0
End If
End If
End If
End Sub
Sub BoyFlash()
If flash=0 Then
If KeyDown(39) Or KeyDown(37) Or KeyDown(38) Or KeyDown(40) Then
flash=1
z=((yBoy*40+xBoy)/64)+1
map3(z)=32
Exit Sub
End If
Sprite sd,xBoy,yBoy,zFlash
z=((yBoy*40+xBoy)/64)+1
map3(z)=255
vFlash +=.5
If vFlash >=1 Then
vFlash=0
zFlash +=1
If zFlash=8 Then zFlash=0
End If
End If
End Sub
Sub StarShrink()
If yStar >0 Then
Sprite sb,xStar,yStar,zStar
vStar +=.5
If vStar >=1 Then
vStar=0
zStar +=1
If zStar=16 Then
zStar=0
yStar=0
vStar=0
End If
End If
End If
End Sub
Sub InitDat()
For x=0 To 4
xEny(x)=0
yEny(x)=0
rEny(x)=0
zEny(x)=0
vEny(x)=0
Next
xBoy =0: yBoy =0: zBoy =0: rBoy =0
xExit=0: yExit=0: zExit=0: aExit=0
xExp =0: yExp =0: zExp =0: iExp =0
yStar=0: xStar=0: zStar=0: ras =0
yPill=0: xPill=0: zPill=0: pills=0
eras =0: play =0: iStop=0: zAtom=0: x=0: y=0: z=0: p=0: rx=0: p=1
xShrink=0: yShrink=0: zShrink=0: press=0: flash=0: zFlash=0: vFlash=0
End Sub
Sub NewGame()
h1= OpenFile "game/maps/map" + m + "-1.txt"
h2= OpenFile "game/maps/map" + m + "-2.txt"
h3= OpenFile "game/maps/map" + m + "-3.txt"
ReadByte h1,map1,1200
ReadByte h2,map2,1200
ReadByte h3,map3,1200
CloseFile h1
CloseFile h2
CloseFile h3
InitDat
InitEny
InitBoy
End Sub
InitDat
InitEny
InitBoy
While IsWindow(hwnd) 'And KeyDown(27)=0
If KeyDown(32) And press=0 Then
NewGame
press=1
End If
If KeyDown(%VK_N) And rBoy=5 Then
m +=1
If m=19 Then m=1
h1=OpenFile "game/lastLevel.bin"
WriteByte h1,m,4
CloseFile h1
NewGame
End If
ShowMaps
ExitActiv
BoyShrink
BoyBumm
DrawBoy
ScanEnemy
ShowEnemy
CheckBoy
BoyFlash
PillsAni
NoPills
Starshrink
If rBoy=5 Then
BmpText s1,140,320,"NEXT MAP PRESS N",32,84
End If
If rBoy=6 Then
BmpText s1,140,340,"YOU WERE NABBED",32,64
BmpText s1,140,406,"PRESS SPACE BAR",32,64
End If
BmpText s1,320,660,"MAP"+m,24,34
Canvas_Redraw
SetFps (70)
If KeyDown(32)=0 Then press=0
Wend
FreeGraphic
FreeBass
Canvas_Window End
This is here a ThinBasic_abc.dll heavy test.
Is a small game with 18 maps and some stupid enemies.
The Zip file includes everything what we need. (source code is also within)
How do I play ?
Use your arrow keys to move your Picker. (Little boy)
Get all the pills and stars. After that, go on the blinking tile. (Exit)
Here you will read, Press N for the the next level. Do it!
As I said, there are 18 Maps. Each of this Maps is very easy to play. Play it!
Every played Map is automatically stored. (lastlevel.bin)
Thus, you can take a rest, untill to the next day. (When you want this day.)
Uses "ui"
#INCLUDE "abc.inc"
#INCLUDE "bass.inc"
#DEFAULT BOUNDCHECK Off
DWord hdc, hwnd
hwnd = Canvas_Window("ThinBasic",xMiddle(768),yMiddle(708),768,708)
Canvas_Attach(hwnd,0,%TRUE)
hdc = Canvas_GetDC()
SetHandleDC hdc
InitBass
Long xBoy,yBoy,zBoy,rBoy,xExit,yExit,zExit,aExit,xShrink,yShrink,zShrink,play
Long ras,pills,yPill,xPill,zPill,x,y,z,p,rx,zAtom,yStar,xStar,zStar,eras
Long xExp,yExp,zExp,iExp,m,iStop,press,flash,zFlash,ms,h1,h2,h3
Long s1,s2,s3,s4,s5,s6,s7,s8,s9,sa,sb,sc,sd,se,sf,w1,w2,w3,w4,w5
Single vFlash,vExp,vStar,vAtom,vShrink,vBoy,vPill
Dim map1(1200) As Byte
Dim map2(1200) As Byte
Dim map3(1200) As Byte
Dim xEny(4) As Long
Dim yEny(4) As Long
Dim rEny(4) As Long
Dim zEny(4) As Long
Dim vEny(4) As Single
Dim iName As String*16
s1= LoadBmp "game/gfx/char.bmp",60
s2= LoadBmp "game/gfx/atom.bmp",16
s3= LoadBmp "game/gfx/boyd.bmp",16
s4= LoadBmp "game/gfx/boyu.bmp",16
s5= LoadBmp "game/gfx/boyr.bmp",16
s6= LoadBmp "game/gfx/boyl.bmp",16
s7= LoadBmp "game/gfx/exitani.bmp",16
s8= LoadBmp "game/gfx/pillani.bmp",8
s9= LoadBmp "game/gfx/bummani.bmp",16
sa= LoadBmp "game/gfx/starani.bmp",16
sb= LoadBmp "game/gfx/shrani.bmp",16
sc= LoadBmp "game/gfx/fire.bmp",16
sd= LoadBmp "game/gfx/boyf.bmp",8
se= LoadBmp "game/gfx/layout.bmp",1
sf= LoadBmp "game/gfx/font32.bmp",91
w1= LoadSound "game/wavs/success.wav"
w2= LoadSound "game/wavs/caim.wav"
w3= LoadSound "game/wavs/drown.wav"
w4= LoadSound "game/wavs/hit.wav"
w5= LoadSound "game/wavs/grab.wav"
If FileExists "game/lastlevel.bin" Then
h1= OpenFile "game/lastlevel.bin"
ReadByte h1,m,4
CloseFile h1
Else
m=1
End If
h1= OpenFile "game/maps/map" + m + "-1.txt"
h2= OpenFile "game/maps/map" + m + "-2.txt"
h3= OpenFile "game/maps/map" + m + "-3.txt"
ReadByte h1,map1,1200
ReadByte h2,map2,1200
ReadByte h3,map3,1200
CloseFile h1
CloseFile h2
CloseFile h3
Sub BoyBumm()
If yExp >0 Then
Sprite s9,xExp,yExp,zExp
If play=0 Then
PlaySound w4
play=1
End If
vExp +=.5
If vExp >=1 Then
vExp=0
zExp +=1
If zExp =16 Then
yExp =0
iExp =1
End If
End If
End If
End Sub
Sub InitEny()
For y=0 To 29
For x=0 To 39
z=(y*40+x)+1
If map3(z)=62 Then
xEny(p)=x*64
yEny(p)=y*64
rEny(p)=-1
p +=1
ElseIf map3(z)=63 Then
xEny(p)=x*64
yEny(p)=y*64
rEny(p)=-1
p +=1
ElseIf map3(z)=64 Then
xEny(p)=x*64
yEny(p)=y*64
rEny(p)=-1
p +=1
ElseIf map3(z)=65 Then
xEny(p)=x*64
yEny(p)=y*64
rEny(p)=-1
p +=1
End If
If p=5 Then Exit Sub
Next
Next
End Sub
Sub ScanEnemy()
If eras >0 Then Exit Sub
For x=1 To 4
z=((yEny(x)*40+xEny(x))/64)+1
If map3(z)=62 And map3(z+1)=111 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z)=63 And map3(z-1)=111 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf map3(z)=64 And map3(z-40)=111 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf map3(z)=65 And map3(z+40)=111 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf (map3(z)=62 And map3(z+40)=111) Or (map3(z)=63 And map3(z+40)=111) Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf (map3(z)=62 And map3(z-40)=111) Or (map3(z)=63 And map3(z-40)=111) Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf (map3(z)=64 And map3(z-1)=111) Or (map3(z)=65 And map3(z-1)=111) Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf (map3(z)=64 And map3(z+1)=111) Or (map3(z)=65 And map3(z+1)=111) Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z)=62 Then
If map1(z)=105 And map3(z+1)=32 And map3(z+40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
ElseIf rx=2 Then
rEny(x)=4
map3(z)=32
map3(z+40)=65
End If
ElseIf map1(z)=105 And map3(z+1)=32 And map3(z-40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
ElseIf rx=2 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
End If
ElseIf map1(z)=105 And map3(z+40)=32 And map3(z-40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=4
map3(z)=32
map3(z+40)=64
ElseIf rx=2 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
End If
ElseIf map3(z+40)=32 And map3(z+1) >32 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf map3(z-40)=32 And map3(z+1) >32 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf map3(z+1) >32 And map3(z+40) >32 And map3(z-40) >32 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf map3(z+1) >32 And map3(z+40) >32 And map3(z-40) >32 Then
rEny(x)=-1
ElseIf map3(z)=62 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
End If
ElseIf map3(z)=63 Then
If map1(z)=105 And map3(z-1)=32 And map3(z-40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
ElseIf rx=2 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
End If
ElseIf map1(z)=105 And map3(z+40)=32 And map3(z-40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=4
map3(z)=32
map3(z+40)=64
ElseIf rx=2 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
End If
ElseIf map1(z)=105 And map3(z-1)=32 And map3(z+40)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
ElseIf rx=2 Then
rEny(x)=4
map3(z)=32
map3(z+40)=65
End If
ElseIf map3(z+40)=32 And map3(z-1) >32 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf map3(z-40)=32 And map3(z-1) >32 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf map3(z-1) >32 And map3(z+40) >32 And map3(z-40) >32 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z-1) >32 And map3(z+40) >32 And map3(z-40) >32 Then
rEny(x)=-1
ElseIf map3(z)=63 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
End If
ElseIf map3(z)=64 Then
If map1(z)=105 And map3(z-40)=32 And map3(z+1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
ElseIf rx=2 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
End If
ElseIf map1(z)=105 And map3(z-40)=32 And map3(z-1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=3
map3(z)=32
map3(z-40)=64
ElseIf rx=2 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
End If
ElseIf map1(z)=105 And map3(z-1)=32 And map3(z+1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
ElseIf rx=2 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
End If
ElseIf map3(z-40) >32 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf map3(z-40) >32 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z-40) >32 And map3(z+1) >32 And map3(z-1) >32 And map3(z+40)=32 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
ElseIf map3(z-40) >32 And map3(z+1) >32 And map3(z-1) >32 Then
rEny(x)=-1
ElseIf map3(z)=64 And map3(z-40)=32 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
Else
rEny(x)=-1
End If
ElseIf map3(z)=65 Then
If map1(z)=105 And map3(z+40)=32 And map3(z+1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=4
map3(z)=32
map3(z+40)=65
ElseIf rx=2 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
End If
ElseIf map1(z)=105 And map3(z+40)=32 And map3(z-1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=4
map3(z)=32
map3(z+40)=65
ElseIf rx=2 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
End If
ElseIf map1(z)=105 And map3(z+1)=32 And map3(z-1)=32 Then
rx=Rand(1,2)
If rx=1 Then
rEny(x)=1
map3(z)=32
map3(z+1)=62
ElseIf rx=2 Then
rEny(x)=2
map3(z)=32
map3(z-1)=63
End If
ElseIf map3(z+40) >32 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=63
rEny(x)=2
ElseIf map3(z+40) >32 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=62
rEny(x)=1
ElseIf map3(z+40) >32 And map3(z+1) >32 And map3(z-1) >32 And map3(z-40)=32 Then
map3(z)=32
map3(z-40)=64
rEny(x)=3
ElseIf map3(z+40) >32 And map3(z+1) >32 And map3(z-1) >32 Then
rEny(x)=-1
ElseIf map3(z+40)=32 Then
map3(z)=32
map3(z+40)=65
rEny(x)=4
End If
End If
Next
End Sub
Sub SetEny(e As Long)
vEny(e) +=.5
If vEny(e) >=1 Then
vEny(e)=0
zEny(e) +=1
If zEny(e)=16 Then zEny(e)=0
End If
End Sub
Sub ShowEnemy()
For z=1 To 4
If rEny(z)= -1 Then
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
ElseIf rEny(z)=1 Then
xEny(z) +=2
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
ElseIf rEny(z)=2 Then
xEny(z) -=2
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
ElseIf rEny(z)=3 Then
yEny(z) -=2
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
ElseIf rEny(z)=4 Then
yEny(z) +=2
Sprite(sc,xEny(z),yEny(z),zEny(z))
SetEny(z)
End If
Next
eras +=2
If eras=64 Then eras=0
End Sub
Sub ShowMaps()
For y=0 To 29
For x=0 To 39
z=(y*40+x)+1
If map1(z)=34 Then Sprite s1,x*64,y*64,1
If map1(z)=107 Then Sprite s1,x*64,y*64,2
If map1(z)=105 Then Sprite s1,x*64,y*64,2
If map2(z)=91 Then Sprite s2,x*64,y*64,zAtom
If map2(z)=121 Then Sprite s7,x*64,y*64,0
If map2(z)=81 Then Sprite sa,x*64,y*64,zAtom
Next
Next
vAtom +=.5
If vAtom >=1 Then
vAtom=0
zAtom +=1
If zAtom=16 Then zAtom=0
End If
End Sub
Sub InitBoy()
For y=0 To 29
For x=0 To 39
z=(y*40+x)+1
If map3(z)=111 Then
xBoy = x*64
yBoy = y*64
End If
If map2(z)=91 Or map2(z)=81 Then
pills +=1
End If
If map2(z)=121 Then
xExit = x*64
yExit = y*64
End If
Next
Next
End Sub
Sub CheckBoy()
If ras >0 Or rBoy >=5 Then Exit Sub
z=((yBoy*40+xBoy)/64)+1
If map3(z) >=62 And map3(z) <=65 Then
rBoy=6
xExp=xBoy
yExp=yBoy
ElseIf map2(z)=121 And aExit=1 Then
xShrink=xBoy
yShrink=yBoy
map3(z)=32
rBoy=5
ElseIf map2(z)=91 Then
xPill=xBoy
yPill=yBoy
Pills -= 1
map2(z)=32
map3(z)=32
rBoy=0
PlaySound w2
ElseIf map2(z)=81 Then
xStar=xBoy
yStar=yBoy
Pills -= 1
map2(z)=32
map3(z)=32
rBoy=0
PlaySound w5
ElseIf KeyDown(39) <0 And map3(z+1)=32 Then
map3(z)=32
map3(z+1)=111
rBoy=1
ElseIf KeyDown(37) <0 And map3(z-1)=32 Then
map3(z)=32
map3(z-1)=111
rBoy=2
ElseIf KeyDown(38) <0 And map3(z-40)=32 Then
map3(z)=32
map3(z-40)=111
rBoy=3
ElseIf KeyDown(40) <0 And map3(z+40)=32 Then
map3(z)=32
map3(z+40)=111
rBoy=4
Else
rBoy=0
End If
End Sub
Sub DrawBoy()
If rBoy=0 Then
Sprite s3,xBoy,yBoy,0
ElseIf rBoy=1 Then
xBoy +=2
Sprite s5,xBoy,yBoy,zBoy
vBoy +=.5
If vBoy >=1 Then
vBoy=0
zBoy +=1
If zBoy=16 Then zBoy=0
End If
ras +=2
If ras=64 Then ras=0
ElseIf rBoy=2 Then
xBoy -=2
Sprite s6,xBoy,yBoy,zBoy
vBoy +=.5
If vBoy >=1 Then
vBoy=0
zBoy +=1
If zBoy=16 Then zBoy=0
End If
ras +=2
If ras=64 Then ras=0
ElseIf rBoy=3 Then
yBoy -=2
Sprite s4,xBoy,yBoy,zBoy
vBoy +=.5
If vBoy >=1 Then
vBoy=0
zBoy +=1
If zBoy=16 Then zBoy=0
End If
ras +=2
If ras=64 Then ras=0
ElseIf rBoy=4 Then
yBoy +=2
Sprite s3,xBoy,yBoy,zBoy
vBoy +=.5
If vBoy >=1 Then
vBoy=0
zBoy +=1
If zBoy=16 Then zBoy=0
End If
ras +=2
If ras=64 Then ras=0
End If
End Sub
Sub PillsAni()
If ypill >0 Then
Sprite s8,xpill,yPill,zPill
vPill +=.5
If vPill >=1 Then
vPill=0
zPill +=1
If zPill=8 Then
zPill=0
yPill=0
End If
End If
End If
End Sub
Sub NoPills()
If Pills=0 Then
If pills=0 And aExit=0 Then PlaySound w1
aExit=1
End If
End Sub
Sub ExitActiv()
Static vExit As Single
If aExit=1 Then
Sprite s7,xExit,yExit,zExit
vExit +=.5
If vExit >=1 Then
vExit=0
zExit +=1
If zExit=16 Then zExit=0
End If
End If
End Sub
Sub BoyShrink()
If yShrink >0 Then
Sprite s9,xShrink,yShrink,zShrink
If iStop=0 Then
PlaySound w4
iStop=1
End If
vShrink +=.5
If vShrink >=1 Then
vShrink=0
zShrink +=1
If zShrink=16 Then
yShrink=0
End If
End If
End If
End Sub
Sub BoyFlash()
If flash=0 Then
If KeyDown(39) Or KeyDown(37) Or KeyDown(38) Or KeyDown(40) Then
flash=1
z=((yBoy*40+xBoy)/64)+1
map3(z)=32
Exit Sub
End If
Sprite sd,xBoy,yBoy,zFlash
z=((yBoy*40+xBoy)/64)+1
map3(z)=255
vFlash +=.5
If vFlash >=1 Then
vFlash=0
zFlash +=1
If zFlash=8 Then zFlash=0
End If
End If
End Sub
Sub StarShrink()
If yStar >0 Then
Sprite sb,xStar,yStar,zStar
vStar +=.5
If vStar >=1 Then
vStar=0
zStar +=1
If zStar=16 Then
zStar=0
yStar=0
vStar=0
End If
End If
End If
End Sub
Sub InitDat()
For x=0 To 4
xEny(x)=0
yEny(x)=0
rEny(x)=0
zEny(x)=0
vEny(x)=0
Next
xBoy =0: yBoy =0: zBoy =0: rBoy =0
xExit=0: yExit=0: zExit=0: aExit=0
xExp =0: yExp =0: zExp =0: iExp =0
yStar=0: xStar=0: zStar=0: ras =0
yPill=0: xPill=0: zPill=0: pills=0
eras =0: play =0: iStop=0: zAtom=0: x=0: y=0: z=0: p=0: rx=0: p=1
xShrink=0: yShrink=0: zShrink=0: press=0: flash=0: zFlash=0: vFlash=0
End Sub
Sub NewGame()
h1= OpenFile "game/maps/map" + m + "-1.txt"
h2= OpenFile "game/maps/map" + m + "-2.txt"
h3= OpenFile "game/maps/map" + m + "-3.txt"
ReadByte h1,map1,1200
ReadByte h2,map2,1200
ReadByte h3,map3,1200
CloseFile h1
CloseFile h2
CloseFile h3
InitDat
InitEny
InitBoy
End Sub
InitDat
InitEny
InitBoy
While IsWindow(hwnd) 'And KeyDown(27)=0
If KeyDown(32) And press=0 Then
NewGame
press=1
End If
If KeyDown(%VK_N) And rBoy=5 Then
m +=1
If m=19 Then m=1
h1=OpenFile "game/lastLevel.bin"
WriteByte h1,m,4
CloseFile h1
NewGame
End If
ShowMaps
ExitActiv
BoyShrink
BoyBumm
DrawBoy
ScanEnemy
ShowEnemy
CheckBoy
BoyFlash
PillsAni
NoPills
Starshrink
If rBoy=5 Then
BmpText s1,140,320,"NEXT MAP PRESS N",32,84
End If
If rBoy=6 Then
BmpText s1,140,340,"YOU WERE NABBED",32,64
BmpText s1,140,406,"PRESS SPACE BAR",32,64
End If
BmpText s1,320,660,"MAP"+m,24,34
Canvas_Redraw
SetFps (70)
If KeyDown(32)=0 Then press=0
Wend
FreeGraphic
FreeBass
Canvas_Window End