Here's some updated code with comments on what is giving me problems where, too
` Do menu.
GoSub Menu
CLS
` Initial settings.
GoSub Loading
` Call setup routines.
GoSub LoadObjects
GoSub Declarations
GoSub CreateRoom
CLS
` Main loop.
Do
GoSub Animate
GoSub Walk
GoSub Shoot
` Update screen.
Sync
Loop
Loading:
` Setup and play level sound.
Load Music "SND\LEVELMUSIC.MP3", 1
Load Sound "SND\WATER.WAV", 2
Loop Music 1
Loop Sound 2, 0
Set Sound Volume 2, 90
` Set general screen settings.
BackDrop Off : Hide Mouse
` Select font.
Set Text Font "Andy" : Set Text Size 24
Set Text to Bold : Set Text Transparent
` Loading prompt.
Sync : Center Text Screen Width()/2, Screen Height()/2, "LOADING" : Sync
Return
LoadObjects:
` Load textures.
Load Image "TEX\FLOOR.JPG", 1
Load Image "TEX\CEILING.JPG", 2
Load Image "TEX\WALL.JPG", 3
Load Image "TEX\WATER.JPG", 4
Load Image "TEX\HEALTH.BMP", 5
` Load status.
Load Image "TEX\CROSSHAIR.BMP", 6
Load Image "TEX\AK47.JPG", 7
` Load weapons.
Load Object "OBJ\AK47.X", 8
` Load in game sounds.
Load Sound "SND\SPLASH.WAV", 3
Load Music "SND\AK47.WAV", 4
Return
Declarations:
` Structural settings.
WestWall = 1
EastWall = 2
SouthWall = 3
NorthWall = 4
Ceiling = 5
Floor = 6
Water = 7
` Limitations as walking goes:
MaxWest = 2
MaxEast = 98
MaxSouth = 2
MaxNorth = 98
` Character actions.
Ducking = 0
` Declare game variables.
Health# = 100
GunMoveLeft = 1
Return
CreateRoom:
` Create floor.
Make Object Cube Floor, 100
Scale Object Floor, 100, 1, 100
Position Object Floor, 50, 0, 50
Texture Object Floor, 1
Scale Object Texture Floor, 20, 20
` Create room walls.
Make Object Plain WestWall, 100, 10
Make Object Plain EastWall, 100, 10
Make Object Plain SouthWall, 100, 10
Make Object Plain NorthWall, 100, 10
Position Object WestWall, 0, 5, 50
Position Object EastWall, 100, 5, 50
Position Object SouthWall, 50, 5, 0
Position Object NorthWall, 50, 5, 100
YRotate Object WestWall, Object Angle Y(2)+90
YRotate Object EastWall, Object Angle Y(3)+90
` Texture walls.
For Obj = 1 To 4
Texture Object Obj, 3
Scale Object Texture Obj, 6, 1
Scroll Object Texture Obj, 0, +.06
Set Object Texture Obj, 1, 2
Next Obj
` Create ceiling.
Make Object Cube Ceiling, 100
Scale Object Ceiling, 100, 1, 100
Position Object Ceiling, 50, 10, 50
Texture Object Ceiling, 2
Scale Object Texture Ceiling, 15, 15
` Make water.
Make Object Cube Water, 100
Scale Object Water, 100, 1, 100
Position Object Water, 50, .2, 50
Texture Object Water, 4
Scale Object Texture Water, 20, 20
Ghost Object On Water, 3
` Setup toolbar.
` 1) Health bar
Sprite 1, 0, 628, 5
Set Sprite 1, 0, 1
Set Sprite Priority 1, 0
Set Sprite Alpha 1, 125
` 2) Crosshair
Sprite 2, Screen Width()/2, Screen Height()/2, 6
Set Sprite 3, 0, 1
Set Sprite Priority 3, 1
` 3) Weapon bar
Sprite 3, 866, 608, 7
Set Sprite 3, 0, 1
Set Sprite Priority 3, 2
Set Sprite Alpha 3, 125
` Position weapon.
Lock Object On 8
Scale Object 8, 20, 20, 20
Rotate Object 8, -5, 0, 0
Position Object 8, 0.5, -1, 2.1
Disable Object ZDepth 8
` Set up text.
Set Text Font "Tahoma" : Set Text Size 48
Set Text Transparent
[b]HERE IT IS!!! AAAHHH
THIS IS WHERE THE TROUBLE IS, NO MATTER WHAT THE CAMERA
ALWAYS POINTS AT THE CEILING[/b]
` Position player.
Position Camera 50, 3, 50
Position Mouse 1024, 768
Point Camera 152, 153, 152
Return
Animate:
` Move the water.
Scroll Object Texture Water, -.002, -0.002
` Move player weapon.
If GunMoveLeft = 1
YRotate Object 8, Object Angle Y(8) + .05
If Object Angle Y(8) > 4.5 Then GunMoveLeft = 0
Endif
If GunMoveLeft = 0
YRotate Object 8, Object Angle Y(8) - .05
If Object Angle Y(8) < 1.5 Then GunMoveLeft = 1
Endif
` Set mipmapping.
For Obj = 1 To 4
Set Object Texture Obj, 1, 2
Next Obj
` Refresh health.
Center Text 90, 654, STR$(Health#)
Return
Walk:
[b]HERE'S THE MAIN LINE OF THE PROBLEM! BECAUSE OF YOUR MOUSE MOVEMENT ON THE MAIN MENU, IT LOOKS AT THE CEILING. I KNOW THIS LINE IS THE PROBLEM BECAUSE I TRIED TAKING IT OUT ALTOGETHER AND THE BUG WAS GONE! BUT I NEED THIS LINE TO MAKE IT SO THAT YOU CAN LOOK AROUND WITH THE MOUSE. ANYONE KNOW OF ANY OTHER WAYS OF LOOKING AROUND WITH THE MOUSE SO THAT THIS CAN BE FIXED?[/b]
` Rotate camera according to mouse movement.
Rotate Camera Camera Angle X(0)+(MouseMoveY()/2.0),Camera Angle Y(0)+(MouseMoveX()/2.0),0
` Control player movement.
cx#=Camera Angle X(0) : cy#=Camera Angle Y(0)
If UpKey()=1
XRotate Camera 0, 0 : Move Camera 0, 0.3 : XRotate Camera 0, cx#
` Play walking sound.
If Sound Playing(3)
GoTo Next1
Else
Play Sound 3
Set Sound Speed 3, 9500+RND(1500)
EndIf
Next1:
EndIf
If DownKey()=1
XRotate Camera 0, 0 : Move Camera 0, -0.3 : XRotate Camera 0, cx#
` Play walking sound.
If Sound Playing(3)
GoTo Next2
Else
Play Sound 3
Set Sound Speed 3, 9500+RND(1500)
EndIf
Next2:
EndIf
If LeftKey()=1
YRotate Camera 0, cy#-90 : Move Camera 0.3 : YRotate Camera 0, cy#
If Ducking = 1 Then If Camera Position Y() < 1.5 Then Position Camera Camera Position X(), 1.5, Camera Position Z()
If Ducking = 0 Then If Camera Position Y() < 3 Then Position Camera Camera Position X(), 3, Camera Position Z()
` Play walking sound.
If Sound Playing(3)
GoTo Next3
Else
Play Sound 3
Set Sound Speed 3, 9500+RND(1500)
EndIf
Next3:
EndIf
If RightKey()=1
YRotate Camera 0, cy#+90 : Move Camera 0.3 : YRotate Camera 0, cy#
If Ducking = 1 Then If Camera Position Y() < 1.5 Then Position Camera Camera Position X(), 1.5, Camera Position Z()
If Ducking = 0 Then If Camera Position Y() < 3 Then Position Camera Camera Position X(), 3, Camera Position Z()
` Play walking sound.
If Sound Playing(3)
GoTo Next4
Else
Play Sound 3
Set Sound Speed 3, 9500+RND(1500)
EndIf
Next4:
EndIf
` Prevent camera from performing full rotation.
If WrapValue (Camera Angle X(0)) > 40 and WrapValue (Camera Angle X(0)) < 180 Then XRotate Camera 0, 40
If WrapValue (Camera Angle X(0)) > 180 and WrapValue (Camera Angle X(0)) < 280 Then XRotate Camera 0, 280
` Set ducking/gravity levels.
If ControlKey() = 1
Ducking = 1
Position Camera Camera Position X(), Camera Position Y() - .09, Camera Position Z()
If Camera Position Y() < 2 Then Position Camera Camera Position X(), 2, Camera Position Z()
EndIf
If ControlKey() = 0
Ducking = 0
Position Camera Camera Position X(), Camera Position Y() + .07, Camera Position Z()
If Camera Position Y() > 3 Then Position Camera Camera Position X(), 3, Camera Position Z()
EndIf
` Limit where player is allowed to walk.
If Camera Position X() < MaxWest Then Position Camera MaxWest, Camera Position Y(), Camera Position Z()
If Camera Position X() > MaxEast Then Position Camera MaxEast, Camera Position Y(), Camera Position Z()
If Camera Position Z() > MaxNorth Then Position Camera Camera Position X(), Camera Position Y(), MaxNorth
If Camera Position Z() < MaxSouth Then Position Camera Camera Position X(), Camera Position Y(), MaxSouth
Return
Shoot:
` Check if user is firing.
If MouseClick()=1
` Play the sound.
If Music Playing(4)
Return
Else
Loop Music 4
EndIf
EndIf
If MouseClick()=0
Stop Music 4
Endif
Return
` === MAIN MENU ===
Menu:
` Set resolution and frame rate.
Set Display Mode 1024, 768, 32
Sync On : Sync Rate 0
` Load and display menu.
Load Image "MNU\OPTIONS.BMP", 1
Load Image "MNU\LOGO.BMP", 2
Load Image "MNU\NEW.BMP", 3
Load Image "MNU\STORY.BMP", 4
Load Image "MNU\CREDITS.BMP", 5
Load Image "MNU\EXIT.BMP", 6
Do
CLS
` Place the images.
Paste Image 2, Screen Width()/2-150, Screen Height()/2-250
Center Text 35, 0, "MouseX: " + STR$(MouseX())
Center Text 35, 25, "MouseY: " + STR$(MouseY())
` Animate and enable menu.
` 0) Change if mouse is not over an option.
If MouseY < 738 Then Paste Image 1, 0, 698
` 1) NEW
If MouseX() > 97 and MouseX() < 191
If MouseY() > 700 and MouseY() < 738
Paste Image 3, 0, 698
If MouseClick()=1
` Clear and return.
For DelImg = 1 To 6
Delete Image DelImg
Next DelImg
Return
EndIf
EndIf
EndIf
` 2) STORY
If MouseX() > 287 and MouseX() < 420
If MouseY() > 700 and MouseY() < 738
Paste Image 4, 0, 698
If MouseClick()=1
EndIf
EndIf
EndIf
` 3) CREDITS
If MouseX() > 531 and MouseX() < 691
If MouseY() > 700 and MouseY() < 738
Paste Image 5, 0, 698
If MouseClick()=1
EndIf
EndIf
EndIf
` 4) EXIT
If MouseX() > 799 and MouseX() < 880
If MouseY() > 700 and MouseY() < 738
Paste Image 6, 0, 698
If MouseClick()=1
EndIf
EndIf
EndIf
Sync
Loop
Return