Archive for the ‘Uncategorized’ Category

Free XBox buttons and controller graphics for your game…

Wednesday, June 13th, 2012

We’re still working on StarSuckers (working title Winking smile). And have had to create a lot of graphics from scratch to avoid copyright infringements. So I thought I would share these buttons and controllers I made, in case any of you could use them. Here are the buttons in 256x256, 128x128, 64x64 and 32x32 pixels. (download)

contactsheet

And the controllers in 256x256 pixels (download)

contactsheet_controllers

Enjoy Smile

Manipulating doublearrays – an extension method

Thursday, March 22nd, 2012
arraymanipulations

I’ve been fiddling around with returning JSON from an Asp.net MVC solution and getting it in Jquery using the $.getJSON method. Unfortunately – when the default JSON serializer in .net serializes my doublearrays it takes the values of the first column first, then the next column, etc. I would like it to serialize it as one row, then the next, etc.

I am aware that this is default behavior and that I could just populate the doublearray with rows as columns and vice versa, but I find it more intuitive to be able to refer to the first indexer in an array as x and the second as y, like this:

byte[,] data = new byte[3,3];
int x = 2;
int y = 1;
data[x,y] = 1;

Therefore I created a little extension method for manipulating doublearrays. You may find it helpful if you need to rotate an array, or swap values vertically or horizontally.

You can perform multiple operations by chaining the manipulations.

This is how you use it:

byte[,] data = new byte[3,3];
byte[,] manipulatedData =data.GetManipulatedCopy(ArrayManipulation.RotateClockwise);

Download Vs2010 project

Download Class file

Here is the complete class:

using System;

// Class with extensionmethods to manipulate doublearrays with
// Jakob Krarup (www.xnafan.net)
// Use, alter and redistribute this code freely,
// but please leave this comment

namespace ArrayManipulation
{

    /// <summary>
    /// Defines how to manipulate an array
    /// </summary>
    public enum ArrayManipulation
    {
        /// <summary>
        /// Moves all values around the array clockwise
        /// </summary>
        RotateClockwise,

        /// <summary>
        /// Moves all values around the array counterclockwise
        /// </summary>
        RotateCounterClockwise,

        /// <summary>
        /// Swaps all values from the top to bottom and vice-versa
        /// </summary>
        FlipTopToBottom,

        /// <summary>
        /// Swaps all values from left to right and vice-versa
        /// </summary>
        FlipRightToLeft
    }

    public static class ArrayExtensions
    {

        /// <summary>
        /// Implements easy doublearray manipulations
        /// </summary>
        /// <typeparam name="T">The type of the values in the array</typeparam>
        /// <param name="matrix">The doublearray</param>
        /// <param name="manipulation">How to manipulate the array</param>
        /// <returns>A copy of the array with the values as ordered</returns>
        public static T[,] GetManipulatedCopy<T>(this T[,] matrix, ArrayManipulation manipulation)
        {
            int width = matrix.GetLength(0);
            int height = matrix.GetLength(1);
            T[,] ret = null;
            switch (manipulation)
            {
                //if we are rotating the matrix,
                //we need to swap width and height sizes
                case ArrayManipulation.RotateClockwise:
                case ArrayManipulation.RotateCounterClockwise:
                    ret = new T[height, width];
                    break;

                //otherwise we create an array with the same size
                case ArrayManipulation.FlipTopToBottom:
                case ArrayManipulation.FlipRightToLeft:
                    ret = new T[width, height];
                    break;
                default:
                    throw new ArgumentOutOfRangeException("Invalid manipulation : " + manipulation);
            }

            //for all values in the source matrix...
            for (int y = 0; y < height; ++y)
            {
                for (int x = 0; x < width; ++x)
                {
                    //copy the values to the new array
                    //choosing position depending on the wanted manipulation
                    switch (manipulation)
                    {
                        case ArrayManipulation.RotateCounterClockwise:
                            ret[y, width - x - 1] = matrix[x, y];
                            break;
                        case ArrayManipulation.RotateClockwise:
                            ret[height - y - 1, x] = matrix[x, y];
                            break;
                        case ArrayManipulation.FlipTopToBottom:
                            ret[x, height - 1 - y] = matrix[x, y];
                            break;
                        case ArrayManipulation.FlipRightToLeft:
                            ret[width - 1 - x, y] = matrix[x, y];
                            break;
                    }
                }
            }

            //return the new array
            return ret;
        }
    }
}

Searchwords for Google: extensionmethod, rotate double arrays, manipulate two-dimensional, twodimensional arrays, non-jagged

We won a “Juror’s Special Pick” award!!

Wednesday, February 3rd, 2010

I had to leave Nordic Game Jam before the votes were counted in the semifinals. Apparently we first made it to the finals and then were picked by the juror Thor Frølich (Graphics Designer and Ninja Extraordinaire from IO Interactive). He liked the simplicity - that the game had one core gameconcept chase and the simplistic graphical expression.
Apparently (I wasn't there, but Rasmus was) suddenly everybody could see the benefits in our simple game as opposed to the graphically superior games :)
GREAT :)

To all the Teenage-Game-Tycoons out there :)

Thursday, January 28th, 2010

Someone posted on the XNA Forums about how all of his projects gradually slowed down and finally ground to a halt far from being finished and far from being anything like what he was striving for.

The original post was deleted while I was responding - but since I know there are many TGT's out there I thought I'd post it here.
If you're a TGT - this one's for you!

"Well if you want to hear my solution:

Do a little and do it well
Start out simple - but finish it!
If you have to create XNA-tic-tac-toe or XNA-Pong for you to finish a complete game including titlescreen, options and help, then by all means DO THAT :)
Better to have a fully finished game to show off, expand and learn from than 20 barely-begun projects laying around.

Be proud of what you do - because YOU did it!
This has worked for me in many endeavors.
Continually praise yourself saying "well done - you finished another sprite/method/class/level" and remind yourself of how far you've gotten on this project.
It is really a benefit to have high thoughts about what YOU produce - even despite what others may think or compare your games to. :)

Join hands - it just makes for better results :)
Only start something by yourself if you are content with failure or another "draft-gone-prealpha-gone-stale" :)
Find someone on the forums to make your first little game with. All gameprogrammers started small, but very few got to where they are today without the moraleboost of being in a group.

Go get'em tiger!

Kind regards - Jakob "xnaFan" Krarup"

XNA talk at AANUG

Wednesday, December 16th, 2009

xnacrashcourse_firstslideJust came home from Aalborg .Net User Group (AANUG) where I had the pleasure of introducing around 20 coders to XNA. We talked our way through a little quick and dirty "Let's make a PNG move across the screen using the keyboard" to

  • Proper methods of subclassing DrawableGameComponent.
  • Using ElapsedGameTime to make animation smooth
  • Storing services in Game.Services so components can communicate
  • Etc.

All in all a fun evening with a keen crowd. Thanks to the XNA coders present who supplemented my presentation where I lacked knowledge (XBOX360 specifics and the Indie concept).

The PowerPoint is in danish - so no need to download it if you don't speak that language 😉

Xna præsentation

Now in Widescreen :)

Wednesday, November 4th, 2009

Found the default WP theme (which I happen to like) in a wider format at http://www.cenolan.com/2008/11/wordpress-default-theme-1024-wide/.

Nice and easy to install - and with quite a bit more space for your XNA reading enjoyment.

Playable singleplayer version out :)

Sunday, November 1st, 2009

It's amazing what you can do with a few wellplaced questions. The AI for controlling the Oilbarrel in Climate Conflict only has a handful of IF's, but actually does an okay job :)

I will write a proper AI, breadth-first A* algorithm or similar, weighting tiles that are in the opponent's possesion higher.

The entire game also needs some finish as the graphics and music still don't give a cohesive appearance. But we're still building the framework for reuse as we go along.

I'm pretty happy with the AI implementation. My idea is that it should be possible to instantiate a Controller class which then gives input to the gamecomponent to control. The Controller is so far implemented in three different types:

  • KeyBoardController - listens for the users Up/Down/Left/Right keys and request to move in that direction (if possible).
  • RandomController - tries to go in one of the open directions when it enters a tile
  • SimpleDirectionController - tries to move towards a specific tile. This is used to steer the opponent around after his restock-place, but is just as usable to make enemies chase you :)

The abstract base class GameBoardControllerBase is implemented with a method that moves a playing piece forward, and if the piece crosses the center of the tile it calls the methods that are to be implemented in the specific controllers:

protected abstract void SetWantedDirection(Sprite controllee);
protected abstract void UpdateDirection(Sprite controllee);

The first method asks for a wanted direction (e.g. random, based on keyboard, networkplayer's input, recorded, etc...) and then UpdateDirection checks to see whether that is possible right now and adjusts for the current state of the gameboard.

It's working a charm though I've had to write a LOT more Console.WriteLine's than I have in a long time to figure out what the */(¤%(/% the AI was thinking at times :)

Go download the newest release at http://klimakonflikt.codeplex.com and let us have some feedback.

</Jakob>

Our game is published on codeplex

Monday, October 26th, 2009

The weekend 16-18 October I attended the Indie 9000 game coding competition.

The concept is intriguingly simple. Be there friday by 1600 hours, find out who else codes in your language (flash/xna/java/gamemaker/etc.) and chat for a couple of hours.

In the evening the theme of the competition is announced. Last time (February) it was "Horror", this time it was "Climate disaster". That set the frame for entries in the competition and we were given till midnight to come up with ideas and at midnight the first competition was held: The Pitching Competition.
Competitors were given up to 10 minutes to pitch their idea. There were some very interesting ones, ranging from "Destroy the earth" where all people must be punished for destroying earth, using only the powers of Nature. Others put you in the role of Law Enforcer where you had to beat up demonstrators at a climate summit. Lotsa fun ideas being tossed around.
Here's a video from our pitching (yes - we were the only ones who made a little play ;-)) http://www.youtube.com/watch?v=HojmWezSkW8

People teamed up and found graphics artists, sound producers and coders. Till sunday morning we barely slept, making up for it with plenty of strong coffee and bad jokes :)

We didn't win either "Best GrafX", "Best Original Sound" nor "Best Game", but we would have won "Had The Most Fun" if there was such a prize :))

The game we ended up making is "Climate Conflict" where the Oil industry dukes it out realtime with the TreeHuggers. The fractions are symbolized by an oil barrel and a sack of seeds respectively spreading oilpuddles and sowing flowers. Check it out - we are currently building a level editor (Jesper Niedermann) and improving both handling and AI. As we improve the game the lessons learnt will find their way into this blog.

The title screen for Climate Conflict

The title screen for Climate Conflict

It is the first time I've worked with a project hosted on CodePlex, but it worked a charm. Using Visual Studio.net 2008 and AnkhSVN for synchronizing with CodePlex was a great learning experience.

The project is at : http://klimakonflikt.codeplex.com/

Keep ideas and comments coming :)

- Jakob

Off to a running start… :)

Friday, October 23rd, 2009

Hi everybody. Well I finally took the dive into the binary fray of the Blog-O-sphere and here it is. A blog about my passion "Gamedevelopment".

In the times to come I will be creating a site with tutorials meant for beginners to get up-and-running, while posting API ideas,tools, etc. of my own creation.

Looking very much forward to getting started, sharing and reading your feedback.

- Jakob "XnaFan" Lund Krarup