XNA Arcade Remix: Snake

  EDIT: The published game can be found here. I don’t think that the crappy youtube video gives this game justice.

   Over the past few days I’ve been working on a small side-project hoping to help me learn A* and other pathfinding algorithms. It’s a remix of the classic game Snake; where the snake must eat the “apple” to increase his light supply, which eventually diminishes and the game ends. There is also two different “apples”: a blue light and red light (or “Firefly”). The blue light allows the play to generate a path to the green light by pressing X, once collected. The Firefly must be contained before it spawns. The video below will demonstrate this better than I can explain it:

(sorry if you don’t like the music, I just got the Mongol Movie Soundtrack 😛

   I just made this for fun. Hopefully, in the future, I will become a member of the XNA Creators Club and will be able to play this on Xbox 360; it is that addicting.

Advertisements

~ by IG on December 30, 2008.

7 Responses to “XNA Arcade Remix: Snake”

  1. Nice, I like how the light is very short-ranged and you don’t know whether you will run into yourself. I like how you pulled off the “no-walls” Snake. If only people could see that remaking games isn’t so bad…

  2. Yeah really, as long as you give them a modern twist, arcade games can still be interesting. Especially on handhelds…though unfortunately I don’t have any money for a Zune atm. Would be nice though.

  3. It looks great!

    I’ve just started programming in XNA and I can’t for the life of me work out how you did those lighting effects!

    I’d be really grateful if you could point me in the direction of a relevant tutorial, or give me a pointer to get started!

  4. Hi fatso, I really liked the glow effect on the “apples”. Apples are truly weird where you live. By the way, I linked to your site on my blog because it’s really an interesting place to get ideas. My blog is actually tutorials and thoughts on integrating functionality in a tile-game engine.

    I plan on showing many things like AI (using Finite-State-Machine and/or Fuzzy-State-Machine), path-finding using A*. Having NPCs walking on paths added from the editor is one of my goal. I’m far from there with my own engine but I’m having quite a lot of fun doing all this.

    I wanted to tell you your engine truly seems to rock. Day/Night with full-screen effects (are they full screen animated sprites or are they generated real-time?). You gave me a lot of idea for my engine and I truly hope I will do the same while working on my blog.

    One thing I was wondering, Do your engine support parallax scrolling (having some layer scroll faster than others). This would create false 3d in your game. Using it in dungeons and such, would let you add depth to your maps. It’s an essential effects in Platformers but it could also be interesting in RPGs, if, for example, you wanted to show the sky at some time (you know, the classic cliff-side with the night-sky in a distance). The sky, shouldn’t scroll but you could still use a tile-layer for it.

    Ok.. my post is too long! Good luck with your projects. If you ever need help or anything, come by my blog. 😉

  5. Slossius:

    There is no tutorial I followed that helped me create this game; it was built from prior knowledge. I can tell you basically what I did to create the lighting effects, though this is all very technical. I used the distance formula, sqroot of [x1-x2 squared plus y1 – y2 squared], (which is basic math) then set the alpha of the grid square to 1 over that number. Then, by creating the colors using Vector4s, I could control the color added based on the object, i.e., a red apple would add more to red, etc. This is essentially what I did, while not exactly. My advice is just to mess with it until it works.

    boomwav: Thanks for linking to this site, I appreciate your support! The community needs a leader and a teacher of XNA RPGs, there’s too much talk and not enough action. I’m hoping to see an RPG in Community Games in the next year, to hear you’ll aid in this goal is music to my ears. Good luck!

  6. Is the code for this available I’d like to see you implementaion of the distance formula

    • public Vector4 CalcAlpha(int x, int y) //x and y is the value of the current tile on the grid //in an int[,] array
      {
      Vector4 color;
      Vector3 white = Color.White.ToVector3();
      float alpha = 1f;
      double yDif = (double)y – (double)(light.Y / (cellSize-2)); //location of light=head of the snake
      double xDif = (double)x – (double)(light.X / (cellSize-2));

      float distance = (float)Math.Sqrt(yDif * yDif + xDif * xDif);

      alpha = 1f – distance / radius;

      I used this function to generate the color. The “lightness” is the alpha value. The other code used to blend colors is irrelevant to the question. The float “radius” is gradually decreasing, which increases the distance/radius value, thus decreasing the alpha value and the transparency of the tile. It’s a simple use of the distance formula, yet it’s at the core of the program.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: