Get the latest Education e-news
 

Go Back   Game Career Guide Forums > Programming
Forum Home Register Members List Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 08-12-2009, 09:29 AM   #1
Editoreoa
Junior Member

Activity Longevity
0/20 14/20
Today Posts
0/11 ssssssss3
Location: colorado
Question depth in 2-d question

Hello, this is my first ndeavour in game programming and am the only one working on this project
I was able to restrict movement of the player within a rectangle (no problem) but what Iíd like to achieve is a sense of depth where as I move up I am actually moving upstage as well. This is hard to grasp as I am using sprites on a background. The earliest game that I can think of that is a good example is double dragon.

I am using xna
Editoreoa is offline   Reply With Quote
Old 08-12-2009, 10:47 AM   #2
Protector one
Moderator

Activity Longevity
2/20 17/20
Today Posts
1/11 ssssss695
Location: Netherlands
Default

So what is the problem exactly? If you can get a sprite to move horizontally, surely you can also get it to move vertically. (This is how the sprites in Double Dragon move between 'stages', as you call them.) Alternatively, it might look good to to draw different sprites for moving vertically (sprites faced towards the screen and away from the screen) and/or slightly scale the sprites in accordance with perspective (moving towards the screen the sprite should grow in size, away it should shrink).
That's just my two cents for now, but your question is a little confusing.
__________________
My name is Louis. Hi!
Uh oh! The princess is in another signature!
Protector one is offline   Reply With Quote
Old 08-12-2009, 11:37 AM   #3
Editoreoa
Junior Member

Activity Longevity
0/20 14/20
Today Posts
0/11 ssssssss3
Location: colorado
Default

Well it is a matter of layer depth simulation, if a GameObjectís Y value less that other GameObjects Iíd like to draw them first. The tutorial spawns enemies from the right and scrolls them left, and it looks really bad when enemies are drawn over others when they shouldnít be.
Yes, Iíve talked about different art for moving up and down with the person who is drawing my batches. I just recently discovered effects.horizontalflip so my animation works in both left/right movement. I got a fire weapon animation to work with as well. The problem at hand is in this block I believe

foreach (GameObject enemy in enemies)
{
if (enemy.alive)
{
spriteBatch.Draw(enemy.sprite,
enemy.position, Color.White);
}
}

As it gives no layer precedence in the draw up date
Editoreoa is offline   Reply With Quote
Old 08-12-2009, 11:59 AM   #4
Protector one
Moderator

Activity Longevity
2/20 17/20
Today Posts
1/11 ssssss695
Location: Netherlands
Default

I'm no expert, but what I'd do is maintain a sorted list that contains your sprites in the order that they should be drawn. Then, instead of simply doing a foreach, traverse your sorted list front to back and draw each sprite/enemy in the encountered order.
It isn't difficult maintainting the sorted list; in general, you can simply sort the sprites on the y-coordinate.
__________________
My name is Louis. Hi!
Uh oh! The princess is in another signature!
Protector one is offline   Reply With Quote
Old 08-18-2009, 11:13 AM   #5
Editoreoa
Junior Member

Activity Longevity
0/20 14/20
Today Posts
0/11 ssssssss3
Location: colorado
Default

that works like a dream, thanks! Now on to collision that also has depth
Editoreoa is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 01:34 AM.






UBM Tech