Tricky math questions!

BlitzMax Forums/BlitzMax Beginners Area/Tricky math questions!

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here is a very poor 3d fake. Just to get an idea.
Use mouse and WASD.

SuperStrict


Graphics 1024, 768, 32

HideMouse

Type point
	Global pointList:TList
	Global mx%
	Global my%
	Global mxs%
	Global mys%
	
	Field x#
	Field y#
	Field z#
	Field maxsize# = 100
	
	Method New()
		If pointList = Null Then pointList = CreateList()
		ListAddLast pointList, Self
	End Method
	
	Function Create:point(_x#,_y#,_z#)
		Local p:point = New point
		p.x = _x
		p.y = _y
		p.z = _z
		Return p
	End Function
	
	Function CreateRandom(_max#=1000)
		Local x# = Rnd(-_max,_max)
		Local y# = Rnd(-_max,_max)
		Local z# = Rnd(-_max,_max)
						
		point.Create(x,y,z)
	End Function
	
	Method Draw()
		If Self.z < 0 Then Return	
	
		Local size# = Self.maxsize
		
		If Self.z >= 1
			size = Self.maxsize / (Self.z / 10.0)
		End If
		
		If size > Self.maxsize Then Return
		
		SetColor 255,255,255
		DrawOval Self.x -size/2, Self.y -size/2, size, size
	End Method
	
	Method Update()
		If KeyDown(KEY_W) Then Self.z:- 1
		If KeyDown(KEY_S) Then Self.z:+ 1
		If KeyDown(KEY_A) Then Self.x:+ 1 / (Self.z/1000.0)
		If KeyDown(KEY_D) Then Self.x:- 1 / (Self.z/1000.0)
		
		Self.x:+ Float(mxs) / (Self.z/1000.0)
		Self.y:+ Float(mys) / (Self.z/1000.0)		
	End Method
	
	Function UpdateAll()
		mxs = mx - MouseX()
		mys = my - MouseY()
		mx = MouseX()
		my = MouseY()
			
		If pointList = Null Then Return		
		For Local p:point = EachIn pointList
			p.Update()
			p.Draw()
		Next
	End Function
End Type




For Local i:Int = 0 To 1000
	point.CreateRandom()
Next




While Not KeyHit(KEY_ESCAPE) And Not AppTerminate()
Cls

	point.UpdateAll()

Flip
Wend
End