for(int x=0;x<10;x++){
DrawObject(object[x]); // draws 10 objects
}
How could I get it so that it draws the objects in order of the y coord. If the y coord is less than other objects y coord, draw it first... etc. I was trying to figure this out for a while, and couldn''t produce correct results.
Any help is greatly appreciated. Thanks.
Object Drawing Order
I am trying to draw sprites on the screen in order of their Y coordinate. For instance, drawing an object with y=20 before another object with y=50. That way the latter object will appear as to be drawn over top of the object with a y coord of 20.
The way I have it now is something like this:
Greg FieldsSyntasoft Gameswww.syntasoft.comPost-Time Horse Racing (Available Now)
You need to sort your object array before you sended them to the Rederor, somthing like
for y = 0 to numberObjects
for x = 0 to numberObjects
if ObjectArray(y).y > ObjectArray(x).y then
if ObjectArray(y+1).y < ObjectArray(x).y then
Shift ObjectArray,Y,1 ''Move evrything up one Spot
''make room for the new eliment
Add ObjectArray(x) to ObjectArray(y)
end if
end if
next x
next y
this is off the top of my Head
you will need to add more code to that but thats a Bubel sort (i think)
hehe
hope that helps
oo yea umm when all thats done then you can just render them in the arder thay are in the Array (e.g. ObjectArray(0) to ObjectArray(UperLimit)
-VBLimits
Sorry about the Spelling..
for y = 0 to numberObjects
for x = 0 to numberObjects
if ObjectArray(y).y > ObjectArray(x).y then
if ObjectArray(y+1).y < ObjectArray(x).y then
Shift ObjectArray,Y,1 ''Move evrything up one Spot
''make room for the new eliment
Add ObjectArray(x) to ObjectArray(y)
end if
end if
next x
next y
this is off the top of my Head
you will need to add more code to that but thats a Bubel sort (i think)
hehe
hope that helps
oo yea umm when all thats done then you can just render them in the arder thay are in the Array (e.g. ObjectArray(0) to ObjectArray(UperLimit)
-VBLimits
Sorry about the Spelling..
![](http://www.telusplanet.net/public/javaman/img/Title.gif)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement