So I am using this wacky code to randomly select from 1 of 4 bitmaps and 1 of 4 rotation angles thus giving me 16 different looking images displayed randomly which creates a nice electricity effect for my shield. This works great on my Roku 3 but I was just testing on my Roku 1 today and well the performance is horrible.
if this.shield_on
if this.shield_animation_timer.TotalMilliseconds() > 50
this.rnd_shield_old = this.rnd_shield
this.rnd_shield_rotation_old = this.rnd_shield_rotation
this.shield_animation_timer.Mark()
set_shield_animation:
this.rnd_shield = cint(rnd(4)-1)
this.rnd_shield_rotation = 90 * cint(rnd(4)-1)
this.x_offset = 0
this.y_offset = 0
if this.rnd_shield_rotation = 90
this.y_offset = 150
else if this.rnd_shield_rotation = 180
this.y_offset = 150
this.x_offset = 150
else if this.rnd_shield_rotation = 270
this.x_offset = 150
end if
if this.rnd_shield_rotation = this.rnd_shield_rotation_old and this.rnd_shield = this.rnd_shield_old
goto set_shield_animation
end if
end if
this.screen.DrawRotatedObject(this.spr_ship_x-33-10+this.x_offset, this.ship_y-21-10+this.y_offset, this.rnd_shield_rotation, this.bm_shield[this.rnd_shield], m.ship_color[m.active_ship].shield.hex)
end if
So the question is, is there a performance difference between these various forms of drawing to the screen:
- Drawing sprites that are in the compositor using compositor.DrawAll()
- Using screen.DrawObject()
- Using screen.DrawScaledObject()
- Using screen.DrawRotatedObject()
I guess it makes sense that if the game needs to handle rotating the image first it would take time, I just didn't think it would have this much of a performance hit.
Also note that I am colorifying (IDK the term but gimp calls it this) the shield using the optional hex color argument. Not sure if that could affect it as well.
I know that I could swap out DrawScaledObject() and DrawObject() temporarily to see what it does ( and I probably will ) but I just thought I'd see if anyone else has thoughts on this topic.
Cheers