Using FangEngine The FangEngine is created by Brian C. Ladd & Jam Jenkins Presentation by Pepper With much credit to: Jenkins, Jam & Brian C. Ladd. Introductory.

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

GAME:IT Junior Learning Game Maker: The Control Tab.
Create a Simple Game in Scratch
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
1 CSC 221: Computer Programming I Fall 2006 interacting objects modular design: dot races constants, static fields cascading if-else, logical operators.
Create a Simple Game in Scratch
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
GUIs Part 4 CS221 – 4/17/09. Professional Assignments Assignment #2 – Download and install Visual Studio 2008 Professional Trial Software –
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
2D Graphics in Java COMP53 Nov 14, Applets and Applications Java applications are stand-alone programs – start execution with main() – runs in JVM.
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
Begin Java having used Alice Pepper - Some slides from Alice in Action with Java.
A Simple Applet.
Racing Car Game Using the keys to control a sprite.
Writing Methods. Create the method Methods, like functions, do something They contain the code that performs the job Methods have two parts.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Programming Task: Task 1 Controlled Assessment Practice.
Chapter 5 - Making Music: An On-Screen Piano
Construct 2 Game Development Shahed Chowdhuri Sr. Technical Evangelist
1 Programming James King 12 August Aims Give overview of concepts addressed in Web based programming module Teach you enough Java to write simple.
How to Keep Score.  If the hitter grounds out to shortstop, for example, write in "6-3," which shows the shortstop threw him out at first base.  If.
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
Applications in Java Towson University *Ref:
Introduction to TouchDevelop
Inheritance & Interfaces. The Plan ● Motivate Inheritance ● Motivate Interfaces ● Examples ● Continue Practice on Observer/Observable.
More on Classes Pepper With help from rs.html.
CSC172 Intro Pepper. Goals Reminder of what a class is How to create and use classes How to design classes How to think in terms of objects How to comment.
Java Classes Using Java Classes Introduction to UML.
Learn about the types of Graphics that are available Develop a basic Graphics applet Develop a basic Graphics application Review the Java API and use.
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
How to Run a Java Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Java GUI’s are event driven, meaning they generate events when the user interacts with the program. Typical events are moving the mouse, clicking a mouse.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
INTERFACES More OO Concepts. Interface Topics Using an interface Interface details –syntax –restrictions Create your own interface Remember polymorphism.
Session 16 Pinball Game Construction Kit:. Pinball Version 1 Replaced the fire button with a mouse event. Multiple balls can be in the air at once. –Uses.
Game Maker – Getting Started What is Game Maker?.
1 CSE1340 Class 4. 2 Objectives Write a simple computer program in Java Use Swing components to build the GUI Use proper naming conventions for classes.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
2.3. A RCHITECTURAL D ESIGN I Example approach for game screen management.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
Session 13 Pinball Game Construction Kit (Version 3):
1 CSC 216 Lecture 3. 2 Unit Testing  The most basic kind of testing is called unit testing  Why is it called “unit” testing?  When should tests be.
CompSci Introduction to Jam’s Video Game Package.
CompSci Video Game Package Design Design of the Video Game Package.
CS 5JA Introduction to Java Graphics One of the powerful things about Java is that there is.
Video Game Package Intro 1 Last Edited 1/10/04CPS4: Java for Video Games Introduction.
CompSci 44.1 Game Package Introduction to Jam’s Video Game Package.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Introducing, the JFrame Gives us a work area beside System.out.println.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
CompSci Inheritance & Interfaces. CompSci Inheritance & Interfaces The Plan  Motivate Inheritance  Motivate Interfaces  Examples  Continue.
Contacts: Intro to game programming in Java (with almost-drawingpanel)
JavaDoc CECS277 Mimi Opkins.
Installing and running the local check projects in Eclipse
The Finch Robot and the While Loop
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
How to Run a Java Program
Download : to follow along.
Game Loop Update & Draw.
Introduction to Snap Programming
Developing Java Applications with NetBeans
Developing Java Applications with NetBeans
Expanding the PinBallGame
Creating a Simple Game in Scratch
Presentation transcript:

Using FangEngine The FangEngine is created by Brian C. Ladd & Jam Jenkins Presentation by Pepper With much credit to: Jenkins, Jam & Brian C. Ladd. Introductory Programming with Simple Games. Mass: Wiley, 2011

Teach Your Program Teach your program to play a game without you having to learn much about how Java plays a game. Basic engine: – Networked – Knows about players – Knows about how games are played

Game Playing Basics Define setup – Create/gather playing components – Set initial configuration Define advance – Update game state Call setup While (not game over) – Show game state – Get input from user – Call advance Indicate winner (or tie) * From Jenkins, Jam & Brian C. Ladd. Introductory Programming with Simple Games. Mass: Wiley, 2011, 28-29

Resources Fang Engine main page Download jar – fang 2 Install in BlueJ Tutorial for creating wackadot (but older fang engine and more than we are including)

Bring in the Fang Knowledge Bring the Fang 2 engine knowledge into our program so we can call on it. import fang2.core.*; import fang2.sprites.*; import java.awt.*; import java.awt.geom.*;

Package Set up a package so we can export easily package wackadot; import fang2.core.*; import fang2.sprites.*; import java.awt.*; import java.awt.geom.*;

Comment /** * Use mouse to wack dots and move them. * Score points for wacking dots * kris pepper 1 */

Inheritance Make our class be an extension of the GameLoop class. Now our Wackadot will know everything GameLoop knows We can use the variables GameLoop has plus we can add our own We can use the methods GameLoop has – Plus add our own – Plus Override GameLoop’s methods if we want to change what they do. (That is how we will teach Wackadot what we want that is different from GameLoop.) public class Wackadot extends GameLoop { // note that GameLoop contains the variable canvas // it also has a variable called random }

Main Method Add a main method so we can create a wackadot instance using the blueprint we are writing. We can then run the game as an application by asking our wackadot instance to run itself. public static void main(String[] args) { Wackadot mygame = new Wackadot(); mygame.runAsApplication(); } Run to see the result

Add a dot to our game Make a fang type of variable that knows how to make a dot private Sprite dot; Create an instance of Sprite to put into the dot variable Ask that Sprite to set itself to the shape, color and location we want. private void makeSprites() { dot=new OvalSprite(1, 1); dot.setScale(0.1); dot.setLocation(0.5, 0.5); dot.setColor(Color.RED); }

Now Add the Dot to the Canvas We have a dot variable filled with a Sprite Now add the dot to the canvas Override the startGame method to tell it to add a public void startGame() { makeSprites(); addSprites(); } private void addSprites() { canvas.addSprite(dot); } Run to see the result

Add a mouse event Make the Sprite move with public void advanceFrame(double timePassed) { Point2D.Double mouse= getPlayer().getMouse().getLocation(); dot.setLocation(mouse); } Run to see the result

2 More Dots – Random Locations Make 2 more dots appear Add 2 more variables private Sprite redDot; private Sprite blueDot; Create instances of Sprites to put into those new boxes inside makeSprites() redDot=new OvalSprite(1, 1); redDot.setScale(0.1); redDot.setLocation( random.nextDouble(), random.nextDouble()); redDot.setColor(Color.RED); Repeat for blueDot

Add the 2 dots to the canvas Change addSprites to add 2 more dots private void addSprites() { canvas.addSprite(dot); canvas.addSprite(redDot); canvas.addSprite(blueDot); Run to see the result

Handle Collisions Handle collisions by detecting them and then repositioning: private void handleCollisions() { if (dot.intersects(blueDot)) { blueDot.setLocation( random.nextDouble(), random.nextDouble()); } Repeat for redDot

Tell the fang2 engine how to advance Fang2 engine wont use your collision handling unless you tell it Tell it to run your method after every public void advanceFrame(double timePassed) { Point2D.Double mouse = getPlayer().getMouse().getLocation(); dot.setLocation(mouse); handleCollisions(); } Run to see the result

Add a Score Add a Sprite that knows about text: Private StringSprite scoreSprite; Add a variable to keep track of collisions private int redScore, blueScore; Set the scores to 0 when the game public void startGame() { makeSprites(); addSprites(); redScore = 0; blueScore = 0; }

Add the Score Object to the Canvas Create the Sprite instance to put into your scoreSprite inside makeSprite: scoreSprite=new StringSprite("Red Score: " + redScore + " Blue Score: " + blueScore); scoreSprite.setHeight(0.08); scoreSprite.rightJustify(); scoreSprite.topJustify(); scoreSprite.setLocation(1, 0); Add the score to your canvas inside addSprite canvas.addSprite(scoreSprite);

Increase the Score upon a hit Upon a hit, increase the score Also, reset the scoreSprite to show the new score private void handleCollisions() { if (dot.intersects(blueDot)) { blueDot.setLocation( random.nextDouble(), random.nextDouble()); blueScore++; scoreSprite.setText("Red Score: " + redScore + " Blue Score: " + blueScore); } Run to see the result

Your Job Add one more Yellow Sprite When the Yellow Sprite is hit, reduce one point from the blue and red scores Change the Red Sprite to start in the upper left corner Make any other changes to the game logic you like. See available methods for fang2 sprites at: