
Hi there Jess, thanks for a reply. Just tried your idea and it works a treat!

Thought it was to do with no value in the array or outside of it should I say, but wasn't sure as it said nothing in the tutorial and nobody else has mentioned it which is strange????
Thanks for the help though, the DBPro forums are still very helpfull, or should that be the people in it!

Heres the new code if anyone needs it in following the tutorial.
Rem Project: PACMAN
Rem Created: 15/03/2005 21:11:05
Rem ***** Main Source File *****
set display mode 1024,768,32
hide mouse
sync off
cls
`
` Declare global variables
global playerz#, playerx#
global playerup, playerdown, playerleft, playerright
global playercangoup, playercangodown, playercangoleft, playercangoright
`
` Maze is 16 cells across by 20 cells down
dim maze#(20,16)
_load_level()
`
` Define player object
make object sphere 1000,6
color object 1000, rgb(255,255,0)
_start_level()
do
position camera 87,150,87
point camera 87,0,87
`
` See if player is in the centre of a cell
centrex#=(playerx#-20)/8
centrez#=(playerz#+4)/8
centrex=int(centrex#)
centrez=int(centrez#)
centre=0
if centrex#=centrex and centrez#=centrez
centre=1
endif
`
` If player in centre of a cell
if centre=1
`
` Initialise all possible directions
playercangoup=0
playercangodown=0
playercangoleft=0
playercangoright=0
`
` See what is in the cell immediately up, down, left and right of player
xplus=centrex+1
xmin=centrex-1
if xplus > 16 then xplus=1
if xmin < 1 then xmin=16
mazeup=maze#(centrez+1, centrex)
mazedown=maze#(centrez-1, centrex)
mazeleft=maze#(centrez, xmin)
mazeright=maze#(centrez, xplus)
`
` Determine whether it is possible for player to make move
if mazeup=0 or mazeup>=3
playercangoup=1
else
playerup=0
endif
if mazedown=0 or mazedown>=3
playercangodown=1
else
playerdown=0
endif
if mazeleft=0 or mazeleft>=3
playercangoleft=1
else
playerleft=0
endif
if mazeright=0 or mazeright>=3
playercangoright=1
else
playerright=0
endif
_player_turn()
endif
`
` Allow player to do a quick about face
if playerright=1 and leftkey()
_reset_player_direction()
playerleft=1
endif
if playerleft=1 and rightkey()
_reset_player_direction()
playerright=1
endif
if playerup=1 and downkey()
_reset_player_direction()
playerdown=1
endif
if playerdown=1 and upkey()
_reset_player_direction()
playerup=1
endif
_player_move()
_player_show()
sync
loop
function _start_level()
playerx#=84
playerz#=52
groundheight=get ground height(1,87,87)
position object 1000, playerx#, groundheight, playerz#
playerup=0
playerdown=0
playerleft=0
playerright=0
endfunction
function _reset_player_direction()
playerup=0
playerdown=0
playerleft=0
playerright=0
endfunction
function _player_move()
`
` Check to see if the player is at edge of maze
if playerx#<=28 and playerleft
playerx#=150
endif
if playerx#>=150 and playerright
playerx#=28
endif
`
` Alter player coordinate
if playerup then playerz#=playerz#+1
if playerdown then playerz#=playerz#-1
if playerleft then playerx#=playerx#-1
if playerright then playerx#=playerx#+1
endfunction
function _player_turn()
`
` Respond to player actions
if upkey() and playercangoup=1
_reset_player_direction()
playerup=1
endif
if downkey() and playercangodown=1
_reset_player_direction()
playerdown=1
endif
if leftkey() and playercangoleft=1
_reset_player_direction()
playerleft=1
endif
if rightkey() and playercangoright=1
_reset_player_direction()
playerright=1
endif
endfunction
function _player_show()
groundheight=get ground height(1,87,87)
position object 1000, playerx#, groundheight, playerz#
endfunction
function _load_level()
mazewall=0
mazepill=200
mazepower=500
load image "media\blank.bmp",1
make matrix 1,128,160,16,20
prepare matrix texture 1,1,1,1
fill matrix 1,0,1
position matrix 1,24,0,0
groundheight=get ground height(1,87,87)
for mazey=1 to 20
for mazex=1 to 16
read maze
maze#(mazey, mazex)=maze
`
` If a wall is detected
if maze=1
inc mazewall
make object cube mazewall,8
color object mazewall, rgb(0,0,255)
position object mazewall, (mazex*8)+20, groundheight, (mazey*8)-4
endif
`
` If a pen gate is detected
if maze=2
inc mazewall
make object cube mazewall,8
color object mazewall, rgb(255,0,255)
position object mazewall, (mazex*8)+20, groundheight, (mazey*8)-4
endif
`
` If a pill is detected
if maze=3
inc mazepill
make object sphere mazepill,2
color object mazepill, rgb(255,255,0)
position object mazepill, (mazex*8)+20, groundheight, (mazey*8)-4
endif
`
` If a power pill is detected
if maze=4
inc mazepower
make object sphere mazepower,4
color object mazepower, rgb(255,255,0)
position object mazepower, (mazex*8)+20, groundheight, (mazey*8)-4
endif
next mazex
next mazey
endfunction
level1:
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Data 1,3,3,3,3,1,3,3,3,3,1,3,3,3,3,1
Data 1,4,1,1,3,3,3,1,1,3,3,3,1,1,4,1
Data 1,3,1,1,1,1,3,3,3,3,1,1,1,1,3,1
Data 1,3,3,3,3,3,3,1,1,3,3,3,3,3,3,1
Data 1,1,1,3,1,1,1,1,1,1,1,1,3,1,1,1
Data 1,3,3,3,3,3,3,0,0,3,3,3,3,3,3,1
Data 1,3,1,3,1,1,1,1,1,1,1,1,3,1,3,1
Data 1,3,1,3,1,1,1,1,1,1,1,1,3,1,3,1
Data 1,3,1,3,3,3,3,3,3,3,3,3,3,1,3,1
Data 1,3,1,3,1,3,1,1,1,1,3,1,3,1,3,1
Data 1,3,3,3,1,3,1,0,0,1,3,1,3,3,3,1
Data 1,1,1,3,1,3,1,2,2,1,3,1,3,1,1,1
Data 0,0,0,3,3,3,0,0,0,0,3,3,3,0,0,0
Data 1,1,1,3,1,1,1,1,1,1,1,1,3,1,1,1
Data 1,3,3,3,3,3,3,1,1,3,3,3,3,3,3,1
Data 1,3,1,1,1,1,3,3,3,3,1,1,1,1,3,1
Data 1,4,1,1,3,3,3,1,1,3,3,3,1,1,4,1
Data 1,3,3,3,3,1,3,3,3,3,1,3,3,3,3,1
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
This is all like AMOS on the Amiga!
