From 9506bc923e259ba6ac497e1736d12f49b9352c53 Mon Sep 17 00:00:00 2001 From: Kleme Date: Thu, 29 Jun 2017 20:38:38 +0200 Subject: [PATCH] Mario now duck (or flee) when grabbed --- src/fr/klemek/minimario/MarioAI.java | 14 ++++++++++---- src/fr/klemek/minimario/MarioWindow.java | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/fr/klemek/minimario/MarioAI.java b/src/fr/klemek/minimario/MarioAI.java index 0a661c3..f1185e1 100644 --- a/src/fr/klemek/minimario/MarioAI.java +++ b/src/fr/klemek/minimario/MarioAI.java @@ -7,7 +7,7 @@ import java.util.Random; public class MarioAI { //times - private static final int MIN_STATE_TIME = 500; + private static final int MIN_STATE_TIME = 1000; private static final int MAX_STILL_TIME = 10000-MIN_STATE_TIME; private static final int MAX_WALKING_TIME = 5000-MIN_STATE_TIME; private static final int MAX_RUNNING_TIME = 3000-MIN_STATE_TIME; @@ -190,9 +190,15 @@ public class MarioAI { break; case LOOSING: if(this.time-this.time2>100){ - this.time2 = this.time+rand.nextInt(MAX_STILL_TIME)+MIN_STATE_TIME; - this.wait = true; - this.state = State.STILL; + int randi = rand.nextInt(100); + if(randi<80){ //0-79 - 80% + this.time2 = this.time+rand.nextInt(MAX_STILL_TIME)+MIN_STATE_TIME; + this.wait = true; + this.state = State.STILL_DUCK; + }else{ //80-99 - 20% + this.wait = false; + this.state = State.RUNNING; + } } break; } diff --git a/src/fr/klemek/minimario/MarioWindow.java b/src/fr/klemek/minimario/MarioWindow.java index fe941c8..a8a8b39 100644 --- a/src/fr/klemek/minimario/MarioWindow.java +++ b/src/fr/klemek/minimario/MarioWindow.java @@ -25,7 +25,7 @@ public class MarioWindow extends JWindow implements ActionListener { private static final long serialVersionUID = 1L; - private static final String VERSION = "1.6"; + private static final String VERSION = "1.6.1"; private static final int REFRESH_MS = 20; private static final int TILE_W = 20;