ASP.NET
  Home arrow ASP.NET arrow Page 2 - .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
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 2
    2005-01-04

    Table of Contents:
  • .Netterpillars: Artificial Intelligence and Sprites
  • Object-Oriented Programming
  • Artificial Intelligence
  • Line of Sight
  • Use Your Imagination
  • Coding the Sprite Attributes
  • The Game Proposal
  • The Sprite Class
  • The Main Program Structure

  • 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 - Object-Oriented Programming


    (Page 2 of 9 )

    There are many technical books that explain the academic details of object-oriented analysis (OOA) and object-oriented programming (OOP). It’s not our goal to enter into such particulars, but instead loosely define a few terms and demonstrate some practical uses of these techniques.

    The main idea behind creating objects is to make your code simpler to write and easier to maintain. By creating high-level objects to take care of specific tasks, you can build your games using these objects without needing to remember every tiny detail about a new game.

    A good analogy is a house. A house is composed of many different rooms with many purposes, and in any neighborhood, you’ll find a variety of shapes and sizes of homes, each uniquely defined by characteristics such as shape, size, and color. However, a house is built from a template, usually a blueprint, which describes how that house can be built in a repeatable way. You can even break the house down into smaller pieces called subsystems, which provide certain functions in a repeatable way (plumbing, electricity, and heating are simple examples). These subsystems are themselves built from repeatable and reusable components. In the case of an electrical subsystem, you have switches, outlets, and wiring.

    The fundamental point is that good object-oriented approaches tend to mimic real-world environments and systems, and that these systems are often able to be used in even more complex systems.

    Table 2-1 lists some common terms used when talking about object-oriented programming and analysis, along with a definition of each.

    TERM DEFINITION
    Class The code you write that is used as a blueprint to create objects. It describes the characteristics of an object: what kind of attributes it has, how it can be asked to do things, and how it responds to events.
    Object An instance of a class. Generally created by invoking a class’s constructor.
    Methods Functions defined inside a class. Generally speaking, a method describes an action that the object can be told to do.
    Properties or attributes

    Variables defined inside a class. Class attributes typically describe the qualities (state) of the object. In some cases, attributes might not be accessible to the user of an object because you (the author) have decided those attributes should not be easily modified by a user. Properties are a special type of attribute that let you define more complex ways to read or write to an attribute.

    Events Methods in the object triggered by an external action. May be associated with a user action (such as clicking a button) or a system action (such as a specific time slice that has elapsed).
    Constructor Special method called when creating an object—in C#, this is done by using the keyword “new” followed by the class name.
    Destructor Special method called when the object is being destroyed. In C#, to code the destructor you have to override (see the Overriding entry) the Dispose method of the base class. However, because of the automatic garbage collection found in the common language runtime, explicitly calling a destructor is rarely needed.
    Inheritance Object-oriented concept that defines that one class can be derived from another class or classes (called base classes), and inherit their interface and code (called the derived or child class).
    Overriding Object-oriented concept that defines that a derived class can create a different implementation of a base class method. In effect, it completely overrides the base class’s behavior.
    Interface A “contract” that defines the structure of methods, properties, events, and indexers. You can’t create an object directly from an interface. You must first create a class that implements the interface’s features.
    Encapsulation The concept of gathering methods, properties, events, and attributes into a cohesive class and removing the details from the user. An example of encapsulation would be a car—you operate a car by steering, braking, and accelerating. Good encapsulation removes the need for you to worry about managing fuel injection flow, brake fluid hydraulics, and proper internal combustion.
    Overloading Object-oriented concept that states that one method can have many different interfaces, while keeping the same name.

    Table 2-1. Common Object-Oriented Terminology

    Polymorphism Object-oriented concept that says that different objects can have different implementations of the same function. An Add method, for example, can sum integers and concatenate strings.


    NOTE We’ll refer to these concepts and terms throughout the rest of the book, reinforcing their meanings as we go along.

    Continuing with the introductory concepts of this chapter, let’s talk about artificial intelligence, demonstrating a real-life application of this concept born in science fiction books. 

    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 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek