Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


LordRhys

Member Since 19 Oct 2005
Offline Last Active Jan 29 2015 07:03 AM

Topics I've Started

Render order for objects

04 February 2013 - 11:11 AM

 I used a technique that was in an XNA TileEngine tutorial by Nick Gravelyn where a renderlist is created and a sort done based on a comparison between object origins. This all works great between the animated sprites (player, npc's, and mobs) however my issue is with the player and non-animated objects like treasure chests and other items that may be placed. The code pieces I use are listed below, I am trying to figure out how I would also include the BaseSprite class objects. This is done so that when the player passes an npc, mob or object atthe top of that sprite he will be displayed as walking behind it.

 

private List<AnimatedSprite> renderList = new List<AnimatedSprite>();
 

    private Comparison<AnimatedSprite> renderSort =
      new Comparison<AnimatedSprite>(renderSpriteComapre);
   
    // also have BaseSprite chestSprite as non-animated sprite object

    BaseSprite chestSprite = new BaseSprite(
                containers,
                new Rectangle(0, 0, 32, 32),
                new Point((int)c.Value.X, (int)c.Value.Y));
   
    renderList.Add(npc.Sprite);
    renderList.Add(mob.Sprite);
    renderList.Add(player.Sprite);
   
    private static int renderSpriteComapre(AnimatedSprite a, AnimatedSprite b)
    {
        return a.Origin.Y.CompareTo(b.Origin.Y);
    }   
   
    public override void Draw(GameTime gameTime)
    {
      //spritebatch.begin info
      //draw level code
     
      renderList.Sort(renderSort);


 

      foreach (AnimatedSprite s in renderList)
        s.Draw(gameTime, GameRef.SpriteBatch);
     
      //spritebatch.end info     
    }
    


[.net] Drag & Drop in a Card Game

22 November 2005 - 01:37 AM

Hi All, I am trying to write a card game, I have the cards being drawn with no problem using the g.DrawImage(card, drawRect, 0, 0, card.Width, card.Height, GraphicsUnit.Pixel, transparentAttributes) method. I am trying to figure out how to grab a section of the array of cards and drag it and drop it on another array of cardimages (sort of like solitaire). I have code to determine at which point in the array you have done a mouse down event but am lost on the actual drag and drop, any sugestions would be welcome or pointing me to some code examples would be great also. I am doing this in VB.Net but code examples in C# would work also since I can convert. Thanks, Frank

Reading Embedded Resource into Bitmap array in VB.Net

26 October 2005 - 07:32 AM

I am working on a card game and have a directory im my project called CardImages, I am trying to loop through and ead all the images into an array of type bitMap, I keep recieving a NullException error on the line that reads the file from the Manifest and puts it into the array. The files are labeled in the format of 0.gif, 1.gif, ..., 52.gif; below is my code to load these files. Can anyone give me a heads up on what i am doing wrong, the MSDN Help doesn't give any examples on using these calls correctly. TIA Private cardImages As Image() = New Bitmap(52) {} Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cardName As String Dim execAssem As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly() For i As Integer = 0 To 52 cardName = "DrawCards.CardImages." & i & ".gif" cardImages(i) = New Bitmap(execAssem.GetManifestResourceStream(cardName)) Next i transparentAttributes = New System.Drawing.Imaging.ImageAttributes transparentAttributes.SetColorKey(Color.Green, Color.Green) End Sub

PARTNERS