quick sprite hack

BlitzMax Forums/BlitzMax Beginners Area/quick sprite hack

was looking for somthing in my snippets directory when I found this quick 1/2 hour hack I did a while ago...

My overiding the lists sort method, you should be able be able to change the order they are displayed in, it your worried about that kinda thing...

anyhow it should be simple enough for ppl to use when they start experimenting with bmax

SuperStrict

Framework BRL.GLMax2D
Import BRL.Math
Import BRL.PNGLoader
Import BRL.Random

SetGraphicsDriver GLMax2DDriver()

Type Tsprite
	Field image:Timage
	Field x:Float	'position
	Field y:Float
	Field ang:Float 'heading
	
	Field lx:Float	'last position
	Field ly:Float
	
	' these are just for test purposes
	Field xi:Float	'angle increments
	Field yi:Float
	Field xa:Float	' movement angles
	Field ya:Float
	Field sizea:Float
	
	Field r:Int
	Field g:Int
	Field b:Int
		
	Method update()
		lx=x
		ly=y
		xa:+xi
		ya:+yi
		x=400+200*Sin(xa)
		y=300+200*Cos(ya)
		ang=ATan2(y-ly,x-lx)+90
	EndMethod
EndType

Graphics 800,600
SetBlend ALPHABLEND
Global spritelist:Tlist=CreateList()

Global pics:TImage[4]
pics[0]=LoadImage("ship1.png")
pics[1]=LoadImage("ship2.png")
pics[2]=LoadImage("ship3.png")
pics[3]=LoadImage("ship4.png")
SetImageHandle pics[0],32,32
SetImageHandle pics[1],32,32
SetImageHandle pics[2],32,32
SetImageHandle pics[3],32,32

For Local n:Int=0 To 49
	Local s:Tsprite
	s=New Tsprite
	s.image=pics[Rnd(0,3)]
	s.xi=Rnd(-0.5,0.5)
	s.yi=Rnd(-0.5,0.5)
	s.r=Rnd(128,255)
	s.g=Rnd(128,255)
	s.b=Rnd(128,255)
	s.sizea=Rnd(0,359)
	ListAddLast spritelist,s
Next




While Not KeyDown(key_escape) And Not AppTerminate()
	For Local s:Tsprite=EachIn spritelist
		s.update
		s.sizea:+1
		SetScale (Sin(s.sizea)+2)/2,(Sin(s.sizea)+2)/2
		SetRotation s.ang
		SetColor s.r,s.g,s.b
		DrawImage s.image,s.x,s.y
	Next

	Flip
	Cls
Wend