Game Compass


Tweet blitz3d hud code-archives miscellaneous
(Posted 4 months ago) RonTek

Another way to include a compass in your game Very simple example of implementing a compass. Hope you learn something from it!

Author: stayne

Image

Graphics3D 640,480,0,2
SetBuffer BackBuffer() 

camera=CreateCamera() 

light=CreateLight() 
RotateEntity light,90,0,0 

cube=CreateCube() 
PositionEntity cube,0,0,5 
EntityColor cube,255,242,99
EntityFX cube,1

compass = CreateSprite()
ScaleSprite compass,1,.1
PositionEntity compass,0,2,3

tex=CreateTexture(128,18) 
SetBuffer TextureBuffer(tex) 
ClsColor 0,0,255 
Cls
font=LoadFont("verdana",19) 
SetFont font 
Color 255,255,255
Text 0,0,"N | E | S | W |"

EntityTexture compass,tex 
SetBuffer BackBuffer()

While Not KeyDown(1)

    compassrot# = EntityYaw(cube)

    If compassrot# < 0 Then compassrot# = compassrot# + 360

    PositionTexture tex,compassrot#/360,0

    TurnEntity cube,0,-MouseXSpeed(),0

    MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

    RenderWorld()

    Flip

Wend 

End

Reply To Topic (minimum 10 characters)

Please log in to reply