What's FANG?

 - spend some time browsing the FANG site
 - what'd you learn?
 - we're using FANG because it is a fairly simple, easy-to-use game engine
 - it should let us create some simple games in the time we have (sorry no Halo or Smash Bros. this weekend)

Basic Setup

 - download and import FANG
 - add the parts in red to your class:
   import fang.* ;
   public class YourClass extends GameLoop
   {
     public static void main( String[ ] args )
     {
       YourClass varname = new YourClass( ) ;
       varname.players =  1 ; // # of players you want as default value when it starts up ;
       varname.playerSelectable = false ; // whether or not you want them to be able to chang e# of players
       varname.runAsApplication( ) ; // starts the game
     } 
   }

Sprites

 - the term sprite comes from the early days of gaming, when it meant any 2D image
   - basically everything in the "classics" like asteroids, centipede, galaga, etc. are sprites
   - Mario (and everything else) in the original Mario game are all sprites
 - in FANG they are basically the same thing
 - there are five basic kinds: Oval, Rectangle, Polygon Image, and String
   - OvalSprite - created by calling OvalSprite( radius_width, radius_height )
   - RectangleSprite - created by calling RectangleSprite( width, height )
   - PolygonSprite - created by calling PolygonSprite( numberOfSides ) where numberOfSides is an integer >= 3, 3 would make a triangle for example
   - ImageSprite - created by calling ImageSprite( "resources\yourfile.extension" ) 
     - note that yourfile.extension has to be in the resources folder for the project
     - the supported image formats (the extension) are all the common ones: png, gif, jpg, bmp
       - I recommend using png
     - unless your drawing takes up the entire dimensions of the image, I recommend using a transparent background
   - StringSprite - created by calling StringSprite( "your string" ) or StringSprite( s ) where s is a String variable
     - Wackadot's score is a good example of how to use a StringSprite
 - to display something in FANG you basically use a Sprite
 - common Sprite creation chunk:
   Sprite s = new RectangleSprite( 2, 3 ) ;	// makes s a RectangleSprite
   s.setUseBoundingBox( true ) ; // only use true if using RectangleSprite, false otherwise
   s.setScale( 0.4 ) ;	// how big the sprite will be onscreen
   s.setLocation( 0.5, 0.65 ) ;  // where it is initially located
   s.setColor( new Color( 160, 82, 45 ) ) ; // what color you want it to be (don't use for ImageSprite)
 - before a sprite is actually displayed it must be added to the canvas by calling canvas.addSprite( your_sprite ) ;
 - other helpful functions:
   - testing if something has hit a sprite: yourSprite.intersects( anotherSprite ) ;
   - making something invisible: yourSprite.setVisible( false ) ; // use true to make it visible again
   - removing something completely: canvas.removeSprite( yourSprite ) ; // won't display anymore but collisions will still register

FANG's Window

 - the fang window's coordinates go like this:
   - x increases horizontally from 0 to 1 starting at top left
   - y increases vertically from 0 to 1 starting at top left


Trackers

 - trackers are an easier way of handling motion than doing it yourself
 - Let's look at an example
 - Discretization problem

Randon Numers

 - because of FANG's networking capabilities, we cannot use the same random number generator as we did with the dice project
 - fortunately it is even easier for us, just use the variable "random"
   - random.nextDouble( ) -> gives a double between 0 (inclusive) and 1 (exclusive)
   - random.nextInt( number ) -> gives an int between 0 (inclusive) and number (exclusive)

Advance Frame

 - this method gets called at every frame (so many times a second) so the code happens
 - usually this is where collisions and input are handled

Usual Template for what a game begins as

   
import fang.* ;
   public class YourClass extends GameLoop
   {
     // put your variables here

     public YourClass( )
     {
       super( ) ;
       // assignments to intialize variables
       // calls to your makeSomething( ) methods
       addSprites( )
     }
    
     private void addSprites( )
     {
       // all of your canvas.addSprite( something ) calls
     }

     private void handleCollisions( )
     {
       // only write something here if needed
     }

     public void advanceFrame( double time )
     { 
       // anything in here gets called every frame
       // usually want to call handleCollisions( ) if you have one
     }

     public static void main( String[ ] args )
     {
       YourClass varname = new YourClass( ) ;
       varname.players =  1 ; // # of players you want as default value when it starts up ;
       varname.playerSelectable = false ; // whether or not you want them to be able to chang e# of players
       varname.runAsApplication( ) ; // starts the game
     } 
   }