draw a little square
BlitzMax Forums/BlitzMax Programming/draw a little square
| ||
| Hi, For my game, I need to draw moving stars. These stars are only one pixel or a square of 2 pixels. Question: what is the quickest method in term of performance ? Use the "drawrect" function or create an image of this point/square and draw it with the "drawimage" function ? |
| ||
| Probably drawrect. |
| ||
| Nothing in it but can't you test this yourself? Anyway,
Graphics 800,600
Global image:timage=LoadImage("star.png") ' 2*2
SeedRnd MilliSecs()
Type rectstar
Global starlist1:TList=CreateList()
Field x
Field y
Function create()
Local my:rectstar=New rectstar
my.x=Rand(0,800)
my.y=Rand(0,600)
ListAddLast starlist1,my
End Function
Function update()
For Local my:rectstar = EachIn starlist1
my.x:+1
If my.x>800 my.x=0
Next
End Function
Function draw()
For Local my:rectstar = EachIn starlist1
DrawImage image,my.x,my.y
' drawrect my.x,my.y,2,2
Next
End Function
End Type
Type imagestar
End Type
For x = 1 To 200
rectstar.create()
Next
start_rect=MilliSecs()
For x = 1 To 800
Cls
rectstar.draw()
rectstar.update()
Flip
Next
end_rect=MilliSecs()
DebugLog end_rect-start_rect
WaitKey()
|
| ||
| OK tonyG. The result is... no real difference... drawimage: 13323 drawrect: 13317 So, I keep my "drawrect" method. ;-) Thanks. |