Well...
Ross C helped me alot with types and bullets etc., but it seems that the bullets are now, kinda, going backwards....
I just can't figure this out. I know it's probably something blindingly obvious but....
Please can someone help me out?
;;;;;;;;;;;;;;;;;;;;;;
Graphics3D 640,480
SetBuffer BackBuffer()
AmbientLight 170,170,170
;;;;;;;;;;;;;;;;;;;;;;
Global main_bullet=CreateSphere()
ScaleEntity main_bullet,0.16,0.16,0.16
bullet_tex=LoadTexture( "C:/3dgame/bullet_tex.bmp" )
EntityAlpha main_bullet,0.5
EntityTexture main_bullet,bullet_tex
HideEntity main_bullet
Type bullet
Field ent
Field x#,y#,z#
Field speed#
Field time
Field timer
Field alpha
End Type
;;;;;;;;;;;;;;;;;;;;;;
grasstex=LoadTexture( "C:/3dgame/grasstex.bmp" )
playertex=LoadTexture( "C:/3dgame/playertex.bmp" )
plane=CreatePlane()
plane_tex=LoadTexture( "C:/3dgame/watertex.bmp" )
EntityTexture plane,plane_tex
PositionEntity plane,0,-100,0
EntityAlpha plane,1
player=LoadMesh( "C:/3dgame/player.3ds" )
RotateEntity player,0,0,0
Global piv=CreatePivot(player)
EntityTexture player,playertex
ScaleEntity player,0.2,0.2,0.2
MoveEntity piv,0,-5,0
Global cam=CreateCamera()
me=1
walls=2
nodec=3
EntityType player,me
EntityType plane,walls
Type wall
Field entity
End Type
Collisions me,walls,3,1
;;;;;;;;;;;;;;;;;;;;;
While Not KeyHit(1)
updatebullet
If KeyDown (203) Then TurnEntity player,0,0.75,0 ;turn player left
If KeyDown(205) Then TurnEntity player,0,-0.75,0 ;turn player right
If KeyDown(200) Then playerspeed=playerspeed+0.1 ;speed up player
If KeyDown(208) Then playerspeed=playerspeed-0.1 ;slow down player
If KeyDown(30) Then MoveEntity player,0,0.5,0 MoveEntity cam,0,0.5,0 ;move player up
If KeyDown(44) Then MoveEntity player,0,-0.5,0 MoveEntity cam,0,-0.5,0 ;move player down
If playerspeed>3 Then playerspeed=3
If playerspeed<1 Then playerspeed=1
If KeyHit(45) Then
createbullet(player)
EndIf
MoveEntity player,0,0,playerspeed
smoothcam(piv,player,70)
if entitycollided(player,nodec)
print "<< You got a node! >>"
nodes=nodes+1
endif
RenderWorld
UpdateWorld
Flip
Wend
End
;;;;;;;;;;;;;;;;;;;;;;
Function smoothcam(pivot,target,camspeed)
curx#=EntityX(cam)
curz#=EntityZ(cam)
destx#=EntityX(pivot,True)
destz#=EntityZ(pivot,True)
curx#=curx#+((destx#-curx#)/camspeed)
curz#=curz#+((destz#-curz#)/camspeed)
cury#=0.75
PositionEntity cam,curx#,cury#,curz#
PointEntity cam,target
End Function
;;;;;;;;;;;;;;;;;;;;;;
Function createbullet(player)
b.bullet=New bullet
b\ent=CopyEntity (main_bullet)
b\x=EntityX(player)
b\z=EntityZ(player)
b\y=EntityY(player)+2
TurnEntity b\ent,EntityPitch(player),EntityYaw(player),EntityRoll(player)-180
PositionEntity b\ent,b\x,b\y,b\z
b\speed=0.2
b\time=6000
b\timer=MilliSecs()
b\alpha=1
End Function
Function updatebullet()
For b.bullet=Each bullet
MoveEntity b\ent,0,0,b\speed
If MilliSecs()>b\time+b\timer Then
FreeEntity b\ent
Delete b.bullet
End If
Next
End Function
;;;;;;;;;;;;;;;;;;;;;;
Ross C helped me alot with types and bullets etc., but it seems that the bullets are now, kinda, going backwards....
I just can't figure this out. I know it's probably something blindingly obvious but....
Please can someone help me out?
;;;;;;;;;;;;;;;;;;;;;;
Graphics3D 640,480
SetBuffer BackBuffer()
AmbientLight 170,170,170
;;;;;;;;;;;;;;;;;;;;;;
Global main_bullet=CreateSphere()
ScaleEntity main_bullet,0.16,0.16,0.16
bullet_tex=LoadTexture( "C:/3dgame/bullet_tex.bmp" )
EntityAlpha main_bullet,0.5
EntityTexture main_bullet,bullet_tex
HideEntity main_bullet
Type bullet
Field ent
Field x#,y#,z#
Field speed#
Field time
Field timer
Field alpha
End Type
;;;;;;;;;;;;;;;;;;;;;;
grasstex=LoadTexture( "C:/3dgame/grasstex.bmp" )
playertex=LoadTexture( "C:/3dgame/playertex.bmp" )
plane=CreatePlane()
plane_tex=LoadTexture( "C:/3dgame/watertex.bmp" )
EntityTexture plane,plane_tex
PositionEntity plane,0,-100,0
EntityAlpha plane,1
player=LoadMesh( "C:/3dgame/player.3ds" )
RotateEntity player,0,0,0
Global piv=CreatePivot(player)
EntityTexture player,playertex
ScaleEntity player,0.2,0.2,0.2
MoveEntity piv,0,-5,0
Global cam=CreateCamera()
me=1
walls=2
nodec=3
EntityType player,me
EntityType plane,walls
Type wall
Field entity
End Type
Collisions me,walls,3,1
;;;;;;;;;;;;;;;;;;;;;
While Not KeyHit(1)
updatebullet
If KeyDown (203) Then TurnEntity player,0,0.75,0 ;turn player left
If KeyDown(205) Then TurnEntity player,0,-0.75,0 ;turn player right
If KeyDown(200) Then playerspeed=playerspeed+0.1 ;speed up player
If KeyDown(208) Then playerspeed=playerspeed-0.1 ;slow down player
If KeyDown(30) Then MoveEntity player,0,0.5,0 MoveEntity cam,0,0.5,0 ;move player up
If KeyDown(44) Then MoveEntity player,0,-0.5,0 MoveEntity cam,0,-0.5,0 ;move player down
If playerspeed>3 Then playerspeed=3
If playerspeed<1 Then playerspeed=1
If KeyHit(45) Then
createbullet(player)
EndIf
MoveEntity player,0,0,playerspeed
smoothcam(piv,player,70)
if entitycollided(player,nodec)
print "<< You got a node! >>"
nodes=nodes+1
endif
RenderWorld
UpdateWorld
Flip
Wend
End
;;;;;;;;;;;;;;;;;;;;;;
Function smoothcam(pivot,target,camspeed)
curx#=EntityX(cam)
curz#=EntityZ(cam)
destx#=EntityX(pivot,True)
destz#=EntityZ(pivot,True)
curx#=curx#+((destx#-curx#)/camspeed)
curz#=curz#+((destz#-curz#)/camspeed)
cury#=0.75
PositionEntity cam,curx#,cury#,curz#
PointEntity cam,target
End Function
;;;;;;;;;;;;;;;;;;;;;;
Function createbullet(player)
b.bullet=New bullet
b\ent=CopyEntity (main_bullet)
b\x=EntityX(player)
b\z=EntityZ(player)
b\y=EntityY(player)+2
TurnEntity b\ent,EntityPitch(player),EntityYaw(player),EntityRoll(player)-180
PositionEntity b\ent,b\x,b\y,b\z
b\speed=0.2
b\time=6000
b\timer=MilliSecs()
b\alpha=1
End Function
Function updatebullet()
For b.bullet=Each bullet
MoveEntity b\ent,0,0,b\speed
If MilliSecs()>b\time+b\timer Then
FreeEntity b\ent
Delete b.bullet
End If
Next
End Function
;;;;;;;;;;;;;;;;;;;;;;