Permalink
Browse files

Color bot

  • Loading branch information...
1 parent ee40061 commit ff5990405cacd2480d96ed4675c1ecbc9067044a @arntanguy committed Apr 30, 2012
Showing with 39 additions and 17 deletions.
  1. +1 −0 src/game/Car.java
  2. +9 −9 src/game/FreeForAllScreenState.java
  3. +4 −0 src/physics/BMWM3Properties.java
  4. +25 −8 src/physics/CarProperties.java
View
@@ -285,6 +285,7 @@ public void stop(int delay) {
public void run() {
accelerate(0);
setLinearVelocity(Vector3f.ZERO);
+ audioRender.mute();
willStop = false;
}
}, delay);
@@ -37,13 +37,14 @@ public void initialize(AppStateManager stateManager, Application a) {
protected void initGame() {
super.initGame();
player.setPhysicsLocation(new Vector3f(0, 27, 700));
- addBot(new Vector3f(new Vector3f(10, 27, 700)), new BMWM3Properties());
- addBot(new Vector3f(new Vector3f(20, 27, 800)), new BMWM3Properties());
- addBot(new Vector3f(new Vector3f(30, 27, 500)), new BMWM3Properties());
- addBot(new Vector3f(new Vector3f(40, 27, 600)), new BMWM3Properties());
- addBot(new Vector3f(new Vector3f(40, 27, 600)), new BMWM3Properties());
- addBot(new Vector3f(new Vector3f(300, 27, 800)), new BMWM3Properties());
- addBot(new Vector3f(new Vector3f(200, 27, 700)), new BMWM3Properties());
+ BMWM3Properties properties = new BMWM3Properties();
+ addBot(new Vector3f(new Vector3f(10, 27, 700)), properties);
+ addBot(new Vector3f(new Vector3f(20, 27, 800)), properties);
+ addBot(new Vector3f(new Vector3f(30, 27, 500)), properties);
+ addBot(new Vector3f(new Vector3f(40, 27, 600)), properties);
+ addBot(new Vector3f(new Vector3f(40, 27, 600)), properties);
+ addBot(new Vector3f(new Vector3f(300, 27, 800)), properties);
+ addBot(new Vector3f(new Vector3f(200, 27, 700)), properties);
/*addBot(new Vector3f(new Vector3f(100, 27, 600)), new BMWM3Properties());
addBot(new Vector3f(new Vector3f(400, 27, 600)), new BMWM3Properties());
addBot(new Vector3f(new Vector3f(500, 27, 500)), new BMWM3Properties());
@@ -52,7 +53,6 @@ protected void initGame() {
addBot(new Vector3f(new Vector3f(0, 27, 600)), new BMWM3Properties());*/
randBotsPos();
-
}
private void randBotsPos() {
@@ -65,7 +65,7 @@ private void randBotsPos() {
protected void addBot(Vector3f location, CarProperties carProperties) {
Car bot = new Car(assetManager, carProperties,
- "Models/FerrariBlue/Car.scene");
+ carProperties.getRandomModel());
bot.setPhysicsLocation(location);
bot.getNode().setShadowMode(ShadowMode.CastAndReceive);
@@ -43,5 +43,9 @@ public BMWM3Properties() {
torque.put(6000, 500);
torque.put(8000, 450); // wrong value
torque.put(15000, 0);
+
+ playerModel = "Models/FerrariRed/Car.scene";
+ availableModels.add("Models/FerrariGreen/Car.scene");
+ availableModels.add("Models/FerrariBlue/Car.scene");
}
}
@@ -1,8 +1,11 @@
package physics;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.TreeMap;
+import physics.tools.MathTools;
+
public class CarProperties {
// tire height (24.5, 26, 27.5, ...cm)
private double tireHeight = 24.5;
@@ -23,8 +26,11 @@
* Gear ratio and properties
*/
protected Gears gears;
-
- protected int redline=6000;
+
+ protected int redline = 6000;
+
+ protected String playerModel;
+ protected ArrayList<String> availableModels;
/**
* Torque corresponding to given engine speed <Engine speed, Torque> ordered
@@ -50,6 +56,8 @@ public CarProperties() {
torque.put(0, 0);
torque.put(75, 390);
torque.put(140, 200);
+
+ availableModels = new ArrayList<String>();
}
public CarProperties(double th, double tgr, int idleRpm) {
@@ -133,14 +141,14 @@ public double getTorque(double rpm) {
w2 = w1;
w1 = wt;
- //System.out.println("RMP (" + rpm + ") > value(" + w1 + "," + w2
- // + ") : get torque (" + torque.get(w1) + "," + torque.get(w2)
- // + ")");
+ // System.out.println("RMP (" + rpm + ") > value(" + w1 + "," + w2
+ // + ") : get torque (" + torque.get(w1) + "," + torque.get(w2)
+ // + ")");
t1 = torque.get(w1);
if (rpm <= w2) {
t2 = torque.get(w2);
- // System.out.println("torque = " + t1 + (rpm - w1) * (t2 - t1)
- // / (w2 - w1));
+ // System.out.println("torque = " + t1 + (rpm - w1) * (t2 - t1)
+ // / (w2 - w1));
return t1 + (rpm - w1) * (t2 - t1) / (w2 - w1);
} else {
return 0;
@@ -198,8 +206,17 @@ public float getMass() {
public void setMass(float mass) {
this.mass = (mass >= 0) ? mass : 0.f;
}
-
+
public int getRedline() {
return redline;
}
+
+ public ArrayList<String> getAvailableModels() {
+ return availableModels;
+ }
+
+ public String getRandomModel() {
+ int rand = MathTools.randBetween(0, availableModels.size());
+ return availableModels.get(rand);
+ }
}

0 comments on commit ff59904

Please sign in to comment.