Skip to content
Browse files

implemented difficulty method (needs to be finished)

  • Loading branch information...
1 parent f689d8e commit 5ac286749490809beeef9986ed06a32c295d1f53 @Jon8linden committed Apr 17, 2012
View
BIN Senior Project/bin/Senior-Project.apk
Binary file not shown.
View
BIN Senior Project/bin/classes.dex
Binary file not shown.
View
36 Senior Project/src/com/linden/sp/game/Engine.java
@@ -31,6 +31,9 @@
//game looping speed
final static int gameLoopSpeed = 20;
+ private int scoreDelay= 25;
+ private int currentScoreTime=0;
+
//start up game variables
static Boolean surfaceCreated = false;
@@ -91,13 +94,22 @@ public void runGame(){
//items
//score and check if win condition
- //calculateScore();
+ incrementScore();
}
+ private void incrementScore() {
+ //delay score from incrementing extreamly fast
+ if ((totalRunTime - currentScoreTime)> scoreDelay){
+ score++;
+ currentScoreTime= totalRunTime;
+ }
+
+ }
+
private void totalRunTime() {
totalRunTime++;
@@ -197,8 +209,6 @@ protected void onCreate(Bundle savedInstanceState) {
Bundle bundle = getIntent().getExtras();
//set to 0 so it does not effect survival mode
level = bundle.getInt("level",0);
-
- selectedCar = bundle.getInt("car",1);
difficulty = bundle.getInt("difficulty",1);
// Set to gameView
@@ -229,8 +239,26 @@ protected void onCreate(Bundle savedInstanceState) {
}
+ static void updateDifficulty() {
+ // TODO Auto-generated method stub
+ //difficulty changes number of obstructions on the screen at once
+ if (difficulty == 1){
+ maxObstructions = 3;
+ //number of cops
+ }
+ else if (difficulty == 2){
+ maxObstructions = 4;
+ //number of cops
+ }
+ else if (difficulty == 3){
+ maxObstructions = 5;
+ //number of cops
+ }
+
+ }
+
// calculate score based off time and hitting obstacles
- public void calculateScore(){
+ public void calculateScore(){
score = score+1 * Player.scoreMult;
Log.i("calculateScore ", "Current Score " + score);
View
15 Senior Project/src/com/linden/sp/game/Player.java
@@ -59,6 +59,10 @@ public void changePlayerImage(Resources res){
setAcceleration(2);
//breakingPower = number; implement later
setBreakingPower(3);
+ //max number of obstructions
+ Engine.maxObstructions = 3;
+ //spawn delay must be changed due to speed of cars
+ Engine.spawnDelay=100;
}
else if (Engine.level == 2){
playerImage = BitmapFactory.decodeResource(res, R.drawable.delsol600);
@@ -68,6 +72,7 @@ else if (Engine.level == 2){
setSpeed(1);
setAcceleration(3);
setBreakingPower(3);
+ Engine.maxObstructions = 3;
}
else if (Engine.level == 3){
playerImage = BitmapFactory.decodeResource(res, R.drawable.jeep);
@@ -76,6 +81,8 @@ else if (Engine.level == 3){
setSpeed(2);
setAcceleration(3);
setBreakingPower(2);
+
+ Engine.maxObstructions = 3;
}
else if (Engine.level == 4){
playerImage = BitmapFactory.decodeResource(res, R.drawable.blacktruck);
@@ -89,6 +96,8 @@ else if (Engine.level == 4){
Engine.maxObstructions = 3;
setAcceleration(4);
setBreakingPower(2);
+
+ Engine.maxObstructions = 3;
}
else if (Engine.level == 5){
playerImage = BitmapFactory.decodeResource(res, R.drawable.gamebmw);
@@ -102,6 +111,7 @@ else if (Engine.level == 5){
setAcceleration(5);
setBreakingPower(4);
+ Engine.maxObstructions = 4;
}
else if (Engine.level == 6){
playerImage = BitmapFactory.decodeResource(res, R.drawable.porsche600);
@@ -125,9 +135,8 @@ else if (Engine.level == 7){
setAcceleration(6);
setBreakingPower(9);
}
-
-
-
+
+ Engine.updateDifficulty();
}
//draw player on screen

0 comments on commit 5ac2867

Please sign in to comment.
Something went wrong with that request. Please try again.