2. PROJECT DETAILS
This is the Desktop 3D version of the game
Angry Birds. The complete work of this project
is and will be done under the flagship of BRAC
University Computer Club by a team
comprising of bunch of first semester students
and a mentor of BRAC University and BRAC
University Computer Club.
Repository:
https://github.com/sadaf2605/AngryJollyBirds3D
3. Want to be a part of the journey?
Welcome aboard!
If you are following this series of tutorial and want
to contribute, then we would also love to work with
you. If you are a new coder like other contributor of
this project, then you are welcoming you more
coordinately.
You can either contact with me (
sadaf2605@gmail.com) with your code or you can
directly send pull request to our github repository
mentioned in the previous page.
4. Download, Install, Open JME3
1. Download it.
Download Link:
http://hub.jmonkeyengine.org/downloads/
2. Install it and
3. Then open it
11. 0. Creating a box
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape at the origin
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
Material mat = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md"); // create a simple material
mat.setColor("Color", ColorRGBA.Blue); // set color of material to blue
geom.setMaterial(mat); // set the cube's material
rootNode.attachChild(geom); // make the cube appear in the scene
}}
13. 1. Importing packages
• When we put 2 files in a same directory, java
can find it easily
• But it fails when we use files of multiple
directory, so we need to import directory.
• Packages are just directories that contains
the location where the class is located.
• Just like Scanner, it is located in
java.util.Scanner directory, so we import it in
the beginning of the file.
17. 2. Inheritance
• But the problem with our social life
inheritance is that if father posses 5 bundle of
coins then each of the 5 son will get 1 bundle
of coins.
• Inheritance in programming languages are
more broad minded, it gives everything of the
father to each and every child
• So probably we should introduce a new
example, shall we?
21. 2. Inheritance
I am moving my arrows 180’ because since
parent has nothing to lose in inheritance parent
does not care who is inheriting him. So its
child’s responsibility to chose a good parent(!).
24. 2. Inheritance
So after inheriting every child and their parent
will have their own phone at the same time.
By the way, if one child destroy the phone but
yet other user won’t get disturbed by it so it is
all alike of using own phone.
25. 2. Inheritance (why?)
“We have more in common as humans than
difference”
2 point to note:
i) Common
ii)Difference
26. 2. Inheritance (why?)
name
age
hobby
job
haveFun()
Gossip() name
age
hobby
job
haveFun()
Gossip()
name
age
hobby
job
haveFun()
Gossip()
name
age
hobby
job
haveFun()
Gossip()
name
age
hobby
job
haveFun()
Gossip()
Karate
skill money
Fix()
arrest() speed
28. 2. Inheritance (why?)
Lets generalize all the common things
together in a super class, in the parent class
and let’s put all the specialization in the sub
class, in the child class.
It will help us to DRY out(Do not Repeat
Yourself) our code.
31. 2. Inheritance (how?)
public class parent{
int parentVariable=0;
void parentMethod(){
System.out.println(“Shouting…….”);
}
}
32. 2. Inheritance (how?)
public class child{
int childVariable=0;
void childMethod(){
System.out.println(“Please, please, please…….”);
}
}
33. 2. Inheritance (how?)
public class parent{
int parentVariable=0;
void parentMethod(){
System.out.println(“Shouting…….”);
}
}
public class child{
int childVariable=0;
void childMethod(){
System.out.println(“Please, please, please…….”);
}
}
34. 2. Inheritance (how?)
public class parent{
int parentVariable=0;
void parentMethod(){
System.out.println(“Shouting…….”);
}
}
public class child{
int childVariable=0;
void childMethod(){
System.out.println(“Please, please, please…….”);
}
}
35. 2. Inheritance (how?)
public class child extends parent{
int childVariable=0;
void childMethod(){
System.out.println(“Please, please,
please…….”);
}
public static void main(String [] args){
//call any parent method you want.
}
}
36. 3. Adding methods
Import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
}
}
37. 3. Adding methods
•Void main method always leads
public static void main(String[] args){
}
•Other method like this follow its
order from the main methods.
public void simpleInitApp() {
}
38. 4. Instantiate to start
Import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
}
39. 4. Instantiate to start
What we do when we need to access
Scanner.class?
•We make instance of it:
Scanner sc= new Scanner(……)
•Then we use its method:
sc.nextInt()
•The same trick
HelloJME3 app = new HelloJME3();
app.start(); // start the game
40. 4. Instantiate to start
So how would we access to our
HelloJME3.class?
•We make instance of it:
HelloJME3 app = new HelloJME3();
•Then we use its method:
app.start(); // start the game
41. 5. Adding Geometry
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
public void simpleInitApp() {
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
}}
42. 5. Adding Geometry
Geometry geom = new Geometry("Box",
b);
Geometry manages all the rendering
information such as the material type, how
the surface should be shaded and the mesh
data such as points, lines, faces and maybe
altogether.
BUT b is not defined! What is b? Mesh!
43. 6. Adding Mesh
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape at the origin
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
}}
44. 6. Adding Mesh
Mesh is used to store rendering data. It is a
collection of vertices along with data about
how the are connected to each other and
the faces they form. In fact all visible
elements in a scene are represented
by meshes.
One kind of Mesh is box.
Box b = new Box(Vector3f.ZERO, 1, 1,
45. 6. Adding Mesh
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape at the origin
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
46. 7. Adding to rootNode
Everything you initialize and attach to the
rootNode in the simpleInitApp().
simpleInitApp() method is part of the scene at
the start of the game. You can rotate,
translate, and scale objects by manipulating
their parent nodes. The Root Node is special:
Only what is attached to the Root Node
appears in the scene.
47. import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape at the origin
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
Material mat = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md"); // create a simple material
rootNode.attachChild(geom); // make the cube appear in the scene
}}
48. 7. Defining Material
Material definitions provide the "logic" for the
materials. Usually a shader that will handle
drawing the object, and corresponding
parameters that allow configuration of the
shader. Material definitions can be created
through J3MD files. The J3MD file abstracts
the shader and its configuration away from
the user, allowing a simple interface where
one can simply set a few parameters on the
material to change its appearance and the
way its handled.
49. 7. Adding Material
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape at the origin
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
Material mat = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md"); // create a simple material
geom.setMaterial(mat); // set the cube's material
rootNode.attachChild(geom); // make the cube appear in the scene
}}
50. 8. Setting a property to Material
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
public class HelloJME3 extends SimpleApplication {
public static void main(String[] args){
HelloJME3 app = new HelloJME3();
app.start(); // start the game
}
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1); // create cube shape at the origin
Geometry geom = new Geometry("Box", b); // create cube geometry from the shape
Material mat = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md"); // create a simple material
mat.setColor("Color", ColorRGBA.Blue); // set color of material to blue
geom.setMaterial(mat); // set the cube's material
rootNode.attachChild(geom); // make the cube appear in the scene
}}