Click here to Skip to main content
15,895,746 members
Home / Discussions / C#
   

C#

 
AnswerThis may sound silly but Pin
Ennis Ray Lynch, Jr.9-Aug-09 18:23
Ennis Ray Lynch, Jr.9-Aug-09 18:23 
AnswerRe: Unable to send image on UDP larger than 10K Pin
Luc Pattyn9-Aug-09 22:59
sitebuilderLuc Pattyn9-Aug-09 22:59 
QuestionRPG - character draw behind object problems [modified] Pin
jdneul9-Aug-09 11:12
jdneul9-Aug-09 11:12 
AnswerRe: RPG - character draw behind object problems Pin
Luc Pattyn9-Aug-09 11:41
sitebuilderLuc Pattyn9-Aug-09 11:41 
AnswerRe: RPG - character draw behind object problems Pin
harold aptroot9-Aug-09 12:28
harold aptroot9-Aug-09 12:28 
GeneralRe: RPG - character draw behind object problems Pin
jdneul9-Aug-09 12:59
jdneul9-Aug-09 12:59 
GeneralRe: RPG - character draw behind object problems Pin
Luc Pattyn9-Aug-09 13:05
sitebuilderLuc Pattyn9-Aug-09 13:05 
GeneralRe: RPG - character draw behind object problems Pin
harold aptroot9-Aug-09 13:14
harold aptroot9-Aug-09 13:14 
Sure, here's my most important draw function
public static void Draw(DrawItemBase D)
{
    const float inv1024 = 1f / 1024;
    int z = D.Bottom;
    if (z < 0)
        return;
    foreach (DrawItemBase d in D)
    {
        d.Draw(z * inv1024, IndexedSprite);
        z++;
    }
    if (!MouseOverHasFoundTarget && (mouseindex < 288 || mouseindex > 288 + 8))
        foreach (DrawItemBase d in D)
            DetectClickOnSelectable(D);
}

There are some mouse-related hacks in it, and the hardcoded 1024 that you see there is half random, it's 768 (screen height, shouldn't normally be hardcoded) + a bit of space for sprites that extend below the bottom of the screen, a Z value bigger than 1 will be clipped away.

The main point of it, is that a draw item keeps a list of draw items which have to be drawn in order (for when exceptional rendering order is required), and that normally the Z is set to the bottom Y of the sprite.

The "IndexedSprite" you see is a homemade spritebatch which uses a different vertex struct to send different information, because it's rendering indexed textures with a player index which changes the colour at some indices, and the player index is something that can vary per sprite (read pixel, use R component and PlayerIndex to do a 2d colour lookup in a texture which contains a colour palette which is different for each player), so making it a uniform shader variable would not work.



AnswerRe: RPG - character draw behind object problems Pin
jdneul10-Aug-09 4:40
jdneul10-Aug-09 4:40 
QuestionTalking to a telnet server [modified] Pin
shultas9-Aug-09 8:21
shultas9-Aug-09 8:21 
AnswerRe: Talking to a telnet server Pin
Randor 9-Aug-09 9:41
professional Randor 9-Aug-09 9:41 
GeneralRe: Talking to a telnet server Pin
shultas9-Aug-09 9:54
shultas9-Aug-09 9:54 
GeneralRe: Talking to a telnet server Pin
shultas9-Aug-09 10:00
shultas9-Aug-09 10:00 
GeneralRe: Talking to a telnet server Pin
Luc Pattyn9-Aug-09 10:30
sitebuilderLuc Pattyn9-Aug-09 10:30 
GeneralRe: Talking to a telnet server Pin
Randor 9-Aug-09 10:32
professional Randor 9-Aug-09 10:32 
Question[Message Deleted] Pin
spankyleo1239-Aug-09 6:13
spankyleo1239-Aug-09 6:13 
AnswerRe: InsertOnSubmit error Pin
Luc Pattyn9-Aug-09 6:28
sitebuilderLuc Pattyn9-Aug-09 6:28 
General[Message Deleted] Pin
spankyleo1239-Aug-09 6:35
spankyleo1239-Aug-09 6:35 
GeneralRe: InsertOnSubmit error Pin
Luc Pattyn9-Aug-09 6:41
sitebuilderLuc Pattyn9-Aug-09 6:41 
QuestionForms overlapping Pin
Xmen Real 9-Aug-09 5:16
professional Xmen Real 9-Aug-09 5:16 
AnswerRe: Forms overlapping Pin
pelnor9-Aug-09 5:28
pelnor9-Aug-09 5:28 
GeneralRe: Forms overlapping Pin
Luc Pattyn9-Aug-09 5:59
sitebuilderLuc Pattyn9-Aug-09 5:59 
GeneralRe: Forms overlapping Pin
pelnor9-Aug-09 6:10
pelnor9-Aug-09 6:10 
GeneralRe: Forms overlapping Pin
Xmen Real 9-Aug-09 6:22
professional Xmen Real 9-Aug-09 6:22 
AnswerRe: Forms overlapping Pin
Luc Pattyn9-Aug-09 6:34
sitebuilderLuc Pattyn9-Aug-09 6:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.