Games:Example:Summary

From FANG

Jump to: navigation, search


Below are a number of samples which demonstrate some of the elements of the gaming package. The source code from these examples can be combined and modified for creating your own games. Be sure to examine the source code from all of the examples before posting questions to the bulletin board. These examples are designed to provide code examples of most of the frequently used elements in games written using the FANG Engine.

Click here to download a single jar file with all of the code for the examples below.


Alarm Beep by Jam Jenkins

This example demonstrates audio and alarms. An alarm is set up to make a ding sound 1 second after the game is started, and every 3 seconds thereafter. This is the only example with sound.

Source Code: AlarmBeep.java

Click here to run the Alarm Beep example.

Collision by Jam Jenkins

This example moves the circle on the left toward the square on the right. When they intersect the circle is made invisible and the square is removed from the canvas.

Source Code: Bullet.java

Click here to run the Collision example.

DragNDrop by Neal Ehardt

This program demonstrates how a sprite can be modified to respond to dragging and dropping.

Source Code: DragNDrop.java and Draggable.java

Click here to run the DragNDrop example.

Font Finder by Jam Jenkins

This program lists all the font families available on your computer. Click on the Next and Previous buttons to go to the next or previous page. You can also click and/or drag in the scrollbar at the bottom of the screen to cycle through the font names.

Source Code: FontFinder.java

Click here to run the Font Finder example.

Input by Jam Jenkins

This example responds to mouse and keyboard input. The StringSprite 'Horiz' tracks the mouse horizontally only. The StringSprite 'Vert' tracks the mouse vertically only, and 'Both' tracks exactly. Pressing the letters 'i', 'j', 'k', and 'm' on the keyboard moves the StringSprite 'Keys' up, left, right, and down respectively.

Source Code: InputLoop.java

Click here to run the Input example.

Level Select by Alex Park

Click to jump through different levels instead of going through levels sequentially.

Source Code: LevelSelect.java, Launcher.java, Level1.java

Click here to run the Level Select example.

Map Explore by Jam Jenkins

This example shows how to use dragging the mouse to move the background. This is the type of interface common in map programs where you click and drag to move the map.

Source Code: MapExplore.java

Click here to run the Map Explore example.

Mouse Locator by Jam Jenkins

This example uses the mouse's location to set the location and text of a StringSprite.

Source Code: MouseLocator.java

Click here to run the Mouse Locator example.

Move On Grid by Jam Jenkins

Shows how to move a sprite smoothly between grid locations rather than jumping directly to the new position. Click on a cell and the circle will move to that cell over a 1 second duration. This example is particularly useful for writing turn-based games such as tic-tac-toe, checkers, or chess where there should be a smooth transition when moving game pieces.

Source Code: MoveOnGrid.java, GridTracker.java, Grid.java

Click here to run the Move On Grid example.

Multiplayer by Jam Jenkins

This is an example runs a multi-player applet. You will need to open at least two copies of it to see it work. Right click on the image and open the link in a new tab or window. Repeat for as many players as you would like. Under the number of players select 2 or more. Optionally put in a session name. Click on 'Start & Connect Game'. Each screen that comes up will represent a different player in a multi-player game where each player controls his or her own location.

Source Code: Multiplayer.java

Click here to run the Multiplayer example.

Multiview by Jam Jenkins

This is an example runs a multi-player applet. You will need to open at least two copies of it to see it work. Right click on the image and open the link in a new tab or window. Repeat for as many players as you would like. Under the number of players select 2 or more. Optionally put in a session name. Click on 'Start & Connect Game'. Each screen that comes up will represent a different player in a multi-player game where each player controls his or her own location.

Source Code: Multiview.java

Click here to run the Multiview example.

Navigator by Jam Jenkins

If you want to make the mouse control which way you move, this is how you deal with the limitation that the screen is only so big.

Source Code: Navigator.java

Click here to run the Navigator example.

Snap to Grid by Jam Jenkins

Shows how to make snap positions to a grid. As you move your mouse over the cells, the current cell is highlighted in yellow. This example is particularly useful for writing turn-based games such as tic-tac-toe, checkers, or chess.

Source Code: SnapToGrid.java and Grid.java

Click here to run the Snap to Grid example.

Splash Screens by Jam Jenkins

This example demonstrates how to make a game come up after a splash screen. This example uses alarms to provide the timing.

Source Code: Splash.java, StartSplash.java, ActualGameLevel.java, GameOverSplash.java

Click here to run the Splash Screens example.

Sprite Test by Jam Jenkins

This example simply places a sprite in the middle of the canvas. Use this example to test different sprites you make before adding them to your game.

Source Code: SpriteTest.java, FaceSprite.java, LightSprite.java, StarSprite.java, TriangleSprite.java

Click here to run the Sprite Test example.

Timer by Jam Jenkins

This example demonstrates how to implement a timer that counts up in seconds. This example uses an alarm that goes off every second to update the clock.

Source Code: TimerLoop.java

Click here to run the Timer example.

Tracker Test by Jam Jenkins

This example applies a tracker to an oval sprite in the middle of the canvas. Use this example to test different sprites you make before addign them to your game.

Source Code: TrackerTest.java, OutlineTracker.java, PulseTracker.java, SpinTracker.java

Click here to run the Tracker Test example.

Turn Based by Wade Gordon and Michael Turnell

This example shows how you can make a game in which the players take turns. When each player clicks, it transfers the turn to the next player.

Source Code: TurnBased.java

Click here to run the Turn Based example.





Views
Personal tools