best way to display multiple images

Monkey Targets Forums/Android/best way to display multiple images

dave.h(Posted 2011) [#1]
im getting bad framerates in v43 and im wondering if its because of the way im coding.Currently i use something like this to display most of my sprites.




but should i be using lists and eachin list.is there a speed increase in doing it another way.


GfK(Posted 2011) [#2]
Your problem (if that's the right word) is that you're doing 100 iterations per cycle - even if there's only a couple of aliens on the screen. However much that's affecting framerate, its a really inefficient way of doing it. At 60FPS, that'd be 6,000 iterations per second. If there's only five aliens, it need only be 300 iterations per second.

Yes, you'd be better off using lists but not having done anything significant in Monkey, I don't know to what extent.


Raz(Posted 2011) [#3]
I can't imagine 100 bool checks will have such an impact on the frame rate.
I use a similar system, but instead of checking from 0 to 99, a check from lowest known active item to highest known active item. (so potentially I could be doing "For local k=2 to 15"

As for using lists, at this stage I think it depends on your selected targets ability to manage them. (ie, XNA on Xbox hates lists).


dave.h(Posted 2011) [#4]
yes i see what you mean there but the number 99 was purely a random number i picked usually i would use an identifier something like

for local k=0 to num_of_aliens

although i must be coding badly as i seem to be getting bad frame rates on my galaxy tab where others see no difference or slight improvements but thanks for the reply.


AdamRedwoods(Posted 2011) [#5]
Try moving globals that sit in any loops locally.

Class MyGame Extends App
	
	Field aliens:sprite[100]
	Field img:Image
	
	Method OnCreate:Int() '..etc..


in Blitzmax, globals would slow down loops.


And I just tested v40 to v43 using this benchmark (link below), and my FPS on v40 was 2-4fps vs v43 on the top end only, for 10 objects and 100 objects. Not a major difference. Galaxy Tab P1010 (wifi).

link to the benchmark:
http://www.monkeycoder.co.nz/Community/post.php?topic=1120&post=10036


therevills(Posted 2011) [#6]
@dave.h - Your code looks okay to me, the only thing is that you have set SetUpdateRate to be 30, so are you wanting a max of 30FPS? Normally I set this to 60.

Also what device are you testing on? Edit: Ah just spotted you said you are using a Galaxy tab...


@Gfk - For Android, lists are actually slower due to that it will create a new iterator every time you use eachin etc, which will cause the GC to start.


dave.h(Posted 2011) [#7]
thanks for the replies guys glad i dont have to mess with them lists and eachin,i never trusted em.I just cant see what advantage they have.Maybe thats cos ive never used them before as ive never used blitzmax.


Shinkiro1(Posted 2011) [#8]
The advantage of lists is that they can grow and shrink easily. With an array you have to resize the whole array whenever you want to change it's size.