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!


Machaira

Member Since 29 Sep 1999
Offline Last Active Jul 08 2013 08:15 AM

Topics I've Started

Sprite rotation problem using XNA

10 October 2011 - 10:44 AM

This is probably an obvious thing that's staring me in the face, but I'm probably too close to it to see it. Posted Image

So I'm doing some rotation of tiles and they're not rendering to the correct location:

Posted Image

The first tile isn't rotated and renders correctly. The other 3 are rotated to each direction other than north. Here's the code:



public override void Draw(GameTime gameTime)
        {
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0);

            SpriteBatch sb = ScreenManager.SpriteBatch;

            sb.Begin();

            _defaultViewport = ScreenManager.GraphicsDevice.Viewport;
            ScreenManager.GraphicsDevice.Viewport = _dungeonRenderArea;

            int x2 = GetTilesShown("width");
            int y2 = GetTilesShown("height");

            float rotation;

            Rectangle rect;

            for (int x = _startX; x < x2; x++)
            {
                for (int y = _startY; y < y2; y++)
                {
                    //TODO: need to fix rotation 
                    if (_rooms[x, y] != null && _rooms[x, y].Type != RoomType.None)
                    {
                        rotation = GetRotation(_rooms[x, y].Rotation);
                        rect = new Rectangle((int)((x - _startX) * (TileSize * _zoomFactor)), (int)((y - _startY) * (TileSize * _zoomFactor)), (int)(TileSize * _zoomFactor), (int)(TileSize * _zoomFactor));

                        sb.Draw(_roomTiles[(int)_rooms[x, y].Type],
                            rect,
                            null,
                            Color.White,
                            rotation,
                            _rooms[x, y].Rotation != Direction.North ? _vecOrigin : Vector2.Zero,
                            SpriteEffects.None, 1.0f);

                        sb.DrawString(_debugFont, rect.ToString(), new Vector2(rect.X, rect.Y), Color.White);

                    }
                }
            }


            ScreenManager.GraphicsDevice.Viewport = _defaultViewport;

            sb.End();

        }

        private float GetRotation(Direction dir)
        {
            float ret = 0.0f;

            switch (dir)
            {
                case Direction.North:
                {
                    ret = 0.0f;
                    break;
                }
                case Direction.East:
                {
                    ret = MathHelper.PiOver2;
                    break;
                }
                case Direction.South:
                {
                    ret = MathHelper.Pi;
                    break;
                }
                case Direction.West:
                {
                    ret = MathHelper.PiOver2 * 3;
                    break;
                }
            }

            return ret;
        }

_vecOrigin is set to the middle of the sprite. The text is rendering in the correct locations for the tiles, but I can't figure out why the tiles aren't.

Any ideas?

Shader for halo effect on 2D logo?

07 October 2010 - 02:21 AM

I'm looking to create a shader to apply a glowing halo around a logo, something similar to the post corona shader in the nVidia FX Composer library. Can anyone point me to something that does this?

Thanks!

XNA Game Studio 4.0 Announced

09 March 2010 - 05:19 AM

Kluch let's the cat out of the bag, finally! http://klucher.com/blog/achievement-unlocked-xna-game-studio-4-0-for-windows-phone/ Jump on board now while the train is still at the station! [grin]

Microsoft's Game Room

08 January 2010 - 12:59 AM

Surely, I'm not the first person to post this here? [grin] I'm normally the last one with news. http://kotaku.com/5442198/xbox-game-room-to-feature-over-1000-classic-arcade-games http://www.microsoft.com/presspass/events/ces/ http://kotaku.com/5443104/ Personally, it looks cool, but the per-play price is way out of scale. Given that you can buy full games for 80 MSP, 40 is a bit much. Where's the micro-transactions that were hyped when Live was first announced? Give me 5 point per-plays and I'll spend a lot more money here.

[.net] Getting rid of stale/wrong metadata in web service

16 July 2009 - 02:50 AM

OK, this is seriously ticking me off. I have a web service for allowing the entering of data through a WinForms apps. The web service references a DLL that contains an Item class where one of the members is an enum of bind types: None BindonPickup BindonEquip BindtoAccount The enums are stored in an assembly that's created dynamically as they're read from the database. Originally the enums were being created based on the exact text stored in the table, which had spaces between the names. I've fixed that and cleaned and rebuilt everything but for some reason the service refuses to recognize the new enum. I keep getting the following error when I try to call one of the web methods: System.ArgumentException: Identifier 'Bind on Pickup' is not CLS-compliant. WTF?!? I've even completely recreated the service from scratch 3 times and it just refuses to let go of the old data. Any tips would be helpful.

PARTNERS