picking image object to put on a scenerio

BlitzMax Forums/BlitzMax Beginners Area/picking image object to put on a scenerio

Graphics 640,480,0,0

Global Shapelist:TList=CreateList()


Type Shape
	Field Xcoor=Rnd(640)-320
	Field Ycoor=Rnd(480)-240
	Field Col1=Rnd(255)
	Field Col2=Rnd(255)
	Field Col3=Rnd(255)
	Field X=Rnd(3)+3
	Field Y=Rnd(3)+3
End Type

Type Shape1 Extends Shape
	Method Drawshape()
		SetColor col1,col2,col3
		DrawOval xcoor+MouseX(),ycoor+MouseY(),20*x,20*y
	End Method
End Type

Type Shape2 Extends Shape
	Method Drawshape()
		SetColor col1,col2,col3
		DrawRect xcoor+MouseX(),ycoor+MouseY(),20*x,20*y
	End Method
End Type



While Not KeyHit(KEY_ESCAPE)
	DrawTheShapes()
	GetInput()


	FlushMem()
	Flip
	SetColor(0,0,0)
	Cls
Wend

End


Function Createshape1(times)
	For loop=1 To Times
		a:Shape1=New shape1
		ListAddLast Shapelist,a
	Next
End Function


Function CreateShape2(times)
	For loop=1 To Times
		b:Shape2=New shape2
		ListAddLast Shapelist,b
	Next
End Function

Function GetInput()
	If KeyHit(KEY_Z) Then CreateShape1(Rnd(5))
	If KeyHit(KEY_X) Then Createshape2(Rnd(5))
	If KeyHit(KEY_SPACE) Then ClearList Shapelist
End Function

Function Drawtheshapes()
	For a:Shape1=EachIn Shapelist
		a.drawshape
	Next
	
	For b:Shape2=EachIn Shapelist
		b.Drawshape
	Next
End Function


Just a few of the basics For adding objects to lists this would be one way as none are created in a preditermined way.
In this programme its using input from keypresses Z,X,Space to add random amound of oval or Rectangles To a Tlist.

You can Remove the Rnd(5) in the Getinput() function and Set it to any value