Dam, now my head hurts too, but here is the cause:;Generate the landscape
scr=512 ;alter if you like
SeedRnd(MilliSecs())
Dim plots(scr-1,scr-1)
For a=0 To scr-1
For b=0 To scr-1
plots(a,b)=Rand(0,1)
Next
Next
;While Not KeyHit(1)
For a=0 To 399999 ;alter too if you like
x=Rand(scr,scr+scr-1)
y=Rand(scr,scr+scr-1)
b=0
For c=-2 To 2
For d=-2 To 2
If Abs(c)+Abs(d)<4 Then b=b+plots((x+c) Mod scr,(y+d) Mod scr)
Next
Next
b=b+Rand(0,4)
plots(x-scr,y-scr)=b/13
Next
c1#=Cos(Rnd(0,180))/2.0+.5
c2#=Cos(Rnd(0,180))/2.0+.5
c3#=Cos(Rnd(0,180))/2.0+.5
c4#=Cos(Rnd(0,180))/2.0+.5
c5#=Cos(Rnd(0,180))/2.0+.5
c6#=Cos(Rnd(0,180))/2.0+.5
c1=0
c3=0
c5=0
c2=1
c4=1
c6=1
; LockBuffer BackBuffer()
out=WriteFile("Output.bmp")
WriteByte(out,66)
WriteByte(out,77)
WriteByte(out,118)
WriteByte(out,47)
SeekFile(out,10)
WriteByte(out,54)
SeekFile(out,14)
WriteByte(out,40)
SeekFile(out,18)
WriteShort(out,scr)
SeekFile(out,22)
WriteShort(out,scr)
SeekFile(out,26)
WriteByte(out,1)
SeekFile(out,28)
WriteByte(out,24)
SeekFile(out,34)
WriteByte(out,64)
WriteByte(out,47)
SeekFile(out,54)
strange=scr Mod 4
For x=scr To scr+scr-1
For y=scr To scr+scr-1
b=0
For c=-2 To 2
For d=-2 To 2
If Abs(c)+Abs(d)<4 Then b=b+plots((x+c) Mod scr,(y+d) Mod scr)
Next
Next
WriteByte(out,(c1*(21-b)+c2*b)*255.0/21.0)
WriteByte(out,(c3*(21-b)+c4*b)*255.0/21.0)
WriteByte(out,(c5*(21-b)+c6*b)*255.0/21.0)
; WritePixelFast x-scr,y-scr,255*256*256+b*256*6,BackBuffer()
Next
For a=1 To strange
WriteByte(out,0)
Next
Next
; UnlockBuffer BackBuffer()
; Flip
Graphics3D 640,480
camera=CreateCamera()
position=CreatePivot()
positionsl=CreatePivot()
positionst=CreatePivot()
button=CreatePivot()
EntityRadius position,1
EntityRadius positionsl,1
EntityRadius positionst,1
EntityRadius button,.01
PositionEntity button,0,-1.02,0
;EntityType position,1
EntityType positionsl,2
EntityType positionst,3
EntityType button,4
texture=LoadTexture("Output.bmp")
ScaleTexture texture,64,64
aterr=LoadTerrain("Output.bmp")
ScaleEntity aterr,2,8,2
MoveEntity aterr,-50,-100,-50
EntityTexture aterr,texture
TerrainDetail aterr,5000
EntityType aterr,5
Collisions 2,5,2,2
Collisions 3,5,2,3
Collisions 4,5,2,2
Repeat
mx% = MouseX()
my% = MouseY()
rotation# = rotation# + (mx% - 200) * .1
tilt# = tilt# + (my% - 200) * .1
If tilt# < -90 Then tilt# = -90
If tilt# > 90 Then tilt# = 90
If rotation# < 0 Then rotation# = rotation# + 360
If rotation# > 360 Then rotation# = rotation# - 360
MoveMouse 200, 200
walk%=0
stepp%=0
If KeyDown(17) walk% = 2
If KeyDown(31) walk% = -2
If KeyDown(30) stepp% = -2
If KeyDown(32) stepp% = 2
If KeyDown(1) endproc% = 1
If KeyDown(57) And inair=0 Then
bmove#=0.35
End If
dmove# = 1
If walk% <> 0 And stepp% <> 0 Then dmove# = .707106
If inair=0 Then
cmove# = cmove# + (Cos(rotation#) * walk% * dmove# - Sin(rotation#) * stepp% * dmove#)*.01
amove# = amove# + (Sin(rotation#) * walk% * dmove# + Cos(rotation#) * stepp% * dmove#)*.01
End If
If ground Then
cmove# = cmove# * .95
amove# = amove# * .95
End If
If cmove*cmove+amove*amove<.000001 Then
cmove=0
amove=0
End If
;the gravity
bmove#=bmove-.025
smartx#=EntityX(position)
smarty#=EntityY(position)
smartz#=EntityZ(position)
PositionEntity positionsl,EntityX(position)+amove,EntityY(position)+bmove,EntityZ(position)+cmove
PositionEntity positionst,EntityX(position)+amove,EntityY(position)+bmove,EntityZ(position)+cmove
PositionEntity button,EntityX(position)+amove,EntityY(position)+bmove-1.2,EntityZ(position)+cmove
UpdateWorld
If EntityCollided(button,5)<>0 Then
inair=0
; bmove=0
PositionEntity position,EntityX(positionst),EntityY(positionst),EntityZ(positionst)
Else
inair=1
PositionEntity position,EntityX(positionsl),EntityY(positionsl),EntityZ(positionsl)
End If
ground=0
If EntityCollided(positionsl,5) Then
bmove=0
ground=1
End If
RotateEntity camera,tilt#,-rotation#,0
PositionEntity camera,EntityX(position),EntityY(position)+.7,EntityZ(position)
RenderWorld
Flip
amove=EntityX(position)-smartx
bmove=EntityY(position)-smarty
cmove=EntityZ(position)-smartz
Until endproc
|