ASP.NET
  Home arrow ASP.NET arrow .Netterpillars: Artificial Intelligence an...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

.Netterpillars: Artificial Intelligence and Sprites, Part 2
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2005-01-11

    Table of Contents:
  • .Netterpillars: Artificial Intelligence and Sprites, Part 2
  • The Branch Class
  • Main Program and GameEngine Class
  • Second Draft: Coding the Player Character
  • Main Program and GameEngine Class
  • Third Draft: Coding the Game Engine and Collision Detection
  • Fourth Draft: Coding the Config Screen and Game Over
  • Coding for the Introduction Screen
  • Final Version: Coding the Netterpillars AI
  • The Main Program: Final Version
  • Further Improvements

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    .Netterpillars: Artificial Intelligence and Sprites, Part 2


    (Page 1 of 11 )

    In this article on artificial intelligence, you will take a computer game from first draft to final version. It is excerpted from chapter two of the book Beginning .NET Game Programming in C#, by Ellen Hatton et. al. (Apress, 2004, ISBN: 1590593197) and is the second of two parts.

     

    The Coding Phase

    As you did in the previous chapter, you’ll start coding the basic objects for the game (simplest first), and then tackle the more difficult code of the game engine and the netterpillar AI classes.

    To allow you to test every new method created, you’ll do your code in five steps:

    1. First draft: Code the static objects.

    2. Second draft: Code the player character.

    3. Third draft: Code the game engine and collision detection.

    4. Fourth draft: Code the configuration screen and game over.

    5. Final version: Code the netterpillars AI.

    The details of each of these versions are shown in the next sections.

    First Draft: Coding the Static Objects

    In the next sections, we show the code and discuss the details of the classes for the static objects, mushrooms, and branches, and create an early version of the main program and the GameEngine class, so you can test these classes.

    The Sprite Class

    You’ll only add a new property in this class, the IMAGE_PATH constant, which will be used by all the child classes to compose the full path from where the images should be loaded.

    The Mushroom Class

    There’s not much to say about the Mushroom class. It just has an overloaded constructor that creates a sprite with the mushroom drawing, to be used instead of the original sprite constructor with a parameter. This will allow cleaner code when creating mushrooms.

    public class Mushroom : Sprite {
      public Mushroom() {…}
    }


    The code for the constructor will be as follows:

    public class Mushroom : Sprite {
      public Mushroom() :
        base(Application.StartupPath+”\\”+IMAGE_PATH+
             ”\\Mushroom.gif”) {}
    }

    Note that all you do is call the base class’s new method, passing the appropriate parameters.


    NOTE When a child class defines a method that already exists in the base class, any object created from the child class will call the code in the method of this class, unless you explicitly call the base class method, as in the preceding code sample (using base() after the colon, plus any necessary parameters).

    This chapter is from Beginning .NET Game Programming in C# by Ellen Hatton et al. (Apress, 2004, ISBN: 1590593197). Check it out at your favorite bookstore today. Buy this book now.

    More ASP.NET Articles
    More By Apress Publishing


     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek