Archive for the 'indie game development' Category

 

I will never buy an Adobe product ever again!

Jun 02, 2010 in consumer alerts, indie game development

About a year and a half ago I bought Adobe Photoshop CS3 Design Premium. Being a web developer and game developer have relied on these products heavily. I started Photoshop about a week ago and I get:  ”Licensing for this product has stopped working” and the program closes

Three days later, after running their Licensing removal tool at all levels, and following other exceptionally silly tasks found here, running the cs3 clean script and then totally reinstalling the junkware I am still having the same issue. I called customer support, but just did not have 45min to 1Hour of time to wait.

I have seen several threads online regarding this issue, some people report success, some are still not able to use their software. I wish I could report that I am one of those lucky enough to get it working again, but I am not. How sad is it that since there is not much competition in this space we tolerate this from adobe? This is not just poor software design, it is bad business! I paid full price for this software, and it should work when I run it damn it!

All I can say is be very wary if you are considering purchasing Adobe products.

XNA Tutorial: HLSL and SpriteBatch for 2D effects.

Jan 07, 2010 in CSharp, XNA, games, indie game development

After writing most of my first XNA game using the built in sorting capability of SpriteBatch, I ran into a pretty big problem. I wanted to add a HLSL effect to certain sprites. I followed the instructions I found, setting the SpriteSortMode to Immediate. What I did not realize at the time is Immediate means IMMEDIATE.

spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);

This means that you cannot rely on the spriteBatch.Draw method to sort for you, and must sort yourself.

I posted in the XNA forums, and learned that it is actually better to sort yourself. This way you know exactly how everything is working behind the scenes, and you can really improve upon the look by implementing same neat HLSL effects. Rewriting my draw functionality was not a huge undertaking but it did take some time.

For my purposes, I decided to create an object for handling everything needed to draw later on.

 class DrawableObject
    {
 
        public Texture2D Texture;
        public Vector2 Position;
        public Vector2 Origin;
        public Color Color;
        public float Rotation;
        public float Scale;
        public float Z_Index;
        public Rectangle DisplayRect;
        public DrawType DrawType;
        public Effect Effect;
        public Object ObjectRef;
 
        public DrawableObject(Texture2D texture, Vector2 position,Rectangle displayRect, Color color, float rotation, Vector2 origin, float scale, float z_Index, DrawType drawType, Effect effect, Object objectRef)
        {
            this.Texture = texture;
            this.Position = position;
            this.Origin = origin;
            this.Color = color;
            this.Rotation = rotation;
            this.Z_Index = z_Index;
            this.Scale = scale;
            this.DisplayRect = displayRect;
            this.DrawType = drawType;
            this.Effect = effect;
            this.ObjectRef = objectRef;
 
        }
    }

In this Object, DrawType is an enumeration used to mark each object so drawing can be handled differently depending on its type. For my purposes I had Player, Projectile, Shadow, etc
I then create a list of DrawableObjects to sort based on the z index.

List listToDraw = new List();
 
            for (int x = 0; x < playerManager.Players.Count; x++)
            {
                    //Add all my players as drawable objects
                    listToDraw.Add(new DrawableObject(playerManager.Players[x].PlayerAnimation.CurrentTexture, playerManager.Players[x].PlayerAnimation.ScreenPosition ,                   playerManager.Players[x].PlayerAnimation.DisplayRect, Color.White, 0f, Vector2.Zero, 1f, playerManager.Players[x].PlayerAnimation.ScreenPosition.Y) / Map.Height, DrawType.Player, playerManager.Players[x].PlayerAnimation.PlayerEffect,  playerManager.Players[x]));
              }

I then sort ….

           //Sort for the right order
            listToDraw.Sort(delegate (DrawableObject d1, DrawableObject d2) {return d2.Z_Index.CompareTo(d1.Z_Index);});

and then draw the list

 for (int x = 0; x < DrawObjectList.Count; x++)
                {
                    if (DrawObjectList[x].DrawType == DrawType.Player)
                    {
                        Player pn = (Player)DrawObjectList[x].ObjectRef;
 
                        spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
                        if (DrawObjectList[x].Effect != null )
                        {
                            DrawObjectList[x].Effect.Begin();
                            DrawObjectList[x].Effect.CurrentTechnique.Passes[0].Begin();
                        }
                        spriteBatch.Draw(DrawObjectList[x].Texture, DrawObjectList[x].Position, DrawObjectList[x].DisplayRect, DrawObjectList[x].Color,
                                         DrawObjectList[x].Rotation, DrawObjectList[x].Origin, DrawObjectList[x].Scale, SpriteEffects.None, DrawObjectList[x].Z_Index);
 
                        if (DrawObjectList[x].Effect != null)
                        {
                            DrawObjectList[x].Effect.CurrentTechnique.Passes[0].End();
                            DrawObjectList[x].Effect.End();
                        }
 
                        //etc etc.
                 }

Well I hope this helps someone looking for the same thing.

~J