![]() |
Multimedia »
DirectX »
General
Intermediate
Multiplayer Snake in 3D using C# and Managed DirectXBy Cr@zyIv@nA new version of the old game. |
C#, Windows, .NET 1.0, .NET 1.1, DirectX, VS.NET2003, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

Probably, everyone knows the game Snake. However, the Snake from this article is a multiplayer version and fully in 3D. It�s written in C# using Managed DirectX. A little knowledge of C# is necessary. And some (Managed) DirectX or other Graphics programming experience would be useful. I advise you, if you haven't already done so, to read Craig Andera's tutorial first.
You�ll need a C# compiler (Visual Studio .NET if possible). And the DirectX 9.0c SDK [Download it from Microsoft.]
For the code to run, you�ll also need a 3D card. But some adjustments in the code would enable it to run on older machines, decreasing its performance.
This is where initialization happens. Also, this is where user input is processed, using the EventKey class (all it does is check if a keystate is changed).
This class processes the input for the movement of one of the players. It holds a collection of Vectors for the trail. It has a Render method that will do the rendering. It also holds a reference to the Level class, the class that implements level functionality: a square array of Booleans so that the snakes can�t move through each other; it also has a couple of predefined levels to make the game a little less boring.
Here, two Meshes are created for some sort of intro movie.
This class renders the box in which the snakes move. It also renders the boxes which initially are already occupied by the Level class.
This is a class I built quite some time ago. It creates a textured box. And allows choosing the sides you want to render.
I do not expect this code to be efficient. A lot of things could�ve been done better and faster. But it works, and when you�ve got nothing to do, this game can be quite fun.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 12 Aug 2004 Editor: Smitha Vijayan |
Copyright 2004 by Cr@zyIv@n Everything else Copyright © CodeProject, 1999-2009 Web19 | Advertise on the Code Project |