SlideShare a Scribd company logo
1 of 26
Tank battle
Farzad Nozarian - Vahid Ranaei
Amirkabir university of technology
References
Problem Definition
Tank Movement
Android Devices
 Orientation Sensors
Desktops
 ‘WASD’ Control Keys
VS.
Problem Definition
Tank Movement/Android Devices
public void onSensorChanged(SensorEvent sensorEvent) {
if (sensorEvent.sensor.getType() == Sensor.TYPE_ORIENTATION) {
float headingAngle = sensorEvent.values[0];
float pitchAngle = sensorEvent.values[1];
float rollAngle = sensorEvent.values[2];
// TODO Apply the orientation
changes to your application.
}
}
Problem Definition
Tank Movement/Desktop Devices
inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_J));
inputManager.addListener(this, "Lefts");
inputManager.addListener(this, "Rights");
Problem Definition
Tank Movement/Desktop Devices
onAction
handler
if (binding.equals("Ups")) {
if (value) {
accelerationValue -= 800;
} else {
accelerationValue += 800;
}
player.accelerate(accelerationValue); }
else if (binding.equals("Rights")) {
if (value) {
steeringValue += -.5f;
} else {
steeringValue += .5f;
}
player.steer(steeringValue);
}
Problem Definition
Tank Movement
Some Abstractions
Fire
Move Forward (Accelerate)
Move Around (Steer)
…
Problem Definition
Tank Movement
vehicle.steer(steeringValue)
vehicle.accelerate(accelerationValue)
applyImpulse
resetSuspension
setPhysicsLocation
setPhysicsRotation
setLinearVelocity
Pattern Definition
• Decouple an abstraction from its implementation so that
the two can vary independently
• When abstractions and implementations should
be extensible through subclassing
Bridge!
Pattern Definition
Pattern Solution
Bridge
Problem Definition
Tank Shooting
Shooting In Real World !
Burst mode
Selective fire
Automatic firearm
Bump firing
Same ‘Fire’ Different Behaviors ?!
Pattern Definition
Tank Shooting
• Many related classes differ only in their behavior
• We need different variant of algorithm
• We need run-time shooting variation
Pattern Solution
Strategy
Problem Definition
World of Complexity!
Geometry
polygon mesh
material
specifying its shape
color
texture
opacity/transparency
Problem Definition
World of Complexity!
Spatial
Purpose:
Abstract data structure that stores user data and transformations
(= translation, rotation, scale) of elements of the 3D
Geometry Node
Visibility: visible 3D object
invisible "handle" for a group of
Spatials
Purpose: represent an object's look
structure and group Geometries
and other Nodes
Examples:
Box, sphere, player, building, terrain,
vehicle, missiles …
rootNode, audioNode, vehicleNode
or shipNode with passengers
attached, etc.
Pattern Definition
World of Complexity!
• Compose objects into tree structures to represent part-
whole hierarchies
• Clients treat individual objects and compositions of
objects uniformly
• We want clients to be able to ignore the difference
between compositions of objects and individual objects
Pattern Solution
World of Complexity!
Problem Definition
Family of Game Entities
Problem Definition
game configuration
Bunch of configurations !!
:
Problem Definition
game configuration
public static class UserBuilder {
private final String firstName;
private final String lastName;
..
public UserBuilder(String firstName, String
lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public UserBuilder age(int age) {
this.age = age;
return this;
}
..
public User build() {
return new User(this);
}
}
}
public class User {
private final String firstName; // required
private final String lastName; // required
private final int age; // optional
private final String phone; // optional
private final String address; // optional
private User(UserBuilder builder) {
this.firstName = builder.firstName;
this.lastName = builder.lastName;
..
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public user getUser(){
return new
User.UserBuilder(‘John’,’Doe’)
.age(30)
.phone(‘3235345)
.address(‘’Fake address 33)
.build();
Problem Definition
game configuration
public class Configuration {
private int displayResolution;// display resolution
private int displayMode;// full screen?
private int soundVolume;//Sound volume
private int musicVolume; //Music volume
//....
private Configuration(ConfigBuilder builder) {
this.displayResolution = builder.displayResolution;
this.displayMode = builder.displayMode;
..
}
public int getDisplayResolution() {
return displayResolution;
}
public int getDisplayMode() {
return displayMode;
}
..
public static class ConfigBuilder{
private int displayResolution=0;// display resolution
private int displayMode=0;// full screen?
private int soundVolume=0;//Sound volume
private int musicVolume=0; //Music volume
//....
public ConfigBuilder displayResolution(int dr)
{
this.displayResolution = dr;
return this;
}
public ConfigBuilder displayMode(int dm)
{
this.displayMode = dm;
return this;
}
..
public Configuration build(){
return new Configuration(this);
}
}
}
Problem Definition
game configuration
But it is not all of it ..
Problem Definition
game configuration
Builderton pattern !? :o
Problem Definition
game configuration
public class Configuration {
private static Configuration c;
private int displayResolution; // display resolution
private int displayMode; // full screen?
private int soundVolume; //Sound volume
private int musicVolume; //Music volume
//....
private Configuration(ConfigBuilder builder) {
this.displayResolution = builder.displayResolution;
this.displayMode = builder.displayMode;
this.soundVolume = builder.soundVolume;
this.musicVolume = builder.soundVolume;
}
public int getDisplayResolution() {
return displayResolution;
}
public int getDisplayMode() {
return displayMode;
}
…
public static class ConfigBuilder{
private int displayResolution=0;
private int displayMode=0;
private int soundVolume=0;
private int musicVolume=0;
//....
public ConfigBuilder displayResolution(int dr)
{
this.displayResolution = dr;
return this;
}
public ConfigBuilder displayMode(int dm)
{
this.displayMode = dm;
return this;
}
…
public Configuration build(){
if (c == null)
{ c=new Configuration(this);
return c;
}
else return c;
}
}
}
To Be Continue …

More Related Content

Similar to Tank Battle - A simple game powered by JMonkey engine

assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxassignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxssuser562afc1
 
Design patterns
Design patternsDesign patterns
Design patternsBa Tran
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxmary772
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxmccormicknadine86
 
Type script by Howard
Type script by HowardType script by Howard
Type script by HowardLearningTech
 
Architecture components - IT Talk
Architecture components - IT TalkArchitecture components - IT Talk
Architecture components - IT TalkConstantine Mars
 
Architecture Components
Architecture Components Architecture Components
Architecture Components DataArt
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by HowardLearningTech
 
Howard type script
Howard   type scriptHoward   type script
Howard type scriptLearningTech
 
Reloj en java
Reloj en javaReloj en java
Reloj en javacathe26
 
PROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdfPROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdfezonesolutions
 
Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfJUSTSTYLISH3B2MOHALI
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...DroidConTLV
 
Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)ThomasHorta
 
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018
Meetup di GDG Italia - Leonardo Pirro -  Codemotion Rome 2018 Meetup di GDG Italia - Leonardo Pirro -  Codemotion Rome 2018
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018 Codemotion
 
I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdffeelinggifts
 

Similar to Tank Battle - A simple game powered by JMonkey engine (20)

assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxassignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
 
Design patterns
Design patternsDesign patterns
Design patterns
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
 
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docxCodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
CodeZipButtonDemo.javaCodeZipButtonDemo.java Demonstrate a p.docx
 
Ali.pptx
Ali.pptxAli.pptx
Ali.pptx
 
Ali.pptx
Ali.pptxAli.pptx
Ali.pptx
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 
Architecture components - IT Talk
Architecture components - IT TalkArchitecture components - IT Talk
Architecture components - IT Talk
 
Architecture Components
Architecture Components Architecture Components
Architecture Components
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
 
Reloj en java
Reloj en javaReloj en java
Reloj en java
 
PROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdfPROGRAM 2 – Fraction Class Problem For this programming as.pdf
PROGRAM 2 – Fraction Class Problem For this programming as.pdf
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Please help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdfPlease help!!I wanted to know how to add a high score to this prog.pdf
Please help!!I wanted to know how to add a high score to this prog.pdf
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)Kotlin Overview (PT-BR)
Kotlin Overview (PT-BR)
 
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018
Meetup di GDG Italia - Leonardo Pirro -  Codemotion Rome 2018 Meetup di GDG Italia - Leonardo Pirro -  Codemotion Rome 2018
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdf
 

More from Farzad Nozarian

SHARE Interface in Flash Storage for Relational and NoSQL Databases
SHARE Interface in Flash Storage for Relational and NoSQL DatabasesSHARE Interface in Flash Storage for Relational and NoSQL Databases
SHARE Interface in Flash Storage for Relational and NoSQL DatabasesFarzad Nozarian
 
Ultimate Goals In Robotics
Ultimate Goals In RoboticsUltimate Goals In Robotics
Ultimate Goals In RoboticsFarzad Nozarian
 
The Continuous Distributed Monitoring Model
The Continuous Distributed Monitoring ModelThe Continuous Distributed Monitoring Model
The Continuous Distributed Monitoring ModelFarzad Nozarian
 
Big data Clustering Algorithms And Strategies
Big data Clustering Algorithms And StrategiesBig data Clustering Algorithms And Strategies
Big data Clustering Algorithms And StrategiesFarzad Nozarian
 
Apache HBase - Lab Assignment
Apache HBase - Lab AssignmentApache HBase - Lab Assignment
Apache HBase - Lab AssignmentFarzad Nozarian
 
Apache HDFS - Lab Assignment
Apache HDFS - Lab AssignmentApache HDFS - Lab Assignment
Apache HDFS - Lab AssignmentFarzad Nozarian
 
Apache Hadoop MapReduce Tutorial
Apache Hadoop MapReduce TutorialApache Hadoop MapReduce Tutorial
Apache Hadoop MapReduce TutorialFarzad Nozarian
 
Big Data and Cloud Computing
Big Data and Cloud ComputingBig Data and Cloud Computing
Big Data and Cloud ComputingFarzad Nozarian
 
Big Data Processing in Cloud Computing Environments
Big Data Processing in Cloud Computing EnvironmentsBig Data Processing in Cloud Computing Environments
Big Data Processing in Cloud Computing EnvironmentsFarzad Nozarian
 
S4: Distributed Stream Computing Platform
S4: Distributed Stream Computing PlatformS4: Distributed Stream Computing Platform
S4: Distributed Stream Computing PlatformFarzad Nozarian
 

More from Farzad Nozarian (14)

SHARE Interface in Flash Storage for Relational and NoSQL Databases
SHARE Interface in Flash Storage for Relational and NoSQL DatabasesSHARE Interface in Flash Storage for Relational and NoSQL Databases
SHARE Interface in Flash Storage for Relational and NoSQL Databases
 
Object Based Databases
Object Based DatabasesObject Based Databases
Object Based Databases
 
Ultimate Goals In Robotics
Ultimate Goals In RoboticsUltimate Goals In Robotics
Ultimate Goals In Robotics
 
The Continuous Distributed Monitoring Model
The Continuous Distributed Monitoring ModelThe Continuous Distributed Monitoring Model
The Continuous Distributed Monitoring Model
 
Big data Clustering Algorithms And Strategies
Big data Clustering Algorithms And StrategiesBig data Clustering Algorithms And Strategies
Big data Clustering Algorithms And Strategies
 
Shark - Lab Assignment
Shark - Lab AssignmentShark - Lab Assignment
Shark - Lab Assignment
 
Apache HBase - Lab Assignment
Apache HBase - Lab AssignmentApache HBase - Lab Assignment
Apache HBase - Lab Assignment
 
Apache HDFS - Lab Assignment
Apache HDFS - Lab AssignmentApache HDFS - Lab Assignment
Apache HDFS - Lab Assignment
 
Apache Hadoop MapReduce Tutorial
Apache Hadoop MapReduce TutorialApache Hadoop MapReduce Tutorial
Apache Hadoop MapReduce Tutorial
 
Apache Spark Tutorial
Apache Spark TutorialApache Spark Tutorial
Apache Spark Tutorial
 
Apache Storm Tutorial
Apache Storm TutorialApache Storm Tutorial
Apache Storm Tutorial
 
Big Data and Cloud Computing
Big Data and Cloud ComputingBig Data and Cloud Computing
Big Data and Cloud Computing
 
Big Data Processing in Cloud Computing Environments
Big Data Processing in Cloud Computing EnvironmentsBig Data Processing in Cloud Computing Environments
Big Data Processing in Cloud Computing Environments
 
S4: Distributed Stream Computing Platform
S4: Distributed Stream Computing PlatformS4: Distributed Stream Computing Platform
S4: Distributed Stream Computing Platform
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

Tank Battle - A simple game powered by JMonkey engine

  • 1. Tank battle Farzad Nozarian - Vahid Ranaei Amirkabir university of technology
  • 3. Problem Definition Tank Movement Android Devices  Orientation Sensors Desktops  ‘WASD’ Control Keys VS.
  • 4. Problem Definition Tank Movement/Android Devices public void onSensorChanged(SensorEvent sensorEvent) { if (sensorEvent.sensor.getType() == Sensor.TYPE_ORIENTATION) { float headingAngle = sensorEvent.values[0]; float pitchAngle = sensorEvent.values[1]; float rollAngle = sensorEvent.values[2]; // TODO Apply the orientation changes to your application. } }
  • 5. Problem Definition Tank Movement/Desktop Devices inputManager.addMapping("Lefts", new KeyTrigger(KeyInput.KEY_H)); inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_K)); inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_U)); inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_J)); inputManager.addListener(this, "Lefts"); inputManager.addListener(this, "Rights");
  • 6. Problem Definition Tank Movement/Desktop Devices onAction handler if (binding.equals("Ups")) { if (value) { accelerationValue -= 800; } else { accelerationValue += 800; } player.accelerate(accelerationValue); } else if (binding.equals("Rights")) { if (value) { steeringValue += -.5f; } else { steeringValue += .5f; } player.steer(steeringValue); }
  • 7. Problem Definition Tank Movement Some Abstractions Fire Move Forward (Accelerate) Move Around (Steer) …
  • 9. Pattern Definition • Decouple an abstraction from its implementation so that the two can vary independently • When abstractions and implementations should be extensible through subclassing Bridge!
  • 12. Problem Definition Tank Shooting Shooting In Real World ! Burst mode Selective fire Automatic firearm Bump firing Same ‘Fire’ Different Behaviors ?!
  • 13. Pattern Definition Tank Shooting • Many related classes differ only in their behavior • We need different variant of algorithm • We need run-time shooting variation
  • 15. Problem Definition World of Complexity! Geometry polygon mesh material specifying its shape color texture opacity/transparency
  • 16. Problem Definition World of Complexity! Spatial Purpose: Abstract data structure that stores user data and transformations (= translation, rotation, scale) of elements of the 3D Geometry Node Visibility: visible 3D object invisible "handle" for a group of Spatials Purpose: represent an object's look structure and group Geometries and other Nodes Examples: Box, sphere, player, building, terrain, vehicle, missiles … rootNode, audioNode, vehicleNode or shipNode with passengers attached, etc.
  • 17. Pattern Definition World of Complexity! • Compose objects into tree structures to represent part- whole hierarchies • Clients treat individual objects and compositions of objects uniformly • We want clients to be able to ignore the difference between compositions of objects and individual objects
  • 21. Problem Definition game configuration public static class UserBuilder { private final String firstName; private final String lastName; .. public UserBuilder(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public UserBuilder age(int age) { this.age = age; return this; } .. public User build() { return new User(this); } } } public class User { private final String firstName; // required private final String lastName; // required private final int age; // optional private final String phone; // optional private final String address; // optional private User(UserBuilder builder) { this.firstName = builder.firstName; this.lastName = builder.lastName; .. } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public user getUser(){ return new User.UserBuilder(‘John’,’Doe’) .age(30) .phone(‘3235345) .address(‘’Fake address 33) .build();
  • 22. Problem Definition game configuration public class Configuration { private int displayResolution;// display resolution private int displayMode;// full screen? private int soundVolume;//Sound volume private int musicVolume; //Music volume //.... private Configuration(ConfigBuilder builder) { this.displayResolution = builder.displayResolution; this.displayMode = builder.displayMode; .. } public int getDisplayResolution() { return displayResolution; } public int getDisplayMode() { return displayMode; } .. public static class ConfigBuilder{ private int displayResolution=0;// display resolution private int displayMode=0;// full screen? private int soundVolume=0;//Sound volume private int musicVolume=0; //Music volume //.... public ConfigBuilder displayResolution(int dr) { this.displayResolution = dr; return this; } public ConfigBuilder displayMode(int dm) { this.displayMode = dm; return this; } .. public Configuration build(){ return new Configuration(this); } } }
  • 25. Problem Definition game configuration public class Configuration { private static Configuration c; private int displayResolution; // display resolution private int displayMode; // full screen? private int soundVolume; //Sound volume private int musicVolume; //Music volume //.... private Configuration(ConfigBuilder builder) { this.displayResolution = builder.displayResolution; this.displayMode = builder.displayMode; this.soundVolume = builder.soundVolume; this.musicVolume = builder.soundVolume; } public int getDisplayResolution() { return displayResolution; } public int getDisplayMode() { return displayMode; } … public static class ConfigBuilder{ private int displayResolution=0; private int displayMode=0; private int soundVolume=0; private int musicVolume=0; //.... public ConfigBuilder displayResolution(int dr) { this.displayResolution = dr; return this; } public ConfigBuilder displayMode(int dm) { this.displayMode = dm; return this; } … public Configuration build(){ if (c == null) { c=new Configuration(this); return c; } else return c; } } }