Okay, here's my entire code. Apart from the player model itself, everything should be in working order.
I changed the player model to a cone for you.
Most non-essential code covering other things has been removed.
graphicsX = 1280
graphicsY = 1024
Graphics3D graphicsX, graphicsY, 32, 1
SetBuffer = BackBuffer()
AntiAlias True
WBuffer True
frameTimer = CreateTimer(60)
Type userType
Field currentMode$
End Type
user.userType = New userType
user\currentMode = "FreeCamera"
Type weaponType
Field xOffset#, yOffset#, zOffset#, weaponName$, charge#, requiredCharge#, ammunition, heat#, hitPoints#, model
End Type
Type fighterType
Field model, speed#, inertiaRating#, primaryWeapon.weaponType
End Type
player.fighterType = New fighterType
player\primaryWeapon.weaponType = New weaponType
Type laserType
Field pivot, sprite, colour$, status$, speed#, damage#, range#, distanceTravelled#
Field x#, y#, z#, x2#, y2#, z2#, cx#, cy#, cz#, tx#, ty#, tz#, vx#, vy#, vz#
End Type
Dim laserArray.laserType(9999)
For i = 0 To 9999
laserArray(i) = New laserType
laserArray(i)\status = "Dead"
Next
BlueLaserSprite = LoadSprite("C:\Documents and Settings\James Robinson\Desktop\Stuff\Blitz and Idea\Blitz3D\MY PROGRAMS\Star Wars\Sprites and Textures\BlueLaser.bmp", 1+8+16+32)
Gosub LoadAllModels
; Create required pivots
masterPivot = CreatePivot()
PositionEntity masterPivot, 0, 0, -120000
cameraPivot = CreatePivot(masterPivot)
playerPivot = CreatePivot(masterPivot)
; Create Player
player\model = createcone(8, True, playerPivot)
; The player model should point towards the star initially.
PositionEntity player\model, EntityX(masterPivot), EntityY(masterPivot), EntityZ(masterPivot)
EntityParent player\model, playerPivot
; Important! All game models are hidden initially.
ShowEntity player\model
; Create a camera and make cameraPivot the parent of the camera.
camera = CreateCamera(cameraPivot)
TranslateEntity camera, 0, 0, -30
CameraRange camera, 1, 99999999999
; Create a light.
light = CreateLight()
RotateEntity light, 90, 0, 0
; Create a star and define a pivot to orbit the planets around.
star = CreateSphere(32)
PositionEntity star, 0, 0, 0
EntityColor star, 255, 150, 0
ScaleEntity star, 60000, 60000, 60000
; Hide mouse pointer and move to screen center initially.
HidePointer
MoveMouse 640, 512
While Not KeyDown(1)
WaitTimer(frameTimer)
; Make player's ship move
Gosub playerMovement
; Fire Player's Primary Weapons
If MouseHit(1)
Gosub playerPrimaryWeapons
EndIf
; Keep Track of all Weapons
Gosub Weapons
; Change Ship Control Mechanism
If MouseHit(2)
If user\currentMode = "FreeCamera"
user\currentMode = "MousePilot"
ElseIf user\currentMode = "MousePilot"
user\currentMode = "FreeCamera"
EndIf
EndIf
; Allows rotation of the camera around the player with the mouse.
Gosub cameraRotate
; Allow turning of ship with mouse
If user\currentMode = "MousePilot"
Gosub MousePilot
EndIf
RenderWorld
Flip True
Wend
End
.playerMovement
; A to increase speed
If KeyDown(30)
player\speed = player\speed + 1
EndIf
; Z to decrease speed
If KeyDown(44)
player\speed = player\speed - 1
EndIf
; SHIFT-A to enter cruise mode
If KeyDown(30) And KeyDown(42)
player\speed = 500
EndIf
; SHIFT-Z for emergency stop
If KeyDown(44) And KeyDown(42)
player\speed = 0
EndIf
TranslateEntity masterPivot, -player\speed*Sin(EntityYaw(playerPivot)), -player\speed*Sin(EntityPitch(playerPivot)), player\speed*Cos(EntityYaw(playerPivot))
Return
.MousePilot
If EntityYaw(cameraPivot) >= 0 And EntityYaw(playerPivot) >= 0
If EntityYaw(cameraPivot) > EntityYaw(playerPivot) + 1
TurnEntity playerPivot, 0, 1/player\inertiaRating, 0
ElseIf EntityYaw(cameraPivot) < EntityYaw(playerPivot) - 1
TurnEntity playerPivot, 0, -1/player\inertiaRating, 0
EndIf
ElseIf EntityYaw(cameraPivot) < 0 And EntityYaw(playerPivot) < 0
If EntityYaw(cameraPivot) > EntityYaw(playerPivot) + 1
TurnEntity playerPivot, 0, 1/player\inertiaRating, 0
ElseIf EntityYaw(cameraPivot) < EntityYaw(playerPivot) - 1
TurnEntity playerPivot, 0, -1/player\inertiaRating, 0
EndIf
ElseIf EntityYaw(cameraPivot) >= 0 And EntityYaw(playerPivot) < 0
If EntityYaw(cameraPivot) - EntityYaw(playerPivot) > 180
TurnEntity playerPivot, 0, -1/player\inertiaRating, 0
Else
TurnEntity playerPivot, 0, 1/player\inertiaRating, 0
EndIf
ElseIf EntityYaw(cameraPivot) < 0 And EntityYaw(playerPivot) >= 0
If EntityYaw(playerPivot) - EntityYaw(cameraPivot) > 180
TurnEntity playerPivot, 0, 1/player\inertiaRating, 0
Else
TurnEntity playerPivot, 0, -1/player\inertiaRating, 0
EndIf
EndIf
If EntityPitch(playerPivot) > EntityPitch(cameraPivot) + 1
TurnEntity playerPivot, -1/player\inertiaRating, 0, 0
ElseIf EntityPitch(playerPivot) < EntityPitch(cameraPivot) - 1
TurnEntity playerPivot, 1/player\inertiaRating, 0, 0
EndIf
Return
.Weapons
For i = 0 To 9999
If laserArray(i)\status = "Alive"
TranslateEntity laserArray(i)\pivot, -laserArray(i)\speed*Sin(EntityYaw(laserArray(i)\pivot)), -laserArray(i)\speed*Sin(EntityPitch(laserArray(i)\pivot)), laserArray(i)\speed*Cos(EntityYaw(laserArray(i)\pivot))
laserArray(i)\x# = EntityX(laserArray(i)\pivot, True)
laserArray(i)\y# = EntityY(laserArray(i)\pivot, True)
laserArray(i)\z# = EntityZ(laserArray(i)\pivot, True)
laserArray(i)\x2# = EntityX(camera, True)
laserArray(i)\y2# = EntityY(camera, True)
laserArray(i)\z2# = EntityZ(camera, True)
laserArray(i)\cx# = laserArray(i)\x# - laserArray(i)\x2#
laserArray(i)\cy# = laserArray(i)\y# - laserArray(i)\y2#
laserArray(i)\cz# = laserArray(i)\z# - laserArray(i)\z2#
TFormVector 0,0,0, laserArray(i)\pivot,0
laserArray(i)\tx# = TFormedX()
laserArray(i)\ty# = TFormedY()
laserArray(i)\tz# = TFormedZ()
laserArray(i)\vx# = laserArray(i)\cy# * laserArray(i)\tz# - laserArray(i)\cz# * laserArray(i)\ty#
laserArray(i)\vy# = laserArray(i)\cz# * laserArray(i)\tx# - laserArray(i)\cx# * laserArray(i)\tz#
laserArray(i)\vz# = laserArray(i)\cx# * laserArray(i)\ty# - laserArray(i)\cy# * laserArray(i)\tx#
AlignToVector(laserArray(i)\sprite, laserArray(i)\vx#, laserArray(i)\vy#, laserArray(i)\vz#, 1)
AlignToVector(laserArray(i)\sprite, laserArray(i)\tx#, laserArray(i)\ty#, laserArray(i)\tz#, 2)
EndIf
Next
Return
.playerPrimaryWeapons
i = 0
Repeat
If laserArray(i)\status = "Dead"
; Speed and other variables should be set here, determined by what weapon is firing.
laserArray(i)\status = "Alive"
laserArray(i)\speed = 0.1
laserArray(i)\pivot = CreatePivot()
PositionEntity laserArray(i)\pivot, EntityX(masterPivot), EntityY(masterPivot), EntityZ(masterPivot)
RotateEntity laserArray(i)\pivot, EntityPitch(playerPivot), EntityYaw(playerPivot), 0
;Set Up Laser Sprite
laserArray(i)\sprite = CopyEntity(BlueLaserSprite)
SpriteViewMode laserArray(i)\sprite, 4
ScaleSprite laserArray(i)\sprite, 1, 10
EntityFX laserArray(i)\sprite, 17
EntityParent laserArray(i)\sprite, laserArray(i)\pivot, False
Exit
Else
i = i + 1
EndIf
Forever
i = 0
Return
.cameraRotate
; zoom camera in
If KeyDown(78)
TranslateEntity camera, 0, 0, 0.1
EndIf
; zoom camera out
If KeyDown(74)
TranslateEntity camera, 0, 0, -0.1
EndIf
; Ensure that the mouse never leaves the screen bounds.
If ( MouseX() > 1200 ) Or ( MouseX() < 50 ) Or ( MouseY() > 1000 ) Or ( MouseY() < 50 ) Then
MoveMouse 640, 512
EndIf
; Turn cameraPivot, thus making camera spin around it. Note that the vertical speed is set
; to be less than the horizontal speed.
TurnEntity cameraPivot, MouseYSpeed() / 1.5, -MouseXSpeed(), 0
; Always keep cameraPivot's roll 0 wrt the horizontal plane.
RotateEntity cameraPivot, EntityPitch(cameraPivot), EntityYaw(cameraPivot), 0
Return