Thanks Klepto.
OK , here you go. The water volume in the cylinder will continuously decrease, when it gets toa certain point it will turn red. The idea is a visual representation of something (health, water, mana , sexual potency , whatever. depends on the game (although I am not sure I want to see a sexual potency icon !) )
The idea is to be creative and make a symbol that is consistent with the them of your game and conveys alot of meaning ( a picture *can be* worth a thousand words)
Import sidesign.MiniB3D
Strict
Global width:Int = 1024 , height# = 768
Global midw:Int = width / 2
Global Midh:Int = height / 2
Graphics3D width,height,32,0
ClearTextureFilters
' Just create a bunch of WORLD stuff to look at
Local box:Tentity
For Local x:Int = 1 To 10
For Local z:Int = 1 To 10
box = CreateCube()
EntityColor box , Rnd(0,200) , Rnd(0,200) , Rnd(0,200)
PositionEntity box , x*5 , Rnd(0,20) , z*5
EntityType box,2
Next
Next
box = CreateCube()
ScaleEntity box,240,0.5,240
EntityColor box , Rnd(0,200) , Rnd(0,200) , Rnd(0,200)
PositionEntity box ,-120,0,-120
EntityType box ,2
' create the player
Local player:TPlayer = Tplayer.create()
' set up collisions between the Player and the World
Collisions(1,2,2,2)
' Main Loopski
Repeat
player.update()
UpdateWorld
RenderWorld
Flip
Until KeyHit(KEY_ESCAPE)
Type Tplayer
Field Entity3d:TEntity ' the Player's pivot
Field cam:Tentity ' the Player Camera
Field HUDweapon:Tentity
Field HUDweaponTex:TTexture
Field HUD3D:Tentity ' the HUD 3D Model
Field HUD3DVolume:Tentity ' this is the Water Volume insdie the cylinder
Field Volume:Float ' the amount of liquid in the Cylinder
Field playermesh:Tentity
Field HudTex:TTexture
Field HUDcam:Tcamera
Field xvel:Float , yvel:Float , zvel:Float
Field xpos:Float , ypos:Float , zpos:Float
Field xScale:Float , yScale:Float , zScale:Float
Field Pitch:Float , yaw:Float , Roll:Float
Field Camspeed:Float = 0.33
Field CamSteps:Int = 8
Field mxs:Float
Field mys:Float
Field move:Float
Field yspeed#
Field lateral#
Field thrust#=0.01
Method Update()
Get_Input()
MovePlayer()
Water_Volume()
End Method
Method Water_Volume()
TurnEntity HUD3D , 0 , 0.4 , 0
Local change:Float = 0.0001
volume:-change
If volume<0.1 Then EntityColor HUD3DVolume,255,0,0
ScaleEntity HUD3DVolume , HUD3DVolume.entityscalex(True) , Volume , HUD3DVolume.entityscalez(True) , True
MoveEntity Hud3DVolume , 0 , -change*2 , 0
End Method
Method Get_Input()
mxs# = smooth(MouseXSpeed()*Camspeed,mxs,Camsteps)
mys# = smooth(MouseYSpeed()*Camspeed,mys,Camsteps)
yaw = EntityYaw(Entity3D)-mxs
pitch = EntityPitch(cam,1)+mys
MoveMouse midw,midh
MouseXSpeed() ' flush
MouseYSpeed() ' flush
If KeyDown(KEY_W) Or KeyDown(KEY_UP)=True Then move#:+thrust ' move camera forward
If KeyDown(KEY_S) Or KeyDown(KEY_DOWN)=True Then move#:-thrust' move camera back
If KeyDown(KEY_A) Or KeyDown(KEY_LEFT)=True Then lateral:-thrust' move camera left
If KeyDown(KEY_D) Or KeyDown(KEY_RIGHT)=True Then lateral:+thrust'move camera Right
End Method
Method MovePlayer()
RotateEntity Entity3D,0,yaw,0 ' turn
RotateEntity cam,pitch,0,0 ' rotate the camera up/down
MoveEntity Entity3D,lateral#,yspeed#,move#
' convert movements into x,y,z velocities
' this is useful for firing weapons, etc. (not used in this demo but nice to have)
xvel = -Sin(EntityYaw(Entity3D)) * move
zvel = Cos(EntityYaw(Entity3D)) * move
move:*0.99 ' slow down (friction)
lateral:*0.99
yspeed=-0.3 ' a constant downward pull to simulate gravity
End Method
Function Create:Tplayer()
Local temp:Tplayer = New Tplayer
temp.Entity3D = CreatePivot() ' THe Player pivot (for Y Rotation...left right)
temp.playermesh = CreateCone(6,1,temp.Entity3D) ' the Visible Triangle on the MAP
ScaleEntity temp.playermesh,4,4,4
EntityColor temp.playermesh , 255,255,0
TurnEntity temp.playermesh , 90 , 0 , 0
' This is the camera we see out of the players eyes with
temp.cam = CreateCamera(temp.Entity3D)
CameraRange Tcamera(temp.cam),0.1 , 1000
' Create the 3D Cylinder HUD object.
temp.HUD3D = CreateCylinder(8,1,temp.cam) ' parent the MAP sprite to the Camera
'RotateEntity temp.HUD,0,0,0
'FlipMesh tmesh(temp.HUD)
EntityColor temp.HUD3D , 0,200,0 ' Green
PositionEntity temp.HUD3D,-0.95,0.65, 1.25
EntityAlpha temp.HUD3D,0.65
ScaleEntity temp.HUD3D , 0.2,0.2,0.2
' Create the 3D Cylinder Volume Object that will be our visual referenc for Health
temp.HUD3DVolume = CreateCylinder(8,1,temp.HUD3D)
EntityColor temp.HUD3DVolume , 0,00,100 ' Blue
EntityAlpha temp.HUD3DVolume,0.75
ScaleEntity temp.HUD3DVolume , 0.175,0.175,0.175,1
temp.Volume = 0.175
' this is a special camera that we will use to render the HUD MAP
temp.HUDCam:Tcamera =CreateCamera()
RotateEntity temp.HUDCam,90,0,0
PositionEntity temp.HUDCam,0,20,0
CameraViewport temp.HUDCam,0,0,128,128
CameraClsColor temp.HUDCam,0,0,0
'CameraZoom temp.HUDcam,0.75
CameraClsColor temp.HUDCam , 0, 0, 200
CameraClsMode temp.HUDCam,False,True
' *** Create the HUD Weapon Sprite. you could put a picture of the current weapon here
temp.HUDweapon = CreateSprite(temp.cam) ' parent the WEAPON sprite to the camera
ScaleSprite TSprite(temp.HUDweapon) , 0.25, -0.25
FlipMesh tmesh(temp.HUDweapon)
PositionEntity temp.HUDweapon,1,1, 1.75
EntityAlpha temp.HUDweapon,0.75
'*** Create And render To the texture
temp.Hudweapontex = CreateTexture(128,128)
EntityTexture temp.HUDweapon , temp.HUDweaponTex
HideEntity temp.cam
ShowEntity temp.HUDcam
Cls
RenderWorld
text 32,64,"WEAPON"
BackBufferToTex(temp.HUDweapontex)
HideEntity temp.HUDcam
ShowEntity temp.cam
' For COLLISIONS command
EntityType temp.Entity3D , 1 ' set the Palyer entity type to 1
EntityRadius temp.Entity3D, 1.1 , 1.75
' finally position the player a little 'up' so he does not fall through the world
PositionEntity temp.entity3D , 0 , 4 , 0
Return temp
End Function
End Type
' this is just to reduce the jerkiness of the FPS camera.
Function Smooth#(newVal#,oldval#,steps )
' this is used for mouselook smoothing
If steps >1 Then oldval#=oldval#-(oldval#-newval#)/steps
If steps <=1 Then oldval=newval
Return oldval#
End Function