360 shooter.... scrolling background

BlitzMax Forums/BlitzMax Beginners Area/360 shooter.... scrolling background

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.

see if this gives you an idea
SuperStrict
Const RADARRADIUS:Float = 50.0
Const COVERRADIUS:Float = 800.0
Const DIAMETER:Float = COVERRADIUS*2
Const RATIO:Float = RADARRADIUS / COVERRADIUS


Type tpoint
	Field 	x:Float
	Field 	y:Float
End Type

Type Tradar
	Field	x		:Float , ..
			y		:Float
			
	Field 	Asquare	:Float
	Field	diameter	:Float
	Field	origin	:tpoint
	Field 	lt		:tpoint
	Field	rt		:tpoint
	Field	lb		:tpoint
	Field	rb		:tpoint
	Field	pointlist :TList		

	Method Create(x:Float , y:Float)
		Self.x = x
		Self.y = y
		Self.Asquare = COVERRADIUS ^ 2
		Self.diameter = COVERRADIUS*2
		origin = New tpoint
		pointlist = CreateList() 
		lt = New tpoint
		rt = New tpoint
		lb = New tpoint
		rb = New tpoint
		Local dx:Float = (DIAMETER - GraphicsWidth())/2 
		Local dy:Float = (DIAMETER - GraphicsHeight())/2
		lt.x = dx * RATIO
		lt.y = dy * RATIO		
		lb.x = lt.x
		rt.y = lt.y
		dx = dx + GraphicsWidth()   
		dy = dy + GraphicsHeight() 
		rb.x = dx * RATIO
		rb.y = dy * RATIO
		rt.x = rb.x
		lb.y = rb.y
	End Method
	
	Method set(x:Float , y:Float) 
		origin.x = x
		origin.y = y
	End Method
	
	Method addpoint:Int(x:Float , y:Float) 
		x:- 320
		y:- 240
		Local dx:Float = x 
		Local dy:Float = y
		If (dx^2+dy^2) <= Asquare  
			Local point:tpoint = New tpoint
			point.x = dx*RATIO
			point.y = dy*RATIO
			pointlist.addlast(point) 
			Return True 
		Else
			Return False
		EndIf 
	End Method
	
	Method clear() 
		pointlist.clear()
	End Method
	
	Method draw() 
		SetColor 200,200,0 
		SetAlpha .2
		DrawOval x - RADARRADIUS , y - RADARRADIUS , RADARRADIUS * 2 , RADARRADIUS * 2
		SetColor 0 , 255 , 0
		DrawLine  lt.x ,  lt.y , rt.x ,  rt.y
		DrawLine  lt.x ,  lt.y , lb.x ,  lb.y
		DrawLine  lb.x ,  lb.y , rb.x ,  rb.y
		DrawLine  rt.x ,  rt.y , rb.x ,  rb.y
		
		SetAlpha 1.0
		SetColor 200,0,0
		For Local p:tpoint = EachIn pointlist
			Plot x+p.x , y+p.y
		Next
		
		SetColor 255,255,255
	End Method
End Type

Type Tenemy
	
	Field x# , y#
	Field dx# , dy#

	Method Create ()

		x = Rand(GraphicsWidth()) 
		y = Rand(GraphicsHeight())
		dx = Cos(Rand(360.0)) *.2
		dy = Sin(Rand(360.0) )*.2
	End Method
	
	Method move() 
		x :+ dx
		y :+ dy
	End Method
			
	Method draw( )
		DrawRect x - 2 , y - 2 , 4 , 4
	End Method
End Type


Graphics 640,480,32
SetBlend alphablend
Local radar:Tradar = New Tradar
radar.Create(50 , 50) 
radar.set(400 ,400) 

Local enemy:Tenemy[5]
Local index:Int
For index = 0 Until enemy.length
	enemy[index] = New Tenemy
	enemy[index].Create() 
Next
Local x:Int = 0
Local y:Int = 0
Repeat
	Cls
	radar.clear() 
	DrawText enemy.length, 500,80
	For index = 0 Until enemy.length
		enemy[index].move() 
		If radar.addpoint(enemy[index].x , enemy[index].y) 
			enemy[index].draw() 
		EndIf
		enemy[index].x :+ x
		enemy[index].y :+ y 
	Next
	radar.draw() 
	If KeyDown(key_left)
		x = -3 
	ElseIf KeyDown(key_right) 
		x = 3
	Else
		x = 0
	EndIf
	If KeyDown(key_up) 
		y = -3 
	ElseIf KeyDown(key_down) 
		y = 3
	Else
		y = 0
	endif
	radar.set(x,y) 
	DrawText x+" "+y,500,50 
	Flip() 
Until KeyDown(key_escape)