I need some quick help please, just in case i posted my whole code, i know it is a piece of poo and is all straight from forums,archives and samples but.... when i run it it says wend without while. I have recieved this bug before but i do not know how to fix it this time. Thank you for your help!
Global info1$="Driver"
Include "start.bb"
Global zp#=1
Global wheels[4]
FPS = 50
period = 1000 / FPS
Global time = MilliSecs (); - period
Global fl=0.2
Global f2=40
Global f3=46
Global d1=1
Global d2=1
Global speed1=0
Global s12
Global toplane=0
;plane
;Const GRAVITY#=-.001
;tank
;Const GRAVITY#=-.07
;car
Global watermesh=LoadMesh("20x20quad.3ds") :
Global surface=CountSurfaces(watermesh)
surface=GetSurface(watermesh,1)
Global VertexCount=CountVertices(surface)
Global s12=Load3DSound("sound/slow one high RPM.mp3")
Const GRAVITY#=-.02
Const BODY=1,WHEEL=2,SCENE=3,DRAG=4,PLANE=5
Collisions BODY,SCENE,2,3
Collisions WHEEL,SCENE,2,3
Collisions BODY,WATERM,2,3
Collisions WHEEL,WATERM,2,3
Collisions WHEEL,WATERT,2,3
Collisions DRAG,SCENE,2,3
Collisions SCENE,DRAG,2,3
Collisions DRAG,BODY,2,3
Collisions DRAG,WHEEL,2,3
Collisions BODY,DRAG,2,3
Collisions WHEEL,DRAG,2,3
Collisions WHEEL,PlANE,2,3
Collisions PLANE,WHEEL,2,3
Collisions BODY,PLANE,2,3
Collisions PLANE,BODY,2,3
Collisions SCENE,PLANE,2,3
Collisions PLANE,SCENE,2,3
Type Vertices
Field x#
Field y#
Field z#
End Type
;PlaySound s1
mesh_skybox = MakeSkyBox("Data\sky")
Function MakeSkyBox( file$ )
m=CreateMesh()
;front face
b=LoadBrush( file$+"_FR.bmp",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0
AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;right face
b=LoadBrush( file$+"_LF.bmp",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0
AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;back face
b=LoadBrush( file$+"_BK.bmp",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;left face
b=LoadBrush( file$+"_RT.bmp",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0
AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
;top face
b=LoadBrush( file$+"_UP.bmp",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0
AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
ScaleMesh m,100,100,100
FlipMesh m
EntityFX m,9
EntityOrder m,10
Return m
End Function
RotateMesh watermesh,90,0,0
RotateEntity watermesh,-90,0,0
ScaleEntity watermesh,10,10,10
EntityShininess watermesh,0.2
PositionEntity watermesh,0,5,0
texd=LoadTexture( "dragon.bmp" )
dragon=LoadMD2( "dragon.md2" )
EntityTexture dragon,texd
PositionEntity dragon,-140,72,-93
ScaleEntity dragon,0.1,0.1,0.1
TurnEntity dragon,0,150,0
EntityType dragon,DRAG
AnimateMD2 dragon,1,0.2,f2,f3
;0,40 : idle
;40,46 : run
;46,54 : attack
;54,58 : paina
;58,62 : painb
;62,66 : painc
;66,72 : jump
;72,84 : flip
dragonb=CreateSphere()
ScaleEntity dragonb,1,1,1
EntityType dragonb,DRAG
EntityAlpha dragonb,0
ramptex=LoadTexture("steel.bmp")
ScaleTexture ramptex,0.5,0.5
ramp=CreateCube()
ScaleEntity ramp,5,3,10
PositionEntity ramp,-170,72,-90
RotateEntity ramp,-30,0,0
EntityTexture ramp,ramptex
EntityType ramp,SCENE
ramp1=CreateCube()
ScaleEntity ramp1,5,3,15
PositionEntity ramp1,-170,72,-40
RotateEntity ramp1,0,0,0
EntityTexture ramp1,ramptex
EntityType ramp1,SCENE
ramp2=CreateCube()
ScaleEntity ramp2,4.9,3,15
PositionEntity ramp2,-170,76,-35
RotateEntity ramp2,-30,0,0
EntityTexture ramp2,ramptex
EntityType ramp2,SCENE
ramp3=CreateCube()
ScaleEntity ramp3,5,3,25
PositionEntity ramp3,-170,82,-5
RotateEntity ramp3,0,0,0
EntityTexture ramp3,ramptex
EntityType ramp3,SCENE
ramp4=CreateCube()
ScaleEntity ramp4,5,3,1000
PositionEntity ramp4,-160,72,-5
RotateEntity ramp4,-30,0,0
EntityTexture ramp4,ramptex
EntityType ramp4,SCENE
ramp5=CreateCube()
ScaleEntity ramp5,200,1,1000
PositionEntity ramp5,-370,200,500
RotateEntity ramp5,0,0,0
EntityTexture ramp5,ramptex
EntityType ramp5,SCENE
;terr=LoadMesh("terrain 1.3ds")
terr=LoadTerrain( "heightmap_256.bmp" )
ScaleEntity terr,1000/TerrainSize(terr),70,1000/TerrainSize(terr)
TerrainDetail terr,1000,True
TerrainShading terr,True
;ScaleEntity terr,1,1,1
PositionEntity terr,-500,0,-500
tex=LoadTexture( "terrain-1.jpg" )
ScaleTexture tex,50,50
EntityTexture terr,tex
EntityType terr,SCENE
a747=LoadMesh("747.x")
ScaleEntity a747,20,20,20
RotateEntity a747,3,5,2
PositionEntity a747,1,3,10
EntityType a747,PLANE
water=CreatePlane()
PositionEntity water,1,2,1
EntityAlpha water,0.8
wt=LoadTexture( "water.bmp" )
ScaleTexture wt,50,50
EntityTexture water,wt
EntityType water,WATER
;wm=LoadTexture( "watermap.bmp")
;wl2=CreatePlane()
;PositionEntity wl2,1,1.9,1
;EntityAlpha wl2,0.8
;EntityTexture wl2,wm
terrp=CreatePlane()
PositionEntity terrp,1,0.1,1
EntityTexture terrp,tex
EntityType terrp,SCENE
;tlight1=CreateLight(2)
;LightColor tlight1,255,194,14
;skyp=CreatePlane()
;PositionEntity skyp,1,70,1
;skypt=LoadTexture("cloud_2.bmp")
;ScaleTexture skypt,1000,1000
;EntityFX skyp,1
;EntityTexture skyp,skypt
;sky=CreateSphere(32)
;ScaleEntity sky,300,300,300
;skyt=LoadTexture("cloud_2.bmp")
;ScaleTexture skyt,1000,1000
;EntityAlpha sky,.5
;EntityFX sky,1
;EntityTexture sky,skyt
;ScaleTexture skyt,50,50
;FlipMesh sky
carch=CreateSphere(32)
EntityColor carch,0,255,0
car=LoadMesh("jeep.3ds")
tlight=LoadTexture("jeep1l.jpg")
reglight=LoadTexture("jeep1.jpg")
;RotateEntity car,40,0,50
ScaleMesh car,1,1,-1
FlipMesh car
FitMesh car,-1.5,-1,-3,3,2,6
PositionEntity car,0,15,0
;EntityShininess car,1
EntityType car,BODY
;PositionEntity tlight1,EntityX(car)-3,EntityY(car),EntityZ(car)-1
;Global wheels[4]
cnt=1
For z#=1.5 To -1.5 Step -3
For x#=-1 To 1 Step 2
;wheels[cnt]=CreateSphere( 8,car )
wheels[cnt]=LoadMesh("wheel.3ds",car )
EntityAlpha wheels[cnt],1
ScaleEntity wheels[cnt],.35,.35,.35
EntityRadius wheels[cnt],.7
PositionEntity wheels[cnt],x,-1.5,z
EntityType wheels[cnt],WHEEL
cnt=cnt+1
Next
Next
light=CreateLight()
TurnEntity light,45,45,0
target=CreatePivot( car )
PositionEntity target,0,5,-12
camera=CreateCamera()
PositionEntity camera,1000,1000,1000
CameraClsColor camera,0,192,255
;CameraFogColor camera,0,192,255
CameraRange camera,1,3000
CameraZoom camera,zp#
CameraFogMode camera,1
CameraFogMode camera,1
CameraFogRange camera,0,750
CameraFogColor camera,222,252,255
;cam2=CreateCamera()
;PositionEntity cam2,0,300,0
;CameraViewport cam2,100,GraphicsHeight(),GraphicsWidth()-100,GraphicsHeight()-100
AmbientLight 255,255,255
speed#=0
x_vel#=0:prev_x#=EntityX( car )
y_vel#=0:prev_y#=EntityY( car )
z_vel#=0:prev_z#=EntityZ( car )
;Repeat
;Repeat
; elapsed = MilliSecs () - time
;Until elapsed
;ticks = elapsed / period
;tween# = Float (elapsed Mod period) / Float (period)
; For framelimit = 1 To ticks
; If framelimit = ticks Then CaptureWorld
; time = time + period
;UpdateGame ()
;UpdateWorld
;PositionEntity water, Sin (time * 0.01) * 10, EntityY (water) + (Sin (time * 0.05) * 0.5) * 0.2, Cos (time * 0.02) * 10
; Next
While Not KeyHit(1)
If EntityCollided(car,DRAG)
TurnEntity car,0,0,3
EndIf
;AnimateMD2 dragon,1,.05,f1,f2
;If EntityInView ( dragon,camera )=True
;start=1-start
;AnimateMD2 dragon,1,0.1,32,46
;EndIf
;PositionEntity water, Sin (time * 0.01) * 10, EntityY (water) + (Sin (time * 0.05) * 0.5) * 0.2, Cos (time * 0.02) * 10
Dim Vertex.Vertices(VertexCount)
For A=0 To VertexCount-1
Vertex(a) = New Vertices
Vertex(a)\x#=VertexX#(surface,a)
Vertex(a)\y#=VertexY#(surface,a)
Vertex(a)\z#=VertexZ#(surface,a)
Next
Repeat
;align car to wheels
zx#=(EntityX( wheels[2],True )+EntityX( wheels[4],True ))/2
zx=zx-(EntityX( wheels[1],True )+EntityX( wheels[3],True ))/2
zy#=(EntityY( wheels[2],True )+EntityY( wheels[4],True ))/2
zy=zy-(EntityY( wheels[1],True )+EntityY( wheels[3],True ))/2
zz#=(EntityZ( wheels[2],True )+EntityZ( wheels[4],True ))/2
zz=zz-(EntityZ( wheels[1],True )+EntityZ( wheels[3],True ))/2
AlignToVector car,zx,zy,zz,1
zx#=(EntityX( wheels[1],True )+EntityX( wheels[2],True ))/2
zx=zx-(EntityX( wheels[3],True )+EntityX( wheels[4],True ))/2
zy#=(EntityY( wheels[1],True )+EntityY( wheels[2],True ))/2
zy=zy-(EntityY( wheels[3],True )+EntityY( wheels[4],True ))/2
zz#=(EntityZ( wheels[1],True )+EntityZ( wheels[2],True ))/2
zz=zz-(EntityZ( wheels[3],True )+EntityZ( wheels[4],True ))/2
AlignToVector car,zx,zy,zz,3
;calculate car velocities
cx#=EntityX( car ):x_vel=cx-prev_x:prev_x=cx
cy#=EntityY( car ):y_vel=cy-prev_y:prev_y=cy
cz#=EntityZ( car ):z_vel=cz-prev_z:prev_z=cz
;resposition wheels
cnt=1
For z=1.5 To -1.5 Step -3
For x=-1 To 1 Step 2
; PositionEntity wheels[cnt],0,0,0
; ResetEntity wheels[cnt]
PositionEntity wheels[cnt],x,-1,z
cnt=cnt+1
Next
Next
;car lights
;PositionEntity tlight,EntityX(car),EntityY(car),EntityZ(car)
;water
;dragon
PositionEntity dragonb,EntityX(dragon),EntityY(dragon),EntityZ(dragon)
PositionEntity dragon,EntityX(dragonb),EntityY(dragonb),EntityZ(dragonb)
MoveEntity dragon,0,-0.7,0
TurnEntity dragon,0,0.1,0
;If EntityX(dragon)<-300
;d1=1
;d2=0
;Else If EntityX(dragon)>-300
;d1=1
;d2=-1
;Else If EntityX(dragon)<-250
;d1=1
;d2=0
;EndIf
TurnEntity dragon,0,d2,0
MoveEntity dragon,0,0,d1
;sky
PositionEntity mesh_skybox,EntityX(camera,1),EntityY(camera,1),EntityZ(camera,1)
TurnEntity mesh_skybox,0,0.01,0
;move car
If EntityCollided( car,WATERM )
MoveEntity car,2,0,2
TurnEntity car,0,3,1
EndIf
If EntityCollided(car,PLANE)
toplane=1 EntityColor car,255,255,255
EndIf
If EntityRoll#(car)>75
EntityColor car,10,10,10
toplane=1
EndIf
;cam2 control
;PositionEntity cam2,EntityX(car),800,EntityZ(car)
;PositionEntity carch,EntityX(car),750,EntityZ(car)
;PositionEntity sky,EntityX(car),EntityY(car),EntityZ(car)
MoveEntity water,0.01,0,0.08
If EntityCollided( car,SCENE )
If KeyDown(54)
speed1=speed1+0.4
If speed1>6 speed1=6
If KeyDown(203) TurnEntity car,0,3,0:;rotate
If KeyDown(205) TurnEntity car,0,-3,0
EndIf
If KeyDown(200)
;EntityTexture car,reglight
;PlaySound s12
speed=speed+.02
;If speed>1.1 speed=speed+0.1
If speed>1.1 speed=1.1
;If speed>3 speed=speed+0.09
;If speed>5 speed=speed+0.03
If KeyDown(203) TurnEntity car,0,3,0
If KeyDown(205) TurnEntity car,0,-3,0
Else If KeyDown(208)
;EntityTexture car,tlight
speed=speed-.02
If speed<-.5 speed=-.5
Else
speed=speed*.9
;Else
; speed=speed*.9
EndIf
;RPM
If KeyHit(2)
PlaySound s12
;s1=PlayMusic("sound/slow one high RPM.mp3")
ChannelPlaying(s12)=0 MoveEntity car,0,0,20
EndIf
MoveEntity car,0,0,speed
TranslateEntity car,0,GRAVITY,0
Else
TranslateEntity car,x_vel,y_vel+GRAVITY,z_vel
EndIf
;update camera
If speed>=0
dx#=EntityX( target,True )-EntityX( camera )
dy#=EntityY( target,True )-EntityY( camera )
dz#=EntityZ( target,True )-EntityZ( camera )
TranslateEntity camera,dx*.1,dy*.1,dz*.1
EndIf
PointEntity camera,car
;PointEntity cam2,car
UpdateWater()
UpdateWorld
RenderWorld
Color 0,255,0
Text 0,0,"Coordinates Car"
Text 0,20," X : "+EntityX(car)
Text 0,40," Y : "+EntityY(car)
Text 0,60," Z : "+EntityZ(car)
Text 150,20,"Roll "+EntityRoll#(car)
Text 150,40,"Yaw "+EntityYaw#(car)
Text 150,60,"Pitch "+EntityPitch#(car)
Text 275,0,"Coordinates Dragon"
Text 275,20," X : "+EntityX(dragon)
Text 275,40," Y : "+EntityY(dragon)
Text 275,60," Z : "+EntityZ(dragon)
Text 400,20,"Roll "+EntityRoll#(dragon)
Text 400,40,"Yaw "+EntityYaw#(dragon)
Text 400,60,"Pitch "+EntityPitch#(dragon)
Text 0,70,"Car Speed : "+speed
Flip
Wend
End
Function UpdateWater()
; Create a wave effect by moving all the vertices in the mesh up and down using Sin
; Try editing:
; Freq#=MilliSecs()/10
; ^ The Bigger the divide, the slower the water moves
; Vertex(a)\z#=Sin(freq+Vertex(a)\x#*300+Vertex(a)\y#*400)*1.125
; ^ The Bigger the Multiply The Higher
; the waves will be, lower = smaller
For a=0 To VertexCount-1
Freq#=MilliSecs()/10
Vertex(a)\z#=Sin(freq+Vertex(a)\x#*300+Vertex(a)\y#*400)*1.125
VertexCoords surface,a,Vertex(a)\x#,Vertex(a)\y#,Vertex(a)\z#
Next
UpdateNormals watermesh
End Function
|