OK posting code:
; Gnash v1.alpha
; Ralph Dunn
; June 10, 2004
; starting to come together
; -------------------
Graphics3D 800,600
SetBuffer BackBuffer()
SeedRnd (MilliSecs())
campiv = CreatePivot()
Global camera = CreateCamera(campiv)
floorpivot=CreatePivot()
PositionEntity camera,1466,200,410 ; 600,440,2000 - BUILDING 1466,200,410 - PAD
CameraRange camera,.1,1500
CameraFogRange camera,10,1300
EntityRadius camera,8,41
EntityType camera,1
Global gun_timer=MilliSecs() ; timer to track the difference in millisecs
Global gun_time=750 ; time in milliseconds that the gun will fire
Global ammo
Global rs
Global musicflag
Global whe
; --------------
;fileout=WriteFile("textures/putlight.dat")
HidePointer
;setup lighting
light=CreateLight()
RotateEntity light,45,45,0
AmbientLight 32,32,32 ; was 32,32,32
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= SOUND
; Load Sound for backmusic
Global windnoise=LoadSound("media/windlow.ogg")
LoopSound windnoise
firebow=LoadSound("media/click1.wav")
Global doorx=LoadSound("media/metaldoor.wav")
Global walk=LoadSound("media/walk2.ogg")
SoundPitch walk,18000
LoopSound walk
play_walk=PlaySound(walk)
annoy=LoadSound("media/heroloop2.ogg")
LoopSound annoy
Global play_annoy=PlaySound(annoy)
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= MAP
Global 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
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= AIMPOINT
S=LoadSprite("textures\aimpoint3.png",4,camera)
EntityOrder S,-1000
EntityBlend S,3
EntityParent S,camera,1
PositionEntity S,0,0,12
;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
Global w=CreatePlane()
EntityTexture w,tex
EntityType w,6
EntityPickMode w,2
EntityBlend w,1
EntityAlpha w,.75
PositionEntity w,0,39,0
EntityFX w,1
;EntityType p,2
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ENTITYS
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> FLAME
Global candle = CreateSprite()
Global flame = LoadAnimTexture("textures\flame.png",2,64,64,0,16)
;Global flamemask = LoadAnimTexture("textures\flamemask.png",2,64,64,0,16)
ScaleSprite candle,18,18 ; add 77 to mesh height
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;cool castle
Global castle=LoadMesh( "textures\tower1.b3d" )
PositionEntity castle,418,125,809
EntityFX castle,0
EntityType castle,2
UpdateNormals castle
TurnEntity castle,0,164,0
ScaleEntity castle,18,30,18
EntityPickMode castle,2
; BRAZIER
brazier=LoadMesh( "textures\brazier2.b3d" )
PositionEntity brazier,1395,190,731
EntityType brazier,2
UpdateNormals brazier
ScaleEntity brazier,2,2,2
EntityPickMode brazier,2
PositionEntity candle,1395,267,731
abra=CopyMesh(brazier)
ScaleEntity abra,2,2,2
PositionEntity abra,1613,185,725
can1=CopyEntity(candle)
PositionEntity can1,1613,267,725
bbra=CopyMesh(brazier)
ScaleEntity bbra,2,2,2
PositionEntity bbra,3500,270,2150
can2=CopyEntity(candle)
PositionEntity can2,3500,347,2150
cbra=CopyMesh(brazier)
ScaleEntity cbra,2,2,2
PositionEntity cbra,1885,400,2746
can3=CopyEntity(candle)
PositionEntity can3,1885,477,2746
dbra=CopyMesh(brazier)
ScaleEntity dbra,2,2,2
PositionEntity dbra,1780,400,2746
can4=CopyEntity(candle)
PositionEntity can4,1780,477,2746
;ebra=CopyMesh(brazier)
;ScaleEntity ebra,2,2,2
;PositionEntity ebra,1613,190,725
; GREAT HALL
Global ghall=LoadMesh( "textures\great_hall.b3d" )
PositionEntity ghall,3179,260,2458
EntityFX ghall,0
EntityType ghall,2
UpdateNormals ghall
TurnEntity ghall,0,164,0
ScaleEntity ghall,15,15,15
EntityPickMode ghall,2
; CRYPT
Global crypt=LoadMesh( "textures\portal2.b3d" )
PositionEntity crypt,1835,399,2872
EntityFX crypt,0
EntityType crypt,2
UpdateNormals crypt
TurnEntity crypt,0,0,0
ScaleEntity crypt,15,15,15
EntityPickMode crypt,2
; SWITCH
Global switch=LoadMesh( "textures\trigger1.b3d" )
PositionEntity switch,1835,399,2872
EntityFX switch,0
EntityAlpha switch,0
UpdateNormals switch
EntityType switch,4
TurnEntity switch,0,0,0
ScaleEntity switch,15,15,15
; CRYPT2
Global crypt2=LoadMesh( "textures\portal4.b3d" )
PositionEntity crypt2,1835,399,2872
EntityFX crypt2,0
EntityType crypt2,2
UpdateNormals crypt2
TurnEntity crypt2,0,0,0
ScaleEntity crypt2,15,15,15
HideEntity crypt2
; CRYPT3
Global crypt3=LoadMesh( "textures\crypt4.b3d" )
PositionEntity crypt3,1835,399,2872
EntityFX crypt3,0
EntityType crypt3,2
UpdateNormals crypt3
TurnEntity crypt3,0,0,0
ScaleEntity crypt3,15,15,15
HideEntity crypt3
;DOCK
Global dock=LoadMesh( "textures\dock_old.b3d" )
PositionEntity dock,950,80,116
EntityFX dock,0
EntityType dock,2
UpdateNormals dock
TurnEntity dock,0,180,0
ScaleEntity dock,18,18,18
EntityPickMode dock,2
;TELEPORT PAD
pad=LoadMesh( "textures\teleportpad1.b3d" )
PositionEntity pad,1466,150,410
EntityFX pad,0
EntityType pad,2
UpdateNormals pad
TurnEntity pad,0,0,0
ScaleEntity pad,5,5,5
EntityPickMode pad,2
Global pad2=LoadMesh( "textures\teleportpad1.b3d" )
PositionEntity pad2,949,-86,1949
EntityType pad2,2
UpdateNormals pad2
ScaleEntity pad2,5,5,5
; PAD 2 Trigger
Global switch2=LoadMesh( "textures\trigger1.b3d" )
PositionEntity switch2,950,-60,1949
EntityFX switch2,0
EntityAlpha switch2,0 ; was 0
UpdateNormals switch2
EntityType switch2,5
ScaleEntity switch2,25,25,25
HideEntity switch2
;WALL
Global wall=LoadMesh( "textures\gate3.b3d" )
PositionEntity wall,1190,175,837
EntityFX wall,0
EntityType wall,2
UpdateNormals wall
;TurnEntity wall,0,164,0
ScaleEntity wall,18,20,18
EntityPickMode wall,2
; PORTAL
Global portal=LoadMesh( "textures\0portal.b3d" )
PositionEntity portal,725,250,1957
EntityFX portal,0
EntityType portal,2
UpdateNormals portal
TurnEntity portal,0,0,0
ScaleEntity portal,25,25,25
EntityPickMode portal,2
;lil dingy
Global boat=LoadMesh( "textures\smallboat.b3d" )
PositionEntity boat,74,3,-267
EntityFX boat,0
EntityType boat,2
UpdateNormals boat
TurnEntity boat,0,0,0
ScaleEntity boat,2,2,2
;ladder
Global ladder=LoadMesh( "textures\ladder_1.b3d" )
PositionEntity ladder,570,251,2022
EntityFX ladder,0
EntityType ladder,2
EntityPickMode ladder,3
UpdateNormals ladder
TurnEntity ladder,0,180,0
ScaleEntity ladder,7,7,7
;DOOR animated
Global Adoor=LoadAnimMesh( "textures\door_cheap.b3d" )
PositionEntity Adoor,825,252,2180 ; 252
EntityFX Adoor,0
EntityType Adoor,2
EntityPickMode Adoor,2
EntityRadius Adoor,10
UpdateNormals Adoor
TurnEntity Adoor,0,0,0
ScaleEntity Adoor,6,8,7
;making new doors
;door2 = CopyMesh(Adoor)
;PositionEntity door2,800,252,2000
; TREE
dot=LoadMesh("textures\tree2.b3d")
HideEntity dot
UpdateNormals dot
EntityFX dot,2
Type tree
Field entity
Field treex
Field treey
Field treez
Field scale
End Type
; Load Xbow
Global gun=LoadAnimMesh("textures\xbow3.b3d",camera)
ScaleEntity gun,.8,.8,.8
PositionEntity gun,-.1,-4,8
; load xbow ammo
Global bolt=LoadMesh("textures\bolt6.b3d",gun)
PositionEntity bolt,-.05,-1,4
HideEntity bolt
; create a type
Type bullet
Field entity
Field speed#
Field range
Field pivot
End Type
; =-=-=-=-=-=-=-=-=-= QUIVERS
Global quiver=LoadMesh( "textures\quiver1.b3d" )
PositionEntity quiver,1172,380,1284
EntityFX quiver,0
EntityType quiver,8
EntityPickMode quiver,1
UpdateNormals quiver
Type reload
Field entity
Field rx
Field ry
Field rz
Field ammoplus
End Type
CameraFogColor camera, 2, 2, 2
CameraFogMode camera,1
Collisions 1,2,2,3
Collisions 2,1,2,3
Collisions 4,1,2,2
Collisions 5,1,2,2
Collisions 1,4,2,2
Collisions 1,5,2,2
Collisions 2,2,2,1
Collisions 2,6,2,2
Collisions 6,2,2,2
Collisions 8,1,2,1
Collisions 1,8,2,1
ammo = 3
jumpflag=False
j#=1
PlaySound windnoise
healthy#=1
current = MilliSecs()
chnWalk=PlaySound (mov)
For tt= 1 To 100 ; 1000 trees on the map??? Sure!
t.tree = New tree ; where did "T" come from... I made it up. I could
t\entity = CopyEntity (dot) ; have used a letter or any word not reserved
t\treex=Rnd(-100,5000) ; NOTE " \ " not " / "
t\treey=0
t\treez=Rnd(-500,5000)
t\scale=Rnd(.5,2) ; Since B3D uses both + and - nums I had to use Rnd
Next ;
For fm = 1 To 60
b.reload = New reload
b\entity = CopyEntity (quiver)
b\rx=Rnd(-100,4000)
b\ry=200
b\rz=Rnd(-100,4000)
b\ammoplus=Rnd(3,100)
Next
put_reload()
put_trees()
musicflag=1
ShowEntity bolt ; just shows the bolt initially
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX HERE
While Not KeyDown( 1 )
If rs=1 Then
PositionEntity camera,1466,220,412
ResetEntity camera
EndIf
rs=0
volume_walk=0
ChannelVolume play_walk,volume_walk
x#=EntityX(camera)
y#=EntityY(camera)
z#=EntityZ(camera)
; ---- HOW TO USE GRAVITY
y#=y#-8
PositionEntity camera,x#,y#,z#
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 KeyHit(50)>=1 Then musicflag=1-musicflag
If KeyHit (156)=True Then
PositionEntity camera,1466,220,412
ResetEntity camera
EndIf
If KeyDown( 208 )=True Then
MoveEntity camera,0,0,-5
volume_walk = 1
ChannelVolume play_walk,volume_walk
EndIf
If KeyDown( 200 )=True Then
MoveEntity camera,0,0,+5
volume_walk = 1
ChannelVolume play_walk,volume_walk
EndIf
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Bullet code by Ross C and G.O.D.
If MilliSecs()>gun_time+gun_timer Then ShowEntity bolt
If MilliSecs()<gun_time+gun_timer Then HideEntity bolt
If ammo=0 Then HideEntity bolt ; this is my addition to make it hide/show
If MouseDown(1) And MilliSecs()>gun_time+gun_timer Then
ammo = ammo-1
If ammo<0 Goto carryon
Animate gun,3
PlaySound firebow
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
.carryon
If ammo < 0 Then
ammo = 0
HideEntity bolt
EndIf
check_collide()
;put_reload()
update_bullet()
; =--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-==-=-=-=-=-=-=
If MouseDown(2) = True Then entity = EntityPick(camera,190)
Select entity
Case Adoor
For hh = 1 To 80
RotateEntity Adoor,0,hh,0 ; was turnentity
Next
Default hh=0
End Select
;If MouseHit(2) = True Then
;xx$=x#
;yy$=y#
;zz$=z#
; WriteLine (fileout,xx$+" "+yy$+" "+zz$)
;EndIf
FlushMouse
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
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-= CANDLES
frame=MilliSecs()/60 Mod 16
EntityTexture candle,flame,frame
EntityTexture can1,flame,frame
EntityTexture can2,flame,frame
EntityTexture can3,flame,frame
EntityTexture can4,flame,frame
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= PLAY MUSIC
If musicflag=1 Then ChannelVolume play_annoy,0.4 Else ChannelVolume play_annoy,0
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#
Text 0,50,"Entity: "+PickedEntity()
Text 0,60,"M1"+ MouseHit(1)
Text 0,70,"M2"+MouseHit(2)
heal#=healthy#*100
Text 0,530,"Health: "+heal#
Text 0,90,"Ammo: "+ammo
Text 0,100,"MF:"+musicflag
Flip
DUDE=0
Wend
; CloseFile fileout
End
Function create_bullet(gun_entity)
HideEntity bolt
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(bolt)
b\pivot=CreatePivot()
PositionEntity b\entity,temp_x,temp_y,temp_z
EntityType b\entity,2
RotateEntity b\entity,EntityPitch(gun_entity,True),EntityYaw(gun_entity,True),0
PositionEntity b\pivot,temp_x,temp_y,temp_z
b\range=300
b\speed=18
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
Function check_collide()
If EntityCollided(camera,5) Then
HideEntity switch2
PositionEntity terr,-20*512,0,-20*512
ResetEntity camera
PositionEntity camera,1466,229,412
ResetEntity camera
ShowEntity w
rs=1
;playsound whoop
ShowEntity crypt2
ShowEntity crypt
ShowEntity castle
ShowEntity wall
ShowEntity portal
ShowEntity ghall
HideEntity crypt3
HideEntity pad2
EndIf
If EntityCollided(camera,4) Then
HideEntity switch
PlaySound doorx
ShowEntity crypt3
ShowEntity pad2
ShowEntity switch2
HideEntity crypt2
HideEntity crypt
HideEntity castle
HideEntity wall
HideEntity portal
HideEntity ghall
;FreeEntity t\entity
PositionEntity terr,0,-120,0
HideEntity w
EndIf
For b.reload = Each reload
If EntityCollided (camera,8) Then
moredude=b\ammoplus
ammo = ammo + moredude
FreeEntity b\entity
FreeEntity rx
FreeEntity ry
FreeEntity rz
FreeEntity ammoplus
Delete b.reload
EndIf
Next
For b.reload = Each reload
EntityType b\entity,8
whe=TerrainY(terr,b\rx,b\ry,b\rz) ; get the height of the terrain at that place
PositionEntity b\entity,b\rx,whe+30,b\rz
Next
End Function
Function put_trees()
For t.tree = Each tree
EntityType t\entity,2
ScaleEntity t\entity,t\scale,t\scale,t\scale
build=LinePick(t\treex,400,t\treez,0,-400,0)
If build=2 Then
FreeEntity t\entity
FreeEntity t\treex
FreeEntity t\treey
FreeEntity t\treez
EndIf
If build=6 Then
FreeEntity t\entity
FreeEntity t\treex
FreeEntity t\treey
FreeEntity t\treez
EndIf
where1=TerrainY(terr,t\treex,t\treey,t\treez) ; get the height of the terrain at that place
PositionEntity t\entity,t\treex,where1,t\treez - 3
Next
End Function
Function put_reload()
jjjjj=9
;For a.reload = Each reload
;EntityType a\entity,8
;whe=TerrainY(terr,a\rx,a\ry,a\rz) ; get the height of the terrain at that place
;PositionEntity a\entity,a\rx,whe+30,a\rz
;Next
End FunctionIts like that... the last function I just ;ed out for now 'cause I am trying to cheat and put the quivers when I check collisions... I did this in another game and it works fine. Doesn't work here though!
-RZ