c++ - 2D Graphics Performance Boost -


i know title bit wishy-washy. problem this, trying code little game in c++ win32 graphics , want pieces drawn top down go in front of each other properly. (e.g., if i'm stood in front of tree, draws tree first, player in front)

my first idea was, using vectors needed dynamic array type thing, cycle in loop this

for(y = 0; y < playeryvalue; y++){     //check every enemy/object see if yvalue matches looping y     object.drawimage(); } 

and same in front of player. however, after running tests, inefficient looping, takes 34 milliseconds, , without takes 2 :/

i looking way draw of objects in order , appreciate whatsoever, worth try. 1 area can't think of inventive way solve problem.

please ask if need me give more details :)

edit: comment in code placeholder vector iterations each time check if object's yvalue equal y :) thought i'd clear bit :)

perhaps should sort objects y value , render them, should faster if doing search on each object every time draw object.

and try not make player special. player should "object" well, sort once front , draw front.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -