Ok, I accidentially added an extra number to the camera point direction.
Now, I have gotten further and all is well except THE COLLISION WONT WORK! I must have missed a step, but I went back and didn't see anything new.
Code:
set display mode 1024,768,32
Hide Mouse
Sync On
Autocam Off
Cls
Global PlayerX#
Global PlayerZ#
Global PlayerUp
Global PlayerDown
Global PlayerLeft
Global PlayerRight
Global PlayerCanGoUp
Global PlayerCanGoDown
Global PlayerCanGoLeft
Global PlayerCanGoRight
Global Pills
Dim Maze#(22,18)
Dim Ghosts#(4,11)
_Load_Level()
Make Object Sphere 1000,6
Color Object 1000, rgb(255,255,0)
Make Object Sphere 1001,6
Color Object 1001,rgb(255,0,0)
Make Object Sphere 1002,6
Color Object 1002,rgb(0,0,255)
Make Object Sphere 1003,6
Color Object 1003,rgb(0,255,0)
Make Object Sphere 1004,6
Color Object 1004,rgb(255,0,255)
_Start_Level()
Do
Position Camera 87,150,87
Point Camera 87,0,87
If Pills = 0
_Load_Level()
_Start_Level()
EndIf
CenterX# = (PlayerX#-20)/8
CenterZ# = (PlayerZ#+4)/8
CenterX = Int(CenterX#)
CenterZ = Int(CenterZ#)
Center = 0
If CenterX# = CenterX and CenterZ# = CenterZ
Center = 1
EndIf
If Center = 1
PlayerCanGoUp = 0
PlayerCanGoDown = 0
PlayerCanGoLeft = 0
PlayerCanGoRight = 0
MazeUp = Maze#(CenterZ+1,CenterX)
MazeDown = Maze#(CenterZ-1,CenterX)
MazeLeft = Maze#(CenterZ,CenterX-1)
MazeRight = Maze#(CenterZ,CenterX+1)
If MazeUp=0 or MazeUp>=3
PlayerCanGoUp=1
Else
PlayerCanGoUp=0
EndIf
If MazeDown=0 or MazeDown>=3
PlayerCanGoDown=1
Else
PlayerCanGoDown=0
EndIf
If MazeLeft=0 or MazeLeft>=3
PlayerCanGoLeft=1
Else
PlayerCanGoLeft=0
EndIf
If MazeRight=0 or MazeRight>=3
PlayerCanGoRight=1
Else
PlayerCanGoRight=0
EndIf
_Player_Turn()
EndIf
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()
_Check_Ghost()
_Ghost_Move()
_Ghost_Show()
_Detect_Collisions()
Sync
Loop
Function _Load_Level()
Pills = 0
For MazeWall = 1 to 199
If Object Exist(MazeWall)
Delete Object MazeWall
EndIf
Next MazeWall
MazeWall = 0
For MazePill = 1 to 499
If Object Exist(MazePill)
Delete Object MazePill
EndIf
Next MazePill
MazePill = 200
For MazePower = 500 to 510
If Object Exist(MazePower)
Delete Object MazePower
EndIf
Next MazePower
MazePower = 500
Load image "media\blank.JPG",1
If Not Matrix Exist(1)
Make Matrix 1,128,160,16,20
Position Matrix 1,24,0,0
Prepare Matrix Texture 1,1,1,1
Fill Matrix 1,0,1
EndIf
GroundHeight = Get Ground Height(1,87,87)
Restore Level1
For MazeY = 1 to 20
For MazeX = 1 to 16
Read Maze
Maze#(MazeY,MazeX) = Maze
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 Maze = 2
inc MazeWall
Make Object Cube MazeWall,8
Color Object MazeWall,rgb(100,0,0)
Position Object MazeWall,(MazeX*8)+20,GroundHeight,(MazeY*8)-4
EndIf
If Maze = 3
inc MazePill
inc Pills
Make Object Sphere MazePill,2
Color Object MazePill,rgb(255,255,0)
Position Object MazePill,(MazeX*8)+20,GroundHeight,(MazeY*8)-4
Make Object Collision Box MazePill, -.5,-.5,-.5,-.5,-.5,-.5,1
EndIf
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
Make Object Collision Box MazePower, -.5,-.5,-.5,-.5,-.5,-.5,1
EndIf
Next MazeX
Next MazeY
EndFunction
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
_Reset_Ghosts()
EndFunction
Function _Player_Move()
If PlayerX# <= 28 And PlayerLeft
PlayerX# = 150
EndIf
If PlayerX# >= 150 And PlayerRight
PlayerX# = 28
EndIf
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()
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 _Reset_Player_Direction()
PlayerUp = 0
PlayerDown = 0
PlayerLeft = 0
PlayerRight = 0
EndFunction
Function _Detect_Collisions()
Collision = Object Collision(1000,0)
If Collision > 200 And Collision < 500
Delete Object Collision
Dec Pills
EndIf
If Collision >500 And Collision < 505
Delete Object Collision
EndIf
EndFunction
Function _Reset_Ghosts()
For Ghost = 1 to 4
Ghosts#(Ghost,3) = 0
Ghosts#(Ghost,4) = 0
Ghosts#(Ghost,5) = 0
Ghosts#(Ghost,6) = 0
Ghosts#(Ghost,7) = 0
Ghosts#(Ghost,8) = 0
Ghosts#(Ghost,9) = 0
Ghosts#(Ghost,10) = 0
Ghosts#(1,6) = 1
Ghosts#(2,6) = 1
Ghosts#(3,5) = 1
Ghosts#(4,5) = 1
Next Ghost
Ghosts#(1,1) = 88
Ghosts#(1,2) = 108
Ghosts#(1,11) = 0
Ghosts#(2,1) = 84
Ghosts#(2,2) = 92
Ghosts#(2,11) = 1
Ghosts#(3,1) = 88
Ghosts#(3,2) = 92
Ghosts#(3,11) = 1
Ghosts#(4,1) = 92
Ghosts#(4,2) = 92
Ghosts#(4,11) = 1
EndFunction
Function _Ghost_Show()
GroundHeight = Get Ground Height(1,87,87)
For Ghost = 1 to 4
GhostObject = 1000+Ghost
GhostX# = Ghosts#(Ghost,1)
GhostZ# = Ghosts#(Ghost,2)
Position Object GhostObject,GhostX#,GroundHeight,GhostZ#
Next Ghost
EndFunction
Function _Ghost_Move()
For Ghost = 1 to 4
GhostX# = Ghosts#(Ghost,1)
GhostZ# = Ghosts#(Ghost,2)
GhostUp = Ghosts#(Ghost,3)
GhostDown = Ghosts#(Ghost,4)
GhostLeft = Ghosts#(Ghost,5)
GhostRight = Ghosts#(Ghost,6)
If GhostX# <= 28 And GhostLeft
GhostX# = 150
EndIf
If GhostX# >= 150 And GhostRight
GhostX# = 28
EndIf
If GhostUp Then GhostZ# = GhostZ# + 1
If GhostDown Then GhostZ# = GhostZ# - 1
If GhostLeft Then GhostX# = GhostX# - 1
If GhostRight Then GhostX# = GhostX# + 1
Ghosts#(Ghost,1) = GhostX#
Ghosts#(Ghost,2) = GhostZ#
Next Ghost
EndFunction
Function _Check_Ghost()
For Ghost = 1 to 4
GhostX# = Ghosts#(Ghost,1)
GhostZ# = Ghosts#(Ghost,2)
GhostUp = Ghosts#(Ghost,3)
GhostDown = Ghosts#(Ghost,4)
GhostLeft = Ghosts#(Ghost,5)
GhostRight = Ghosts#(Ghost,6)
CenterX# = (GhostX#-20)/8
CenterZ# = (GhostZ#+4)/8
CenterX = Int(CenterX#)
CenterZ = Int(CenterZ#)
Center = 0
If Center = 1
GhostCanGoUp = 0
GhostCanGoDown = 0
GhostCanGoLeft = 0
GhostCanGoRight = 0
MazeUp = Maze#(CenterZ+1,CenterX)
MazeDown = Maze#(CenterZ-1,CenterX)
MazeLeft = Maze#(CenterZ,CenterX-1)
MazeRight = Maze#(CenterZ,CenterX+1)
If MazeUp = 0 or MazeUp >=3
GhostCanGoUp=1
Else
GhostCanGoUp=0
EndIf
If MazeDown = 0 or MazeDown >=3
GhostCanGoDown=1
Else
GhostCanGoDown=0
EndIf
If MazeLeft = 0 or MazeLeft >=3
GhostCanGoLeft=1
Else
GhostCanGoLeft=0
EndIf
If MazeRight = 0 or MazeRight >=3
GhostCanGoRight=1
Else
GhostCanGoRight=0
EndIf
Ghosts#(Ghost,3)=GhostUp
Ghosts#(Ghost,4)=GhostDown
Ghosts#(Ghost,5)=GhostLeft
Ghosts#(Ghost,6)=GhostRight
Ghosts#(Ghost,7)=GhostCanGoUp
Ghosts#(Ghost,8)=GhostCanGoDown
Ghosts#(Ghost,9)=GhostCanGoLeft
Ghosts#(Ghost,10)=GhostCanGoRight
EndIf
Next Ghost
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
According to the tutorial, at this point, collision should work for both users AND ghosts.
Digitalmodr
Coder_David
[Apolloed ]