skriker

AnimeWorld
(3D Game Using DirectX 9 and C#)

author - malyfred / 2004-12-15

AnimeWorld (school project) is small and VERY SIMPLE example of using C# and DirectX. I am a complete beginner on this field and I had to fight quite a lot with STUPID MSDN to finish this program. DirectX is badly documented piece of …… at the moment and most of examples that can be found on internet don't work as you need so I have decided to offer this example to other newbies.

It's 3D game (something like Half Life 2 or Doom 3:o) where you collect items and shoot at everything that moves.

Here are some screenshots:

Controls

  • W, S, A, D – moving
  • Mouse – look around
  • E – open hidden doors
  • U – reverse up/down mouse move
  • Mouse button – shooting
  • T – telescope
  • L – turn on/off the lights
  • F – change texture mipmaps
  • I – change skin
  • F1 – fullscreen
  • F2 – back to window
  • Esc – quit

Map

You can create your own map! It's located in /data/bludiste.txt. In the first line of this plain text file is specified size of your map. You can use these symbols:

  • space – space:o)
  • '*' + 'a'…'n' – walls
  • 'S' – starting position (MUST BE!)
  • 'A'…'G' – hidden doors
  • 'H'…'N' – walls
  • 'O'…'R' – targets
  • 'T'…'Z' – collectable item
  • '#' – not collectable item

Installation

You need DirectX (I think 9.0 or higher is necessary, but I have not tested lower versions.)
You need .Net Framework 1.1 (or higher?)
When you have DirectX and .Net installed you can try to run the AnimeWorld.exe but it probably doesn't work – you have to install the Managed DirectX. It means that you have to run mdxredist.msi from ManagedDX.CAB. This .cab file is in the directory where you have unpacked DirectX at the beginning of installation.

That's all – enjoy the game:o)

Source Code

Of course the example is good for nothing when you cannot see souce code – everything is located in src directory. (MS Visual Studio project and all source files) I am REALLY sorry for some czech words and error messages, but I am not going to fix it. This project is partly based on D3DUT framework that is being developed at University of West Bohemia. D3DUT should allow you in near future to move your DirectX projects to Linux and OpenGL…huh:o) But don't worry – I have used just some functions from this framework (fullscreen…).

Last Word

In the left upper corner: FPS, collected items/remaining items, hit targets/remaining targets, time from start in miliseconds – it stops when you have got all items and targets. Don't forget to turn on your speakers and look at your belly!

Download

AnimeWorld.zip – 596kB

Comments

  1. Lemon 2005-03-16 / 2.48 pm

    Nice.

  2. Hamid 2005-05-24 / 6.16 am

    Tank a lot
    I download this file for work with direct & c#
    if u Have any program i will happy recive that!
    with best wishes
    Hamid From C# World

  3. Euqil 2005-08-10 / 8.18 am

    Fakt super / pretty sweet !!!!
    Dikes za zdrojaky :) / Thx 4 src !

  4. abbas 2005-10-28 / 5.56 pm

    hi dear.
    i’m c# programmer.
    i want to build c# application in directx technology.
    i want to use directx to show database list.
    my application is medical software and in all forms i use database.
    help me please .
    C# is good for build ir?

  5. malyfred 2005-10-29 / 1.23 pm

    abbas> Are you sure that you want to use DirectX for database list? Do you have any special reason to do that?

  6. dotJEM 2005-10-31 / 9.09 pm

    Hey…

    Ofc. the sample does not work for me (Dohh, nice gues)…
    But hey not the matter… im alreaddy deep in the DirectX and OpenGL world (Mostly OpenGL)… so i thougt i would share something with u if it was unknown…

    But check out GameDev.net, this is a really good resource for help on most things conserning game development… (DirectX, OpenGL, Game Physics, Game Math, Networking for games ect. ect. ect.)…

    (Note that theres aparently some problems with the site ATM, so be patient and try again)…

    And happy hunting… ^^

  7. le quang song 2006-01-14 / 2.21 pm

    My name Song.I’m very glad when have a game to learn.But when I run it why it could’t run .A error is
    “Soubor ‘bludiste.txt’, obsahující mapu, není k nalezení.
    Press any key to continue”
    Please help me repair this error.
    I am student at VietNam.I am doing project at school about 3D Game about C# and DirectX.Can you for me some of game3D to consult ,learn and finish my project.
    Please send your idea by my mail.
    Thanks a lot for your help.

  8. malyfred 2006-01-14 / 2.44 pm

    le quang song:: As I said I am sorry for czech messages but I’m not gona to fix it.

    Anyway – it says that the file “bludiste.txt” is missing. You need that file because the map of the world is defined inside.

    Just check if you have unpacked the archive properly. The directory “data” mus be in the same place as the .exe file.

  9. Samer W Al Qutob 2006-04-01 / 7.01 pm

    Hi

    I’ve been working with C# for a while and now I would like to learn 3D programming using DirectX. I am looking for tutorials and examples when I found this page.
    Could you please point me to some good DirectX using C# Tutorials.

    Thank You

  10. Umut Uğrak 2006-04-08 / 11.02 am

    Hi.Im new to programming.Im learning c# and directx 9 and ı want to make a simulation for my school project.İn this project ,think that there is three floors and you can walk look with mouse and do the basic things in a fps game.there will be only collision.ı mean it will be a easy engine.which sites you suggest to me.can ı do this kind of engine in the animeengines method.can you give me some examples.
    sorry for my bad english
    really sorry:)but your english is bad too:)thank you

  11. malyfred 2006-04-08 / 9.05 pm

    Umut Uğrak:: Well, the Animeworld is that simple that collisions are solved only in 2D but the main file could be useful for you to lear how to do the basic things in DirectX.

    That’s the main reason why I’ve decided put it on the web. There are not very many simple but useful examples about basics of DirectX in C#.

  12. Nizami 2006-06-15 / 9.06 pm

    It’s good and plz help me more in creating games using C#

  13. Umut Uğrak 2006-06-27 / 11.50 pm

    I want to ask what is D3DUT?What it does usual?Can you tell me a little?thanks

  14. Fareed Nizami 2006-07-09 / 9.51 am

    hey,
    you did marvelous work pal,
    it must be very important for beginers
    Regards

  15. nadir 2006-08-03 / 3.28 pm

    i am very pleased to have a this kind of software ,i am actually a student of master in computer science,and i have a project of 3d game programming in microsoft c# plateform.i need more help regarding to this ,i will be thank full.

  16. Snake 2007-02-13 / 9.26 am

    hey
    firstly let me say nice work.
    i have been looking on the net for a sample for some time now.

  17. Dina 2007-06-10 / 6.05 pm

    hi dear,
    i am a c# programmer and i want to be agame development using DirectX
    can you help me to start my long way?
    and how to start?

    and what is your device for me?

  18. MalkEvange 2007-08-06 / 9.36 pm

    Interesting article!
    Where can I find more on this theme?

  19. XRage 2007-10-01 / 3.41 pm

    Thanks buddy. Good job.

  20. sash 2007-10-30 / 7.08 pm

    Hi

    I have VS2005, i can run the exe fine but when I compile i get 14errors??? heeeeelp :-(

    Error 4 The best overloaded method match for ‘Microsoft.DirectX.Direct3D.Device.Device(int, Microsoft.DirectX.Direct3D.DeviceType, System.Windows.Forms.Control, Microsoft.DirectX.Direct3D.CreateFlags, Microsoft.DirectX.Direct3D.PresentParameters)’ has some invalid arguments D:\DirectX Samples\AnimeWorld\AnimeWorld\src\Runtime.cs 135 16 D3DUT
    Error 5 Argument ‘5’: cannot convert from ‘Microsoft.DirectX.Direct3D.PresentParameters[]’ to ‘Microsoft.DirectX.Direct3D.PresentParameters’ D:\DirectX Samples\AnimeWorld\AnimeWorld\src\Runtime.cs 135 96 D3DUT
    Error 6 The best overloaded method match for ‘Microsoft.DirectX.Direct3D.Device.Reset(Microsoft.DirectX.Direct3D.PresentParameters)’ has some invalid arguments D:\DirectX Samples\AnimeWorld\AnimeWorld\src\Runtime.cs 171 7 D3DUT
    Error 7 Argument ‘1’: cannot convert from ‘Microsoft.DirectX.Direct3D.PresentParameters[]’ to ‘Microsoft.DirectX.Direct3D.PresentParameters’ D:\DirectX Samples\AnimeWorld\AnimeWorld\src\Runtime.cs 171 20 D3DUT
    Error 8 The best overloaded method match for ‘Microsoft.DirectX.Direct3D.Device.Reset(Microsoft.DirectX.Direct3D.PresentParameters)’ has some invalid arguments D:\DirectX Samples\AnimeWorld\AnimeWorld\src\Runtime.cs 192 7 D3DUT
    Error 9 Argument ‘1’: cannot convert from ‘Microsoft.DirectX.Direct3D.PresentParameters[]’ to ‘Microsoft.DirectX.Direct3D.PresentParameters’ D:\DirectX Samples\AnimeWorld\AnimeWorld\src\Runtime.cs 192 20 D3DUT
    Error 10 The best overloaded method match for ‘Microsoft.DirectX.Direct3D.Device.Reset(Microsoft.DirectX.Direct3D.PresentParameters)’ has some invalid arguments D:\DirectX Samples\AnimeWorld\AnimeWorld\src\Runtime.cs 252 7 D3DUT
    Error 11 Argument ‘1’: cannot convert from ‘Microsoft.DirectX.Direct3D.PresentParameters[]’ to ‘Microsoft.DirectX.Direct3D.PresentParameters’ D:\DirectX Samples\AnimeWorld\AnimeWorld\src\Runtime.cs 252 20 D3DUT
    Error 12 The name ‘SpriteFlags’ does not exist in the current context D:\DirectX Samples\AnimeWorld\AnimeWorld\src\AnimeWorld.cs 356 20 D3DUT
    Error 13 ‘Microsoft.DirectX.Direct3D.Sprite’ does not contain a definition for ‘Draw2D’ D:\DirectX Samples\AnimeWorld\AnimeWorld\src\AnimeWorld.cs 365 14 D3DUT
    Error 14 The name ‘SpriteFlags’ does not exist in the current context D:\DirectX Samples\AnimeWorld\AnimeWorld\src\AnimeWorld.cs 369 20 D3DUT
    Error 15 ‘Microsoft.DirectX.Direct3D.Sprite’ does not contain a definition for ‘Draw2D’ D:\DirectX Samples\AnimeWorld\AnimeWorld\src\AnimeWorld.cs 373 14 D3DUT
    Error 16 The name ‘SpriteFlags’ does not exist in the current context D:\DirectX Samples\AnimeWorld\AnimeWorld\src\AnimeWorld.cs 378 19 D3DUT
    Error 17 No overload for method ‘DrawText’ takes ‘5’ arguments D:\DirectX Samples\AnimeWorld\AnimeWorld\src\AnimeWorld.cs 386 4 D3DUT

  21. malyfred 2007-10-30 / 7.41 pm

    This code is old… very old. It’s written under .NET1.1 and it probably cannot be compiled with .NET2.0 or higher (.NET3.5 is the latest version I’m aware of). The other problem could be the incompatibility of DirectX.

  22. samaq 2007-11-08 / 9.54 am

    I have trouble when i begin with directx. This help me alot. Thank.

  23. jorgerosa 2008-04-01 / 9.36 pm

    Thanks malyfred.
    Any C# OpenGL examples around?

  24. david 2008-06-28 / 9.21 pm

    Thanks
    Good job.

  25. M. Gokhan BAKAL 2008-10-12 / 1.13 pm

    before thank you for this application and web site. Which is Directx 9.0 SDK download but small time and not price? I will wait your answers. Thank you for all….

  26. Nescius 2008-10-12 / 6.49 pm

    http://eisenstern.com/ http://sauerbraten.org/ and http://cubeengine.com/ are specially designed for easy map creation, they are both opensource and dont need directx, just opengl and some C – cool easy and ported to everything!

  27. asMe 2008-12-16 / 10.16 pm

    hey! thats really nice ,i also new in this field ,Do you have any idea of how to load an animated mesh/.x model in C# using DirectX9.?

    Please help me ,i m done with static one ,but this animated mesh is creating problem.

  28. asMe 2008-12-22 / 6.03 pm

    Hey there! i am trying to run this code , But its giving some errors like thiss

    -The type or namespace name ‘MouseButton’ could not be found (are you missing a using directive or an assembly reference?)C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Check\Check\MouseEventArgs.cs 75 41 D3DUT
    -The type or namespace name ‘Key’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Check\Check\KeyEventArgs.cs 14 13 D3DUT
    -The type or namespace name ‘Key’ could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Check\Check\KeyEventArgs.cs 34 12 D3DUT
    -‘ZCU.Graphics.D3DUT.KeyEventArgs.Key’ is a ‘property’ but is used like a ‘type’ C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Check\Check\KeyEventArgs.cs 43 61 D3DUT

    Can please tellme from where i can get this D3DUT library..So i can run this code.. as you have added reference of D3Dut.So please help me out.

  29. عباس 2009-02-11 / 9.40 am

    هستمC# Programmer سلام بچه ها منم مثل شما
    با DirectX9 نيزآشنا هستم

  30. reader 2009-08-13 / 10.53 am

    I didn’t have ne problems compiling or even playing this game. Nice work. But It would be nice to have a bit more in-depth explanation of whats happening in the code.

  31. Saeed 2009-09-02 / 11.43 pm

    Hi
    Tnx 4 src
    i have a problem in my character movment
    can u help me?
    plz mail me if you can
    its got a tiny time of yours
    Tnx again

  32. Saeed 2009-09-03 / 5.00 am

    my mail is saeed_masoumi_1987@yahoo.com

  33. sadegh 2010-03-26 / 1.33 pm

    saLLam saeed jan
    haLet khobe
    saLe jadid ro behet tabriiK migam
    ye zahmat vasat daram
    man mikham to c# 3d benvisam
    yani mikham Shoro konam
    shoro be 3d neveshtan
    vaLi nemidoonam bayad az koja shoro konam
    age ketabi hast ya siti ke bedard bokhore
    mishe behem moarefi koni Lotfan
    az Lotfet mamnoon misham
    ghorbane u
    bazam eydo behet tabriik migam

  34. fereshteh 2010-04-27 / 12.19 pm

    thanke you for this file.

  35. Dag 2010-06-27 / 7.49 pm

    Thanx! This was really fun to play around with. Seems the game is unable to use more than one of my processors core… So one of them is working at 100% while the other doesn’t do shit.. Further was I not able to compile the source code in .NET 2.0.. but any way, nice to see that it is possible to create games in C#.

Sorry, the comment form is closed at this time.

© 2004 - 2018 malyfred