So how does one shoot an arrow in a blitz game???
-RZ
-RZ
; Gnash v1.alpha ; Ralph Dunn ; ------------------- Graphics3D 800,600 SetBuffer BackBuffer() SeedRnd (MilliSecs()) campiv = CreatePivot() camera = CreateCamera(campiv) floorpivot=CreatePivot() PositionEntity camera,0,140,0 CameraRange camera,.1,1500 CameraFogRange camera,10,1300 EntityRadius camera,5,49 EntityType camera,1 Global windnoise ; -------------- HidePointer ;setup lighting light=CreateLight() RotateEntity light,45,45,0 AmbientLight 48,48,48 ; was 32,32,32 ; Load Sound for backmusic windnoise=LoadSound("media/windlow.ogg") LoopSound windnoise terr=LoadTerrain("textures\hmap_1024.bmp") ScaleEntity terr,25,400,25 PositionEntity terr,-20*512,0,-20*512 EntityFX terr,1 EntityType terr,2 ;Load terrain ;apply textures To terrain tex1=LoadTexture( "textures\coolgrass1.bmp",1 ) ScaleTexture tex1,10,10 tex2=LoadTexture( "textures\lmap_256.bmp" ) ; i like a nice set of colors ScaleTexture tex2,TerrainSize(terr),TerrainSize(terr) EntityTexture terr,tex1,0,0 EntityTexture terr,tex2,0,1 ; Draw the Aimpoint where the TEXT goes or you never see it aim=LoadImage("textures\aimpoint2.png") ;create cloud planes cloud=LoadTexture( "textures\cloud_2.bmp",3) ScaleTexture cloud,1000,1000 p=CreatePlane() EntityTexture p,cloud EntityFX p,1 PositionEntity p,0,900,0 p=CopyEntity( p ) RotateEntity p,0,0,180 ;create water plane tex=LoadTexture( "textures\wawa1.bmp",3 ) ScaleTexture tex,128,128 p=CreatePlane() EntityTexture p,tex EntityBlend p,1 EntityAlpha p,.75 PositionEntity p,0,41,0 EntityFX p,1 ;EntityType p,2 ;create ground plane in case someone goes off map tex=LoadTexture( "textures\mossyground1.jpg",3 ) ScaleTexture tex,128,128 p2=CreatePlane() EntityTexture p2,tex EntityBlend p2,1 EntityAlpha p2,.75 PositionEntity p2,0,1,0 EntityFX p2,1 EntityType p2,2 ;cool castle castle=LoadMesh( "textures\tower1.b3d" ) PositionEntity castle,418,125,809 EntityFX castle,0 EntityType castle,2 EntityPickMode castle,2 UpdateNormals castle TurnEntity castle,0,164,0 ScaleEntity castle,18,30,18 ;lil dingy boat=LoadMesh( "textures\smallboat.b3d" ) PositionEntity boat,74,3,-267 EntityFX boat,0 EntityType boat,2 EntityPickMode boat,3 UpdateNormals boat TurnEntity boat,0,0,0 ScaleEntity boat,2,2,2 ; Load Xbow xbow=LoadAnimMesh("textures\xbow1.b3d",camera) ScaleEntity xbow,.8,.8,.8 RotateEntity xbow,90,0,190 PositionEntity xbow,2,-2,8 ; load xbow ammo bolt=LoadMesh("textures\xbowbolt.b3d",camera) ScaleEntity bolt,.8,.8,.8 RotateEntity bolt,0,180,0 PositionEntity bolt,2,-2,8 newbolt=CopyEntity(bolt) CameraFogColor camera, 2, 2, 2 CameraFogMode camera,1 Collisions 1,2,2,3 Collisions 1,3,2,3 jumpflag=False j#=1 PlaySound windnoise While Not KeyDown( 1 ) mxs#=MouseXSpeed()/4 mys#=MouseYSpeed()/4 xa#=(xa#-mxs#)Mod 360 ya#=(ya#+mys#)Mod 360 ;limit up and down looking If ya#>=90 Then ya#=90 If ya#<= -89 Then ya#= -89 MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 RotateEntity camera,ya#,xa#,0 ; ------------------------------------------------------------------------------------- If KeyDown( 205 )=True Then RotateEntity camera,0,-5,0 If KeyDown( 203 )=True Then RotateEntity camera,0,+5,0 If KeyDown( 208 )=True Then MoveEntity camera,0,0,-5 If KeyDown( 200 )=True Then MoveEntity camera,0,0,5 If MouseHit (1) = True Then Animate xbow,3 newbolt=CopyEntity(bolt):PositionEntity newbolt,x#,y#,z#:RotateEntity newbolt,EntityPitch (camera),EntityYaw (camera),0 PositionEntity newbolt,x#,y#,z#+1 If KeyHit( 57 )=True And jumpflag = False jumpflag=True oldtime=MilliSecs() EndIf If jumpflag = True Then TranslateEntity camera,+0,+9,+0 If MilliSecs()>oldtime+1250 Then jumpflag=False x#=EntityX(camera) y#=EntityY(camera) z#=EntityZ(camera) ; ---- HOW TO USE GRAVITY y#=y#-8 ; ------------------ PositionEntity camera,x#,y#,z# UpdateWorld() RenderWorld() Text 0,0,"Use cursor keys to move about the terrain [ESC] to quit" Text 0,10,"Jumpflag:"+jumpflag Text 0,30,"X: "+x# Text 100,30,"Y: "+y# Text 200,30,"Z: "+z# DrawImage aim,400,300 Flip Wend EndI figure one of you bright boys can see what I done wrong... The program draws a new BOLT everyplac I move... kind of like pacman in reverse. No fire effect... nada!
; load xbow ammo bolt=LoadMesh("textures\xbowbolt.b3d",camera) ScaleEntity bolt,.8,.8,.8 RotateEntity bolt,0,180,0 PositionEntity bolt,2,-2,9 newbolt=CopyEntity(bolt) ; create a type Type mybolt Field entityhandle End Type ; HEALTHwidget health=LoadMesh("textures\healthbar2.b3d",camera) ScaleEntity health,.5,.5,.5 PositionEntity health,-4,-2,4 CameraFogColor camera, 2, 2, 2 CameraFogMode camera,1 Collisions 1,2,2,3 Collisions 1,3,2,3 jumpflag=False j#=1 PlaySound windnoise healthy#=1 While Not KeyDown( 1 ) mxs#=MouseXSpeed()/4 mys#=MouseYSpeed()/4 xa#=(xa#-mxs#)Mod 360 ya#=(ya#+mys#)Mod 360 ;limit up and down looking If ya#>=90 Then ya#=90 If ya#<= -89 Then ya#= -89 MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 RotateEntity camera,ya#,xa#,0 ; ------------------------------------------------------------------------------------- If KeyDown (209)=True Then healthy#=healthy#-.1: ScaleEntity health,healthy#,.5,.5 If KeyDown (201)=True Then healthy#=healthy#+.1: ScaleEntity health,healthy#,.5,.5 If KeyDown( 205 )=True Then RotateEntity camera,0,-5,0 If KeyDown( 203 )=True Then RotateEntity camera,0,+5,0 If KeyDown( 208 )=True Then MoveEntity camera,0,0,-5 If KeyDown( 200 )=True Then MoveEntity camera,0,0,5 If MouseDown (1) = True Then If MouseHit(1) Then If Animating(xbow)=0 Then Animate xbow,3 newbolt.mybolt=New mybolt ;I GET THE MISMATCH JUST BEFORE THIS LINE! newbolt\entityhandle=CopyEntity(bolt) PositionEntity newbolt\entityhandle,x,y,z RotateEntity newbolt\entityhandle,EntityPitch(camera),EntityYaw(camera),0 FlushMouse EndIf If KeyDown ( 15 ) = True Then entity = EntityPick(camera,100) Select entity Case Adoor Animate Adoor,3 : EntityType Adoor,0 Default hh=0 End Select EntityType Adoor,2 If KeyHit( 57 )=True And jumpflag = False jumpflag=True oldtime=MilliSecs() EndIf If jumpflag = True Then TranslateEntity camera,+0,+9,+0 If MilliSecs()>oldtime+1250 Then jumpflag=False x#=EntityX(camera) y#=EntityY(camera) z#=EntityZ(camera) speed#=2 For newbolt.mybolt=Each mybolt MoveEntity newbolt\entityhandle,0,0,Speed# Next ; ---- HOW TO USE GRAVITY y#=y#-8I am confused by the "." as well... I don't see the "." in the type examples in B3D. Type is a little confusing to me!
newbolt=CopyEntity(bolt)
If Animating(xbow)=0 Then Animate xbow,3 newbolt.mybolt=New mybolt
If MouseDown (1) = True Then If MouseHit(1) Then If Animating(xbow)=0 Then Animate xbow,3 newbolt.mybolt=New mybolt
If Mousehit (1) = True Then If Animating(xbow)=0 Then Animate xbow,3 newbolt.mybolt=New mybolt End if
Graphics 800,600 SetBuffer BackBuffer() x=100 y=100 While Not KeyHit(1) Cls If KeyHit(205) then x=x+1 If x>700 then x=x-1 End If ElseIf KeyHit(203) then x=x-1 If x<50 then x=x+1 End If End If Rect x,y,5,5 Flip Wend End
Graphics 800,600 SetBuffer BackBuffer() x=100 y=100 While Not KeyHit(1) Cls If KeyHit(205) then x=x+1 If x>700 then x=x-1 End If ElseIf KeyHit(203) then x=x-1 If x<50 then x=x+1 End If End If Rect x,y,5,5 Flip Wend End
Graphics3D 800,600 SetBuffer BackBuffer() Global cam=CreateCamera() PositionEntity cam,0,0,-5 Global light=CreateLight() Global gun=CreateCube() ScaleEntity gun,0.3,0.3,3 PositionEntity gun,1,-1,0 Global main_bullet=CreateSphere(); create a bullter that the type objects can copy. ScaleEntity main_bullet,0.3,0.3,0.3 HideEntity main_bullet Type bullet Field entity Field speed# Field range Field pivot End Type Global gun_timer=MilliSecs() ; timer to track the difference in millisecs Global gun_time=200; time in milliseconds that the gun will fire While Not KeyHit(1) If MouseDown(1) And MilliSecs()>gun_time+gun_timer Then gun_timer=MilliSecs() ; reset the timer create_bullet(gun); call function to create a bullet. Pass across the gun entity to the function ; so the bullet can come from the guns position End If update_bullet() UpdateWorld RenderWorld Flip Wend End Function create_bullet(gun_entity) b.bullet=New bullet temp_x=EntityX(gun_entity,True) temp_y=EntityY(gun_entity,True) temp_z=EntityZ(gun_entity,True) b\entity=CopyEntity(main_bullet) ; copy the main bullet entity , into the type object b\pivot=CreatePivot() PositionEntity b\entity,temp_x,temp_y,temp_z RotateEntity b\entity,EntityPitch(gun_entity,True),EntityYaw(gun_entity,True),0 PositionEntity b\pivot,temp_x,temp_y,temp_z b\range=40 ; the range of the bullets b\speed=1 ; the speed of the bullets End Function Function update_bullet() For b.bullet = Each bullet MoveEntity b\entity,0,0,b\speed If EntityDistance#(b\entity,b\pivot) > b\range Then FreeEntity b\entity FreeEntity b\pivot Delete b.bullet End If Next End Function