Browse code

fix color quest

devnewton authored on 09/11/2014 at 21:15:30
Showing 6 changed files
... ...
@@ -42,48 +42,48 @@ public strictfp class Cloud extends AnimatedPlatform implements Updatable {
42 42
     private boolean touched = false;
43 43
     private long disappearEndTime = -1;
44 44
     private float alpha = 1.0f;
45
-	private NewtonColor color;
45
+    private NewtonColor color = NewtonColor.white;
46 46
     private static final long disappearDuration = 1000000000L;
47 47
 
48 48
     public Cloud(World world, float w, float h) {
49 49
         super(world, w, h);
50 50
     }
51
-    
51
+
52 52
     public Cloud(World world, Shape shape) {
53
-    	super(world, shape);
54
-	}
53
+        super(world, shape);
54
+    }
55 55
 
56
-	@Override
56
+    @Override
57 57
     public void collided(Body body) {
58
-        if( body instanceof Hero && checkColor((Hero)body) ) {
58
+        if (body instanceof Hero && checkColor((Hero) body)) {
59 59
             touched = true;
60 60
         }
61 61
     }
62 62
 
63 63
     private boolean checkColor(Hero hero) {
64
-		return null == color || hero.getColor() == color;
65
-	}
64
+        return NewtonColor.white == color || hero.getColor() == color;
65
+    }
66 66
 
67
-	@Override
67
+    @Override
68 68
     public void draw() {
69
-        world.getView().drawCloud(this,alpha);       
69
+        world.getView().drawCloud(this, alpha);
70 70
     }
71 71
 
72 72
     @Override
73 73
     public void update(FrameTimeInfos frameTimeInfos) {
74
-       if( touched) {
75
-           if( disappearEndTime < 0 )
76
-               disappearEndTime = frameTimeInfos.currentTime + disappearDuration;
77
-           else if( frameTimeInfos.currentTime  < disappearEndTime ) {
78
-               alpha =  (disappearEndTime -  frameTimeInfos.currentTime) / (float)disappearDuration;
79
-           } else {
80
-               world.remove(this);
81
-           }
82
-       }
74
+        if (touched) {
75
+            if (disappearEndTime < 0) {
76
+                disappearEndTime = frameTimeInfos.currentTime + disappearDuration;
77
+            } else if (frameTimeInfos.currentTime < disappearEndTime) {
78
+                alpha = (disappearEndTime - frameTimeInfos.currentTime) / (float) disappearDuration;
79
+            } else {
80
+                world.remove(this);
81
+            }
82
+        }
83
+    }
84
+
85
+    public void setColor(NewtonColor color) {
86
+        this.color = color;
83 87
     }
84
-    
85
-	public void setColor(NewtonColor color) {
86
-		this.color  = color;
87
-	}
88
-    
89
-}
90 88
\ No newline at end of file
89
+
90
+}
... ...
@@ -41,7 +41,7 @@ import net.phys2d.raw.Body;
41 41
  */
42 42
 public strictfp class Colorizer extends AnimatedPlatform implements CollisionDetectionOnly, Updatable {
43 43
 
44
-    private NewtonColor color;
44
+    private NewtonColor color = NewtonColor.white;
45 45
 
46 46
     Colorizer(World world, float w, float h) {
47 47
     	super(world, w, h);
... ...
@@ -8,7 +8,7 @@ import net.phys2d.raw.CollisionEvent;
8 8
 
9 9
 public strictfp class DangerousMovingPlatform extends MovingPlatform {
10 10
 	
11
-	private NewtonColor color = null;
11
+	private NewtonColor color = NewtonColor.white;
12 12
 
13 13
 	public DangerousMovingPlatform(World world,
14 14
 			AnimationCollection texture, Vector2f[] destinations, float w,
... ...
@@ -20,7 +20,7 @@ public strictfp class DangerousMovingPlatform extends MovingPlatform {
20 20
 	public void collided(Body other) {
21 21
 		if (other instanceof Hero) {
22 22
 			Hero hero = (Hero) other;
23
-			if (hero.isInvincible() || color == hero.getColor()) {
23
+			if (hero.isInvincible() || (NewtonColor.white != color && color == hero.getColor())) {
24 24
 				return;
25 25
 			}
26 26
 			CollisionEvent[] events = world.getContacts(this);
... ...
@@ -53,7 +53,7 @@ public strictfp class Door extends AbstractDrawableStaticBody implements
53 53
 	protected final World world;
54 54
 	private AnimationCollection texture;
55 55
 	private Play play;
56
-	private NewtonColor color;
56
+	private NewtonColor color = NewtonColor.white;
57 57
 	protected boolean isClose = true;
58 58
 
59 59
 	Door(World world, float w, float h) {
... ...
@@ -93,7 +93,7 @@ public strictfp class Door extends AbstractDrawableStaticBody implements
93 93
 	}
94 94
 
95 95
 	public boolean isOpenableWithKey(Key key) {
96
-		return null == color || color == key.getColor();
96
+		return NewtonColor.white == color || color == key.getColor();
97 97
 	}
98 98
 
99 99
 	@Override
... ...
@@ -19,7 +19,9 @@
19 19
         <!-- you can pass these on the command line as -Dkeystore.password=foo etc. -->
20 20
         <keystore.password></keystore.password>
21 21
         <key.password></key.password>
22
-        <android.sdk.path>${env.HOME}/dev/adt-bundle-linux-x86-20131030/sdk</android.sdk.path>
22
+        <android.sdk.path>${env.HOME}/Documents/NetBeansProjects/adt-bundle-windows-x86_64-20140702/sdk</android.sdk.path>
23
+        <android.version>4.1.1.4</android.version>
24
+        <android.maven.version>4.0.0-rc.2</android.maven.version>
23 25
     </properties>
24 26
 
25 27
     <dependencies>
... ...
@@ -36,14 +38,6 @@
36 36
         </dependency>
37 37
 
38 38
         <dependency>
39
-            <groupId>com.googlecode.playn</groupId>
40
-            <artifactId>playn-android-nativelib</artifactId>
41
-            <version>1.0</version>
42
-            <scope>runtime</scope>
43
-            <type>so</type>
44
-        </dependency>
45
-
46
-        <dependency>
47 39
             <groupId>com.google.android</groupId>
48 40
             <artifactId>android</artifactId>
49 41
             <version>${android.version}</version>
... ...
@@ -362,7 +362,7 @@ public class PlaynGameView implements IGameView {
362 362
                     surface.scale(-1.0f, 1.0f);
363 363
                 }
364 364
                 NewtonColor color = hero.getColor();
365
-                surface.setTint(Color.rgb((int) (color.r * 255), (int) (color.g * 255), (int) (color.r * 255)));
365
+                surface.setTint(Color.rgb((int) (color.r * 255), (int) (color.g * 255), (int) (color.b * 255)));
366 366
                 surface.drawImage(image, x1, y1, bounds.getWidth(), bounds.getHeight(),
367 367
                         texture.getU1()
368 368
                         * image.width(), texture.getV1() * image.height(), (texture.getU2() - texture.getU1()) * image.width(),
... ...
@@ -385,7 +385,7 @@ public class PlaynGameView implements IGameView {
385 385
             surface.rotate(world.getGravityAngle());
386 386
             surface.scale(1, -1);
387 387
             NewtonColor color = key.getColor();
388
-            surface.setTint(Color.rgb((int) (color.r * 255), (int) (color.g * 255), (int) (color.r * 255)));
388
+            surface.setTint(Color.rgb((int) (color.r * 255), (int) (color.g * 255), (int) (color.b * 255)));
389 389
             surface.drawImage(image, -w / 2.0f, -h / 2.0f, w, h, texture.getU1() * image.width(), texture.getV1() * image.height(), (texture.getU2() - texture.getU1()) * image.width(), (texture.getV2() - texture.getV1()) * image.height());
390 390
             surface.setTint(Color.rgb(255, 255, 255));
391 391
             surface.restore();