Find the orb

Miscellaneous Forums/Blitz Showcase/Find the orb

A small physics demonstration on making the steep slopes unwalkable. Try to find the green orb as fast as possible, it's easy to loose the direction. Use WASD control and mouse.
;Find the orb, small demo game



;Generate the landscape
scr=512
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
		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=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
	CloseFile out
;	UnlockBuffer BackBuffer()
;	Flip








Graphics3D 800,600,16
camera=CreateCamera()
CameraRange camera,.1,2000
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")
DeleteFile "Output.bmp"
ScaleEntity aterr,2,7,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
;ExecFile("Output.bmp")
orb=CreateSphere(32)
EntityColor orb,0,255,0
PositionEntity orb,800,TerrainY(aterr,800,0,800)+5,800
ScaleEntity orb,4,4,4
EntityBlend orb,3
EntityShininess orb,.4
light=CreateLight()
RotateEntity light,20,0,0
start=MilliSecs()

Repeat
	loops=loops+1
	EntityAlpha orb,Sin(MilliSecs()/5)/2+.5
  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
	If EntityDistance(orb,position)<6 Then
		time=MilliSecs()-start
		Color 255,0,0
		Text 400,300,"You found the orb in "+loops+" loops",True,True
		Flip
		Delay 1000
		FlushKeys
		WaitKey()
		End
	End If
Until endproc


23128 loops :D

6892 loops :)

9231 loops... :D

8934, dam you'r prof Retro ;)
Edit 6813

8480 loops

8360 loops

6753

/me dances arround

16470 loops. BOOYAH! Take that ROSSC!

I's funny what turn into games, I just wanted to show tiler how to make a collisions system without having to split up the landscape for different types of collisions. And then somebody actually play it? It really reminds me about Lousy Racing Game, somebody asked about car physics, and then people started competing, presumeably having fun.

Edit: 6199

20989 :( still better than RossC though ;)