Difference between revisions of "Game Programming Class9"

esse quam videri
Jump to: navigation, search
m (Text replacement - "syntaxhighlight lang="csharp" line="1" " to "syntaxhighlight lang="csharp"")
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
http://research.microsoft.com/apps/video/default.aspx?id=145653
 +
http://research.microsoft.com/pubs/145347/BodyPartRecognition.pdf
 +
 +
 
==Review Midterm Games==
 
==Review Midterm Games==
Inclass
+
Inclass look @ Midterm game
 +
 
 +
 
 +
Discuss components and dependencies
 +
 
 +
Visible and Hidden Dependencies
 +
http://www.c-sharpcorner.com/UploadFile/b1df45/dependency-generalization-association-aggregation-compos/
 +
 
 +
Dependencies in Unity
 +
 
 +
 
 +
==Chase and Evade==
 +
 
 +
==Change to IntroGameLibrary==
 +
<syntaxhighlight lang="csharp">
 +
public virtual void SetTranformAndRect()
 +
        {
 +
            //The first time this is called the spritetexture may not be loaded
 +
            //try and catch is too slow
 +
            if (this.spriteTexture != null)
 +
            {
 +
                    // Build the block's transform
 +
                    spriteTransform =
 +
                        Matrix.CreateTranslation(new Vector3(this.Orgin * -1, 0.0f)) *
 +
                        Matrix.CreateScale(this.Scale) *
 +
                        Matrix.CreateRotationZ(0.0f) *
 +
                        Matrix.CreateTranslation(new Vector3(this.Location, 0.0f));
 +
 
 +
                    // Calculate the bounding rectangle of this block in world space
 +
                    this.locationRect = CalculateBoundingRectangle(
 +
                            new Rectangle(0, 0, this.spriteTexture.Width,
 +
                                this.spriteTexture.Height),
 +
                            spriteTransform);
 +
               
 +
            }
 +
        }
 +
 
 +
</syntaxhighlight>
 +
 
 +
from
 +
 
 +
<syntaxhighlight lang="csharp">
 +
public virtual void SetTranformAndRect()
 +
        {
 +
            if (this.Game.Content != null)
 +
            {
 +
            try
 +
            {
 +
                // Build the block's transform
 +
                spriteTransform =
 +
                    Matrix.CreateTranslation(new Vector3(this.Orgin * -1, 0.0f)) *
 +
                    Matrix.CreateScale(this.Scale) *
 +
                    Matrix.CreateRotationZ(0.0f) *
 +
                    Matrix.CreateTranslation(new Vector3(this.Location, 0.0f));
 +
 
 +
                // Calculate the bounding rectangle of this block in world space
 +
                this.locationRect = CalculateBoundingRectangle(
 +
                        new Rectangle(0, 0, this.spriteTexture.Width,
 +
                            this.spriteTexture.Height),
 +
                        spriteTransform);
 +
            }
 +
            catch (NullReferenceException nu)
 +
            {
 +
                //nothing
 +
                if (this.spriteTexture == null)
 +
                {
 +
                    //first time this will fail because load content hasn't been called yet
 +
                   
 +
                }
 +
                else
 +
                {
 +
                    throw nu;
 +
                }
 +
            }
 +
            catch( Exception ex)
 +
            {
 +
                throw ex;
 +
            }
 +
 
 +
        }
 +
</syntaxhighlight>
 +
 
 +
==Using a sprite manager to manage groups of sprites==
 +
 
 +
Often times it's easier to manage groups of objects if they are contained in a class that manages them.
 +
 
 +
I often use this pattern when I have many objects that need to act a a group.
 +
 
 +
In class demo of https://iam.colum.edu:8443/svn/XNAProg/trunk/Jeff/IntroObserver/
 +
 
 +
==Events==
 +
 
 +
Simple events project.
 +
 
 +
https://iam.colum.edu:8443/svn/XNAProg4/trunk/XNA4Jeff/ConsoleApplicationPacManEvents/ConsoleApplicationPacManEvents/Program.cs
 +
 
 +
There is a larger project in XNA called GameIntro events. This project demos a timer event and events that cross game components.
 +
 
 +
==Observer==
 +
 
 +
Observer
 +
:Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
 +
 
 +
Observers
 +
 
 +
http://www.dofactory.com/Patterns/PatternObserver.aspx
 +
 
 +
Observer is a design pattern that is often used to publish (push) or subscribe (pull) changes in the stae of one object to other interested object. It encourages loose coupling of objects.
 +
 
 +
The object the get the data often called the subject then notifies the observing objects of the change. The observing object will often repond to the subject.
 +
 
 +
 
 +
[[Image:Observer.gif]]
 +
 
 +
Here is a real example in c#. In this example a stock (the subject) notifies and investor (the observer) of a change in price.
 +
 
 +
[[Image:ObserverStocks.png]]
 +
 
 +
Simple observer project https://iam.colum.edu:8443/svn/XNAProg4/trunk/XNA4Jeff/ConsoleApplicationPacManObserver/Program.cs
  
==Stacks==
+
Bigger implementation in Project IntroObserver
  
  
==Screen Manager==
+
==Ship to XBox==
 
In class demo
 
In class demo
IntroScreenz.zip
+
 
 +
*Creators Club
 +
*Deploy to XBox360 with visual studio
 +
*Package for deployment
  
 
==Homework==
 
==Homework==
Add screen to 2D Game
+
 
 +
==Test Each Others Games==
 +
 
 +
I created a forum in BB. I'd like everyone to test everyone other game. Please create a post for each game you are reviewing. We are looking for general play-ability, graphics, sound, game mechanics, and overall enjoyment.
 +
 
 +
You post should comment on all of these items. If you notice any bugs or crashes please write them up thoroughly. Also if you have any suggestions or comments that you think might make the game better please post these as well.
 +
 
 +
USE the Perfection Game technique I talked about in class.
 +
 
 +
As the game developer please respond to any bugs or suggestions with the criteria below.
 +
 
 +
 
 +
 
 +
===Criteria===
 +
 
 +
Bugs
 +
 
 +
'A' Bug
 +
:Cannot Release Game. Crashes, Spelling, Copyright, Not playable, not fun
 +
 
 +
'B' Bug
 +
:Unfortunate Release, able to deal with bugs
 +
 
 +
'C' Bug
 +
:Nice to fix
 +
 
 +
'D' Bug
 +
:Nice to add features
 +
 
 +
CNR
 +
:Can not replicate
 +
 
 +
NMI
 +
:Need more info
 +
 
 +
NAB
 +
:Nat a bug it's a feature
 +
 
 +
WAS
 +
:Works as designed
 +
 
 +
WNF
 +
:Will not fix
 +
 
 +
Soaking: Soaking is letting your software run for a long time to look for memory leaks or counting errors.
 +
 
 +
Let you game soak for a few hours and see what happens.
 +
 
 +
You may need to modify your game slightly for soaking.
 +
 
 +
<!--===Game Website===
 +
 
 +
Create a website for your game.
 +
 
 +
http://iam.colum.edu/Students/LogonName/XNA/Game1
 +
 
 +
Create a website to host you game.-->

Latest revision as of 03:23, 9 February 2016

http://research.microsoft.com/apps/video/default.aspx?id=145653 http://research.microsoft.com/pubs/145347/BodyPartRecognition.pdf


Review Midterm Games

Inclass look @ Midterm game


Discuss components and dependencies

Visible and Hidden Dependencies http://www.c-sharpcorner.com/UploadFile/b1df45/dependency-generalization-association-aggregation-compos/

Dependencies in Unity


Chase and Evade

Change to IntroGameLibrary

public virtual void SetTranformAndRect()
        {
            //The first time this is called the spritetexture may not be loaded
            //try and catch is too slow
            if (this.spriteTexture != null)
            {
                    // Build the block's transform
                    spriteTransform =
                        Matrix.CreateTranslation(new Vector3(this.Orgin * -1, 0.0f)) *
                        Matrix.CreateScale(this.Scale) *
                        Matrix.CreateRotationZ(0.0f) *
                        Matrix.CreateTranslation(new Vector3(this.Location, 0.0f));

                    // Calculate the bounding rectangle of this block in world space
                    this.locationRect = CalculateBoundingRectangle(
                             new Rectangle(0, 0, this.spriteTexture.Width,
                                 this.spriteTexture.Height),
                             spriteTransform);
                
            }
        }

from

public virtual void SetTranformAndRect()
        {
            if (this.Game.Content != null)
            {
            try
            {
                // Build the block's transform
                spriteTransform =
                    Matrix.CreateTranslation(new Vector3(this.Orgin * -1, 0.0f)) *
                    Matrix.CreateScale(this.Scale) *
                    Matrix.CreateRotationZ(0.0f) *
                    Matrix.CreateTranslation(new Vector3(this.Location, 0.0f));

                // Calculate the bounding rectangle of this block in world space
                this.locationRect = CalculateBoundingRectangle(
                         new Rectangle(0, 0, this.spriteTexture.Width,
                             this.spriteTexture.Height),
                         spriteTransform);
            }
            catch (NullReferenceException nu)
            {
                //nothing
                if (this.spriteTexture == null)
                {
                    //first time this will fail because load content hasn't been called yet
                    
                }
                else
                {
                    throw nu;
                }
            }
            catch( Exception ex)
            {
                throw ex;
            }

        }

Using a sprite manager to manage groups of sprites

Often times it's easier to manage groups of objects if they are contained in a class that manages them.

I often use this pattern when I have many objects that need to act a a group.

In class demo of https://iam.colum.edu:8443/svn/XNAProg/trunk/Jeff/IntroObserver/

Events

Simple events project.

https://iam.colum.edu:8443/svn/XNAProg4/trunk/XNA4Jeff/ConsoleApplicationPacManEvents/ConsoleApplicationPacManEvents/Program.cs

There is a larger project in XNA called GameIntro events. This project demos a timer event and events that cross game components.

Observer

Observer

Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Observers

http://www.dofactory.com/Patterns/PatternObserver.aspx

Observer is a design pattern that is often used to publish (push) or subscribe (pull) changes in the stae of one object to other interested object. It encourages loose coupling of objects.

The object the get the data often called the subject then notifies the observing objects of the change. The observing object will often repond to the subject.


Observer.gif

Here is a real example in c#. In this example a stock (the subject) notifies and investor (the observer) of a change in price.

ObserverStocks.png

Simple observer project https://iam.colum.edu:8443/svn/XNAProg4/trunk/XNA4Jeff/ConsoleApplicationPacManObserver/Program.cs

Bigger implementation in Project IntroObserver


Ship to XBox

In class demo

  • Creators Club
  • Deploy to XBox360 with visual studio
  • Package for deployment

Homework

Test Each Others Games

I created a forum in BB. I'd like everyone to test everyone other game. Please create a post for each game you are reviewing. We are looking for general play-ability, graphics, sound, game mechanics, and overall enjoyment.

You post should comment on all of these items. If you notice any bugs or crashes please write them up thoroughly. Also if you have any suggestions or comments that you think might make the game better please post these as well.

USE the Perfection Game technique I talked about in class.

As the game developer please respond to any bugs or suggestions with the criteria below.


Criteria

Bugs

'A' Bug

Cannot Release Game. Crashes, Spelling, Copyright, Not playable, not fun

'B' Bug

Unfortunate Release, able to deal with bugs

'C' Bug

Nice to fix

'D' Bug

Nice to add features

CNR

Can not replicate

NMI

Need more info

NAB

Nat a bug it's a feature

WAS

Works as designed

WNF

Will not fix

Soaking: Soaking is letting your software run for a long time to look for memory leaks or counting errors.

Let you game soak for a few hours and see what happens.

You may need to modify your game slightly for soaking.