소스 검색

new ramp tiles, ramp wood texture, londoners are killable by jumping on them, small collision bugfix when walking upstairs, fixed black tiles in levels, test level improvemed, walking sounds are now correct (water), jump sound for londoners and hero, more transparent water, london street, london dirt, london background, resource clean up, london street lamp, london styled test level, block data storage for each level (bug fix)

Kajetan Johannes Hammerle 5 년 전
부모
커밋
f65d970148
89개의 변경된 파일273개의 추가작업 그리고 251개의 파일을 삭제
  1. BIN
      levels/00-Tech_Demo.map
  2. BIN
      levels/01-Tech_Demo.map
  3. BIN
      levels/02-Parabola.map
  4. BIN
      levels/03-Higher_Ground.map
  5. BIN
      levels/04-Like_Ice.map
  6. BIN
      levels/04-Out_of_Reach.map
  7. BIN
      levels/05-Like_Ice.map
  8. 1 1
      options.txt
  9. BIN
      resources/london_background/london_background.png
  10. BIN
      resources/london_streets/london_streets0.png
  11. BIN
      resources/london_streets/london_streets1.png
  12. BIN
      resources/london_streets/london_streets10.png
  13. BIN
      resources/london_streets/london_streets11.png
  14. BIN
      resources/london_streets/london_streets12.png
  15. BIN
      resources/london_streets/london_streets13.png
  16. BIN
      resources/london_streets/london_streets14.png
  17. BIN
      resources/london_streets/london_streets15.png
  18. BIN
      resources/london_streets/london_streets2.png
  19. BIN
      resources/london_streets/london_streets3.png
  20. BIN
      resources/london_streets/london_streets4.png
  21. BIN
      resources/london_streets/london_streets5.png
  22. BIN
      resources/london_streets/london_streets6.png
  23. BIN
      resources/london_streets/london_streets7.png
  24. BIN
      resources/london_streets/london_streets8.png
  25. BIN
      resources/london_streets/london_streets9.png
  26. BIN
      resources/street_light/street_light.png
  27. BIN
      resources/street_light/street_light0_0.png
  28. BIN
      resources/street_light/street_light0_1.png
  29. BIN
      resources/street_light/street_light0_2.png
  30. BIN
      resources/street_light/street_light0_3.png
  31. BIN
      resources/street_light/street_light0_4.png
  32. BIN
      resources/street_light/street_light1_0.png
  33. BIN
      resources/street_light/street_light1_1.png
  34. BIN
      resources/street_light/street_light1_2.png
  35. BIN
      resources/street_light/street_light1_3.png
  36. BIN
      resources/street_light/street_light1_4.png
  37. BIN
      resources/street_light/street_light2_0.png
  38. BIN
      resources/street_light/street_light2_1.png
  39. BIN
      resources/street_light/street_light2_2.png
  40. BIN
      resources/street_light/street_light2_3.png
  41. BIN
      resources/street_light/street_light2_4.png
  42. BIN
      resources/street_light/street_light3_0.png
  43. BIN
      resources/street_light/street_light3_1.png
  44. BIN
      resources/street_light/street_light3_2.png
  45. BIN
      resources/street_light/street_light3_3.png
  46. BIN
      resources/street_light/street_light3_4.png
  47. BIN
      resources/street_light/street_light4_0.png
  48. BIN
      resources/street_light/street_light4_1.png
  49. BIN
      resources/street_light/street_light4_2.png
  50. BIN
      resources/street_light/street_light4_3.png
  51. BIN
      resources/street_light/street_light4_4.png
  52. BIN
      resources/tiles.png
  53. BIN
      resources/tiles.xcf
  54. BIN
      resources/water/water_frame1.png
  55. BIN
      resources/water/water_frame2.png
  56. BIN
      resources/water/water_frame3.png
  57. BIN
      resources/water/water_frame4.png
  58. BIN
      resources/water/water_frame5.png
  59. BIN
      resources/water/water_frame6.png
  60. BIN
      resources/water/water_frame7.png
  61. BIN
      resources/water/water_frame8.png
  62. 5 3
      slot1.txt
  63. 3 0
      slot2.txt
  64. 26 7
      src/me/hammerle/supersnuvi/Game.java
  65. 3 3
      src/me/hammerle/supersnuvi/entity/Entity.java
  66. 2 1
      src/me/hammerle/supersnuvi/entity/EntityBuilder.java
  67. 1 1
      src/me/hammerle/supersnuvi/entity/components/DefaultHealth.java
  68. 6 0
      src/me/hammerle/supersnuvi/entity/components/DefaultMovement.java
  69. 5 0
      src/me/hammerle/supersnuvi/entity/components/Movement.java
  70. 0 76
      src/me/hammerle/supersnuvi/entity/components/ai/FollowHeroController.java
  71. 4 2
      src/me/hammerle/supersnuvi/entity/components/ai/HumanController.java
  72. 56 17
      src/me/hammerle/supersnuvi/entity/components/ai/LondonerController.java
  73. 0 50
      src/me/hammerle/supersnuvi/entity/components/ai/WalkController.java
  74. 10 23
      src/me/hammerle/supersnuvi/gamelogic/Level.java
  75. 13 12
      src/me/hammerle/supersnuvi/tiles/BottledSoulTile.java
  76. 16 17
      src/me/hammerle/supersnuvi/tiles/CrumblingStoneTile.java
  77. 2 1
      src/me/hammerle/supersnuvi/tiles/GoalTile.java
  78. 3 2
      src/me/hammerle/supersnuvi/tiles/KillTile.java
  79. 10 1
      src/me/hammerle/supersnuvi/tiles/Location.java
  80. 4 2
      src/me/hammerle/supersnuvi/tiles/NullTile.java
  81. 3 3
      src/me/hammerle/supersnuvi/tiles/Ramp.java
  82. 0 9
      src/me/hammerle/supersnuvi/tiles/SkyTile.java
  83. 2 1
      src/me/hammerle/supersnuvi/tiles/SlipperyTile.java
  84. 2 3
      src/me/hammerle/supersnuvi/tiles/SpikeTile.java
  85. 3 1
      src/me/hammerle/supersnuvi/tiles/StartTile.java
  86. 7 11
      src/me/hammerle/supersnuvi/tiles/Tile.java
  87. 2 1
      src/me/hammerle/supersnuvi/tiles/TrampolinTile.java
  88. 3 3
      src/me/hammerle/supersnuvi/tiles/WaterTile.java
  89. 81 0
      src/me/hammerle/supersnuvi/util/BlockDataStorage.java

BIN
levels/00-Tech_Demo.map


BIN
levels/01-Tech_Demo.map


BIN
levels/01-Parabola.map → levels/02-Parabola.map


BIN
levels/03-Higher_Ground.map


BIN
levels/04-Like_Ice.map


BIN
levels/02-Out_of_Reach.map → levels/04-Out_of_Reach.map


BIN
levels/05-Like_Ice.map


+ 1 - 1
options.txt

@@ -12,4 +12,4 @@ key.left=263
 key.right=262
 key.run=340
 key.up=265
-sound=true
+sound=false

BIN
resources/london_background/london_background.png


BIN
resources/london_streets/london_streets0.png


BIN
resources/london_streets/london_streets1.png


BIN
resources/london_streets/london_streets10.png


BIN
resources/london_streets/london_streets11.png


BIN
resources/london_streets/london_streets12.png


BIN
resources/london_streets/london_streets13.png


BIN
resources/london_streets/london_streets14.png


BIN
resources/london_streets/london_streets15.png


BIN
resources/london_streets/london_streets2.png


BIN
resources/london_streets/london_streets3.png


BIN
resources/london_streets/london_streets4.png


BIN
resources/london_streets/london_streets5.png


BIN
resources/london_streets/london_streets6.png


BIN
resources/london_streets/london_streets7.png


BIN
resources/london_streets/london_streets8.png


BIN
resources/london_streets/london_streets9.png


BIN
resources/street_light/street_light.png


BIN
resources/street_light/street_light0_0.png


BIN
resources/street_light/street_light0_1.png


BIN
resources/street_light/street_light0_2.png


BIN
resources/street_light/street_light0_3.png


BIN
resources/street_light/street_light0_4.png


BIN
resources/street_light/street_light1_0.png


BIN
resources/street_light/street_light1_1.png


BIN
resources/street_light/street_light1_2.png


BIN
resources/street_light/street_light1_3.png


BIN
resources/street_light/street_light1_4.png


BIN
resources/street_light/street_light2_0.png


BIN
resources/street_light/street_light2_1.png


BIN
resources/street_light/street_light2_2.png


BIN
resources/street_light/street_light2_3.png


BIN
resources/street_light/street_light2_4.png


BIN
resources/street_light/street_light3_0.png


BIN
resources/street_light/street_light3_1.png


BIN
resources/street_light/street_light3_2.png


BIN
resources/street_light/street_light3_3.png


BIN
resources/street_light/street_light3_4.png


BIN
resources/street_light/street_light4_0.png


BIN
resources/street_light/street_light4_1.png


BIN
resources/street_light/street_light4_2.png


BIN
resources/street_light/street_light4_3.png


BIN
resources/street_light/street_light4_4.png


BIN
resources/tiles.png


BIN
resources/tiles.xcf


BIN
resources/water/water_frame1.png


BIN
resources/water/water_frame2.png


BIN
resources/water/water_frame3.png


BIN
resources/water/water_frame4.png


BIN
resources/water/water_frame5.png


BIN
resources/water/water_frame6.png


BIN
resources/water/water_frame7.png


BIN
resources/water/water_frame8.png


+ 5 - 3
slot1.txt

@@ -2,11 +2,13 @@ level.00-Tech_Demo.map=true
 level.00-Tech_Demo.map.bottles=9
 level.00-Tech_Demo.map.time=1.5374999999999965
 level.01-Parabola.map=true
-level.01-Parabola.map.bottles=2
+level.01-Parabola.map.bottles=4
 level.01-Parabola.map.time=1.6249999999999962
+level.01-Tech_Demo.map=true
+level.01-Tech_Demo.map.time=3.6499977
 level.02-Out_of_Reach.map=true
-level.02-Out_of_Reach.map.bottles=8
+level.02-Out_of_Reach.map.bottles=10
 level.02-Out_of_Reach.map.time=9.674999999999985
 level.04-Like_Ice.map=true
-level.04-Like_Ice.map.bottles=12
+level.04-Like_Ice.map.bottles=13
 level.04-Like_Ice.map.time=20.69997

+ 3 - 0
slot2.txt

@@ -1 +1,4 @@
 level.00-Tech Demo=true
+level.03-Higher_Ground.map=true
+level.03-Higher_Ground.map.bottles=5
+level.03-Higher_Ground.map.time=43.64962

+ 26 - 7
src/me/hammerle/supersnuvi/Game.java

@@ -34,7 +34,7 @@ public class Game extends Engine
     public static final NullTile FALLBACK_TILE = new NullTile();
     
     // tiles
-    private final Tile[] registeredTiles = new Tile[39];
+    private final Tile[] registeredTiles = new Tile[70];
     
     // levels
     private Level currentLevel = null;
@@ -578,7 +578,7 @@ public class Game extends Engine
         // snuvi start block
         registeredTiles[24] = new StartTile();
         // sky
-        registeredTiles[25] = new SkyTile();
+        registeredTiles[25] = new BaseTile(0.0f, 0.0f, 0.0625f, 0.0625f);
         // slippery slime
         registeredTiles[26] = new SlipperyTile();
         // end level
@@ -594,9 +594,28 @@ public class Game extends Engine
         registeredTiles[34] = new DecoShroomTile(0.0625f, 0.21875f, 0.125f, 0.25f);
         registeredTiles[35] = new DecoShroomTile(0.0625f, 0.1875f, 0.125f, 0.21875f);
         // ramp
-        registeredTiles[36] = new Ramp();
-        registeredTiles[37] = new Ramp();
-        registeredTiles[38] = new Ramp();
+        registeredTiles[36] = new Ramp(0.375f, 0.0f, 0.4375f, 0.0625f, 0.0f, Tile.SIZE, Tile.SIZE, 0.0f);
+        registeredTiles[37] = new Ramp(0.4375f, 0.0f, 0.5f, 0.0625f, 0.0f, Tile.SIZE, Tile.SIZE, Tile.SIZE * 0.5f);
+        registeredTiles[38] = new Ramp(0.5f, 0.0f, 0.5625f, 0.0625f, 0.0f, Tile.SIZE * 0.5f, Tile.SIZE, 0.0f);
+        registeredTiles[39] = new Ramp(0.375f, 0.0625f, 0.4375f, 0.125f, Tile.SIZE, Tile.SIZE, 0.0f, 0.0f);
+        registeredTiles[40] = new Ramp(0.4375f, 0.0625f, 0.5f, 0.125f, Tile.SIZE, Tile.SIZE, 0.0f, Tile.SIZE * 0.5f);
+        registeredTiles[41] = new Ramp(0.5f, 0.0625f, 0.5625f, 0.125f, Tile.SIZE, Tile.SIZE * 0.5f, 0.0f, 0.0f);
+        
+        // london stuff
+        // street
+        registeredTiles[42] = new BaseBoxTile(0.3125f, 0.125f, 0.375f, 0.1875f);
+        // dirt
+        registeredTiles[43] = new BaseBoxTile(0.375f, 0.125f, 0.4375f, 0.1875f);
+        // background
+        registeredTiles[44] = new BaseTile(0.3125f, 0.0625f, 0.375f, 0.125f);
+        // street lamp
+        for(int x = 0; x < 5; x++)
+        {
+            for(int y = 0; y < 5; y++)
+            {
+                registeredTiles[45 + 5 * y + x] = new BaseTile(0.0625f * x, 0.25f + 0.0625f * y, 0.0625f * (x + 1), 0.25f + 0.0625f * (y + 1));
+            }
+        }
     }
     
     public Tile getTile(int id)
@@ -608,11 +627,11 @@ public class Game extends Engine
         return registeredTiles[id];
     }
     
-    public void resetTiles()
+    public void resetTiles(Level l)
     {
         for(Tile t : registeredTiles)
         {
-            t.reset();
+            t.reset(l);
         }
     }
     

+ 3 - 3
src/me/hammerle/supersnuvi/entity/Entity.java

@@ -17,7 +17,7 @@ public final class Entity
     public static final float STEP = 0.0625f;
     // this one is a little bit bigger to prevent wrong calculation
     // while joing upwars
-    public static final float UP_STEP = STEP + 0.001953125f;
+    public static final float UP_STEP = STEP + 0.00390625f;
     
     // the last position is used for interpolation during rendering
     private float lastPosX;
@@ -229,7 +229,7 @@ public final class Entity
         }
         else
         {
-            CollisionObject testBox = box.copy().expand(preMotionX, preMotionY);
+            CollisionObject testBox = box.copy().expand(preMotionX, preMotionY).expand(0.0f, -UP_STEP);
             List<CollisionObject> boxes = level.getMovementBoxesAt(testBox, this);
             if(!boxes.isEmpty())
             {
@@ -361,7 +361,7 @@ public final class Entity
                 level.getCollisionBoxesAt(cb).forEach(loc -> 
                 {
                     controller.onCollideWithTile(loc, f);
-                    loc.getTile().onEntityCollide(this, loc.getX(), loc.getY(), f.getOpposite());
+                    loc.getTile().onEntityCollide(this, loc.getX(), loc.getY(), f.getOpposite(), level);
                 });
             }
 

+ 2 - 1
src/me/hammerle/supersnuvi/entity/EntityBuilder.java

@@ -13,6 +13,7 @@ import me.hammerle.supersnuvi.entity.components.ItemCollector;
 import me.hammerle.supersnuvi.entity.components.NoHealth;
 import me.hammerle.supersnuvi.entity.components.ai.StoneController;
 import me.hammerle.supersnuvi.util.CollisionBox;
+import me.hammerle.supersnuvi.util.SoundUtils.Sound;
 
 public final class EntityBuilder 
 {
@@ -20,7 +21,7 @@ public final class EntityBuilder
     {
         Entity hero = new Entity(level, x, y, new CollisionBox(0.0f, 5.0f, 27.0f, 64.0f));
         hero.controller = new HumanController(hero);
-        hero.health = new DefaultHealth(hero, (ent) -> ent.getLevel().scheduleReset(), 100.0f, null, null, null);
+        hero.health = new DefaultHealth(hero, (ent) -> ent.getLevel().scheduleReset(), 100.0f, null, Sound.MIRROR_CRACK, Sound.MIRROR_BREAK);
         hero.energy = new DefaultEnergy(hero, 100.0f);
         hero.move = new DefaultMovement(hero, 12.0f, 0.0f, 50.0f);
         hero.itemCollector = ItemCollector.HERO;

+ 1 - 1
src/me/hammerle/supersnuvi/entity/components/DefaultHealth.java

@@ -100,7 +100,7 @@ public class DefaultHealth extends Health
             {
                 return;
             }
-            invincibility = Game.getTicksForMillis(1000);
+            invincibility = Game.getTicksForMillis(500);
             hurtTicks = Game.getTicksForMillis(500);
             SoundUtils.playSound(soundHurt);
         }

+ 6 - 0
src/me/hammerle/supersnuvi/entity/components/DefaultMovement.java

@@ -70,6 +70,12 @@ public class DefaultMovement extends Movement
         inWater = b;
     }
 
+    @Override
+    public boolean isInWater()
+    {
+        return inWater;
+    }
+
     @Override
     public void setFrictionFactor(float f)
     {

+ 5 - 0
src/me/hammerle/supersnuvi/entity/components/Movement.java

@@ -64,6 +64,11 @@ public class Movement
     {
     }
     
+    public boolean isInWater()
+    {
+        return false;
+    }
+    
     public void setFrictionFactor(float f)
     {
     }

+ 0 - 76
src/me/hammerle/supersnuvi/entity/components/ai/FollowHeroController.java

@@ -1,76 +0,0 @@
-package me.hammerle.supersnuvi.entity.components.ai;
-
-import me.hammerle.supersnuvi.entity.Entity;
-
-public class FollowHeroController extends Controller
-{
-    private final float motion;
-    private boolean jump;
-    
-    public FollowHeroController(Entity ent, float motion)
-    {
-        super(ent);
-        this.motion = motion;
-        this.jump = false;
-    }
-
-    /*@Override
-    public void tick() 
-    {
-        if(ent.getHealth().isDead())
-        {
-            return;
-        }
-        Entity hero = ent.getLevel().getHero();
-        if(hero.squaredDistance(ent) <= 409600)
-        {
-            if(jump)
-            {
-                jump = false;
-                SoundUtils.playSound(SoundUtils.Sound.LONDONER_JUMP);
-                ent.getMovement().jump();
-            }
-            float distance = ent.signedDistanceX(hero);
-            if(distance < 0)
-            {
-                ent.setMotionX(motion * ent.getMovementPenalty().getFactor());
-            }
-            else if(distance > 0)
-            {
-                ent.setMotionX(-motion * ent.getMovementPenalty().getFactor());
-            }
-        }
-    }
-
-    @Override
-    public void onCollideWithEntity(Entity ent, Face face) 
-    {
-        if(this.ent.signedDistanceX(ent) == 0)
-        {
-            if(ent.getX() - this.ent.getX() > 0)
-            {
-                ent.setMotionX(6.0f);
-            }
-            else
-            {
-                ent.setMotionX(-6.0f);
-            }
-            ent.getHealth().addHealth(-0.05);
-            if(ent.getMovement().useCollisionBox())
-            {
-                jump = true;
-            }
-        }
-    }
-
-    @Override
-    public void onCollideWithTile(Location loc, Face face) 
-    {
-        if((face == Face.LEFT || face == Face.RIGHT) && 
-                Math.abs(ent.getPreviousMotionX() - ent.getMotionX()) > 0.001 &&
-                Math.abs(ent.signedDistanceX(ent.getLevel().getHero())) > 0.001)
-        {
-            jump = true;
-        }
-    }*/
-}

+ 4 - 2
src/me/hammerle/supersnuvi/entity/components/ai/HumanController.java

@@ -6,6 +6,7 @@ import me.hammerle.supersnuvi.Keys;
 import me.hammerle.supersnuvi.entity.Entity;
 import me.hammerle.supersnuvi.util.Face;
 import me.hammerle.supersnuvi.util.SoundUtils;
+import me.hammerle.supersnuvi.util.SoundUtils.Sound;
 import me.hammerle.supersnuvi.util.Utils;
 
 public class HumanController extends Controller
@@ -103,19 +104,20 @@ public class HumanController extends Controller
         if(Keys.LEFT.isDown())
         {
             ent.setMotionX(-speed);
-            SoundUtils.playSound(SoundUtils.Sound.WALK);
+            SoundUtils.playSound(ent.getMovement().isInWater() ? SoundUtils.Sound.WALK_WATER : SoundUtils.Sound.WALK);
         }
         
         if(Keys.RIGHT.isDown())
         {
             ent.setMotionX(speed);
-            SoundUtils.playSound(SoundUtils.Sound.WALK);
+            SoundUtils.playSound(ent.getMovement().isInWater() ? SoundUtils.Sound.WALK_WATER : SoundUtils.Sound.WALK);
         }
         
         if(Keys.JUMP.isDown())
         {
             if(ent.getEnergy().getEnergyPercent() >= 0.1f && ent.getMovement().jump())
             {
+                SoundUtils.playSound(Sound.JUMP);
                 ent.getEnergy().addEnergyPercent(-0.1f);
             }
         }

+ 56 - 17
src/me/hammerle/supersnuvi/entity/components/ai/LondonerController.java

@@ -4,7 +4,9 @@ import me.hammerle.snuviengine.api.Shader;
 import me.hammerle.snuviengine.api.Texture;
 import me.hammerle.supersnuvi.entity.Entity;
 import me.hammerle.supersnuvi.tiles.Location;
+import me.hammerle.supersnuvi.tiles.Ramp;
 import me.hammerle.supersnuvi.util.Face;
+import me.hammerle.supersnuvi.util.SoundUtils;
 import me.hammerle.supersnuvi.util.Utils;
 
 public class LondonerController extends Controller
@@ -23,6 +25,11 @@ public class LondonerController extends Controller
     private int deathFrame = 0;
     
     private Face direction = Face.LEFT;
+    
+    private boolean shouldJump = false;
+    
+    private Entity hurt = null;
+    private Entity attacker = null;
 
     public LondonerController(Entity ent, boolean evil) 
     {
@@ -104,6 +111,41 @@ public class LondonerController extends Controller
             }
         }
         
+        if(shouldJump)
+        {
+            SoundUtils.playSound(SoundUtils.Sound.LONDONER_JUMP);
+            ent.getMovement().jump();
+            shouldJump = false;
+        }
+        
+        if(attacker != null)
+        {
+            this.ent.getHealth().addHealthPercent(-0.201f);
+            attacker.setMotionY(-attacker.getMovement().getJumpPower());
+            
+            attacker = null;
+            hurt = null;
+        }
+        
+        if(hurt != null)
+        {
+            hurt.getHealth().addHealthPercent(-0.1f);
+
+            hurt.setMotionY(ent.getMotionY() - 20.0f);
+
+            float hx = hurt.getLevel().getHero().getCenterX();
+            if(hx < hurt.getCenterX())
+            {
+                hurt.setMotionX(hurt.getMotionX() - 10.0f);
+            }
+            else
+            {
+                hurt.setMotionX(hurt.getMotionX() + 10.0f);
+            }
+            
+            hurt = null;
+        }
+        
         ox = ent.getFace() == Face.RIGHT ? 0.0f: -36.0f;
         
         if(ent.isOnGround())
@@ -180,14 +222,14 @@ public class LondonerController extends Controller
     {
         if(hasRedEyes())
         {
-            if(face.getOpposite() == ent.getFace() && ent.getMotionX() == 0.0f)
+            if(!(loc.getTile() instanceof Ramp) && face.getOpposite() == ent.getFace() && ent.getMotionX() == 0.0f)
             {
-                ent.getMovement().jump();
+                shouldJump = true;
             }
         }
         else
         {
-            if(loc.getTile().shouldAiUseCollisionBox(loc.getX(), loc.getY()))
+            if(loc.getTile().shouldAiUseCollisionBox(loc.getX(), loc.getY(), loc.getLevel()))
             {
                 switch(face)
                 {
@@ -205,21 +247,18 @@ public class LondonerController extends Controller
     @Override
     public void onCollideWithEntity(Entity ent, Face face)
     {
-        if(ent.getItemCollector().isHero() && hasRedEyes())
+        switch(face)
         {
-            ent.getHealth().addHealthPercent(-0.1f);
-            
-            ent.setMotionY(ent.getMotionY() - 20.0f);
-            
-            float hx = ent.getLevel().getHero().getCenterX();
-            if(hx < ent.getCenterX())
-            {
-                ent.setMotionX(ent.getMotionX() - 10.0f);
-            }
-            else
-            {
-                ent.setMotionX(ent.getMotionX() + 10.0f);
-            }
+            case LEFT:
+            case RIGHT:
+                if(ent.getItemCollector().isHero() && hasRedEyes())
+                {
+                    hurt = ent;
+                }
+                break;
+            case UP:
+                attacker = ent;
+                break;
         }
     }
 }

+ 0 - 50
src/me/hammerle/supersnuvi/entity/components/ai/WalkController.java

@@ -1,50 +0,0 @@
-package me.hammerle.supersnuvi.entity.components.ai;
-
-import me.hammerle.supersnuvi.entity.Entity;
-import me.hammerle.supersnuvi.tiles.Location;
-import me.hammerle.supersnuvi.util.Face;
-
-public class WalkController extends Controller
-{
-    private float motion;
-    
-    public WalkController(Entity ent, float motion)
-    {
-        super(ent);
-        this.motion = motion;
-    }
-
-    @Override
-    public void tick() 
-    {
-        if(ent.getHealth().isDead())
-        {
-            return;
-        }
-        ent.setMotionX(motion);
-    }
-
-    /*@Override
-    public void onCollideWithEntity(Entity ent, Face face) 
-    {
-        switchDirection(face);
-    }
-
-    @Override
-    public void onCollideWithTile(Location loc, Face face) 
-    {
-        switchDirection(face);
-    }*/
-    
-    private void switchDirection(Face face)
-    {
-        if(face == Face.LEFT)
-        {
-            motion = -Math.abs(motion);
-        }
-        else if(face == Face.RIGHT)
-        {
-            motion = Math.abs(motion);
-        }
-    }
-}

+ 10 - 23
src/me/hammerle/supersnuvi/gamelogic/Level.java

@@ -84,24 +84,11 @@ public final class Level
             }
             
             // debug stuff
-            if(name.equals("00-Tech Demo"))
+            /*if(name.equals("01-Tech Demo"))
             {
-                int index = data.getBackgroundIndex() + 1;
-                //data.setTile(index, 12, 10, 2);
-                /*data.setTile(index, 13, 9, -6);
-                data.setTile(index, 14, 9, -6);
-                data.setTile(index, 15, 9, -6);
-                data.setTile(index, 16, 9, 6);
-                data.save();*/
-                
-                /*data.setTile(index, 3, 12, 5);
-                
-                for(int i = 0; i < 4; i++)
-                {
-                    data.setTile(index, 9 - i, 9 + i, 36);
-                }
-                */
-            }
+                int l = data.getBackgroundIndex();
+                    
+            }*/
             // end debug stuff
             
             maxSouls = 0;
@@ -146,7 +133,7 @@ public final class Level
 
         resetLevel();
     }
-    
+
     // -------------------------------------------------------------------------
     // basic stuff
     // -------------------------------------------------------------------------
@@ -199,7 +186,7 @@ public final class Level
                 dead = true;
             }
         }*/
-        Game.get().resetTiles();
+        Game.get().resetTiles(this);
         data.activateEntities();
         souls = 0;
         time = 0.0f;
@@ -452,7 +439,7 @@ public final class Level
                 for(int y = tsy; y < tey; y++)
                 {
                     Tile t = Game.get().getTile(data.getTile(tl, x, y));
-                    if(t.shouldRender(x, y))
+                    if(t.shouldRender(x, y, this))
                     {
                         float minX = x * Tile.SIZE + t.getOffsetX();
                         float minY = y * Tile.SIZE + t.getOffsetY();
@@ -637,7 +624,7 @@ public final class Level
         {
             return CollisionObject.NULL_BOX;
         }
-        return Game.get().getTile(i).getMovementBox(x, y).reset().offset(Utils.toCoord(x), Utils.toCoord(y));
+        return Game.get().getTile(i).getMovementBox(x, y, this).reset().offset(Utils.toCoord(x), Utils.toCoord(y));
     }
     
     public List<CollisionObject> getMovementBoxesAt(CollisionObject box, Entity not)
@@ -678,7 +665,7 @@ public final class Level
             return CollisionObject.NULL_BOX;
         }
         Tile tile = Game.get().getTile(i);
-        return tile.getCollisionBox(x, y).reset().offset(Utils.toCoord(x), Utils.toCoord(y));
+        return tile.getCollisionBox(x, y, this).reset().offset(Utils.toCoord(x), Utils.toCoord(y));
     }
     
     public List<Location> getCollisionBoxesAt(CollisionObject cb)
@@ -695,7 +682,7 @@ public final class Level
             {
                 if(getCollisionBox(x, y).isColliding(cb))
                 {
-                    boxes.add(new Location(getInteractionTile(x, y), x, y));
+                    boxes.add(new Location(getInteractionTile(x, y), this, x, y));
                 }
             }
         }

+ 13 - 12
src/me/hammerle/supersnuvi/tiles/BottledSoulTile.java

@@ -2,6 +2,8 @@ package me.hammerle.supersnuvi.tiles;
 
 import java.util.HashSet;
 import me.hammerle.supersnuvi.entity.Entity;
+import me.hammerle.supersnuvi.gamelogic.Level;
+import me.hammerle.supersnuvi.util.BlockDataStorage;
 import me.hammerle.supersnuvi.util.CollisionBox;
 import me.hammerle.supersnuvi.util.CollisionObject;
 import me.hammerle.supersnuvi.util.Face;
@@ -9,23 +11,22 @@ import me.hammerle.supersnuvi.util.SoundUtils;
 
 public class BottledSoulTile extends BaseTile
 {
-    private final HashSet<Long> states;
+    private final BlockDataStorage states = new BlockDataStorage();
     private final int score;
     
     public BottledSoulTile(int score)
     {
         super(0.0625f * (score - 1), 0.0625f, 0.0625f * score, 0.125f);
-        states = new HashSet<>();
         super.setCollisionBox(CollisionBox.createScaledTileBox(0.2f, 0.2f, 0.8f, 0.8f));
         this.score = score;
     }
 
     @Override
-    public void onEntityCollide(Entity ent, int x, int y, Face face) 
+    public void onEntityCollide(Entity ent, int x, int y, Face face, Level l) 
     {
         if(ent.getItemCollector().canCollect())
         {
-            if(states.add(getKey(x, y)))
+            if(states.add(x, y, l))
             {
                 ent.getLevel().updateTile(x, y);
                 if(ent.getItemCollector().isHero())
@@ -39,31 +40,31 @@ public class BottledSoulTile extends BaseTile
     }
     
     @Override
-    public CollisionObject getCollisionBox(int x, int y) 
+    public CollisionObject getCollisionBox(int x, int y, Level l) 
     {
-        if(states.contains(getKey(x, y)))
+        if(states.contains(x, y, l))
         {
             return CollisionObject.NULL_BOX;
         }
-        return super.getCollisionBox(x, y);
+        return super.getCollisionBox(x, y, l);
     }
 
     @Override
-    public boolean shouldAiUseCollisionBox(int x, int y) 
+    public boolean shouldAiUseCollisionBox(int x, int y, Level l) 
     {
         return false;
     }
     
     @Override
-    public boolean shouldRender(int x, int y) 
+    public boolean shouldRender(int x, int y, Level l) 
     {
-        return !states.contains(getKey(x, y));
+        return !states.contains(x, y, l);
     }
     
     @Override
-    public void reset() 
+    public void reset(Level l) 
     {
-        states.clear();
+        states.clear(l);
     } 
     
     @Override

+ 16 - 17
src/me/hammerle/supersnuvi/tiles/CrumblingStoneTile.java

@@ -4,6 +4,7 @@ import java.util.HashSet;
 import me.hammerle.supersnuvi.entity.Entity;
 import me.hammerle.supersnuvi.entity.EntityBuilder;
 import me.hammerle.supersnuvi.gamelogic.Level;
+import me.hammerle.supersnuvi.util.BlockDataStorage;
 import me.hammerle.supersnuvi.util.CollisionBox;
 import me.hammerle.supersnuvi.util.CollisionObject;
 import me.hammerle.supersnuvi.util.Face;
@@ -12,46 +13,44 @@ import me.hammerle.supersnuvi.util.Utils;
 
 public class CrumblingStoneTile extends BaseTile
 {
-    private final HashSet<Long> states;
+    private final BlockDataStorage states = new BlockDataStorage();
     
     public CrumblingStoneTile() 
     {
         super(0.1875f, 0.125f, 0.25f, 0.1875f);
-        states = new HashSet<>();
         super.setCollisionBox(CollisionBox.createScaledTileBox(0.0f, 0.0f, 1.0f, 0.6f));
         super.setMovementBox(CollisionBox.createScaledTileBox(0.0f, 0.0f, 1.0f, 0.6f));
     }
 
     @Override
-    public CollisionObject getCollisionBox(int x, int y) 
+    public CollisionObject getCollisionBox(int x, int y, Level l) 
     {
-        if(states.contains(getKey(x, y)))
+        if(states.contains(x, y, l))
         {
             return CollisionObject.NULL_BOX;
         }
-        return super.getCollisionBox(x, y);
+        return super.getCollisionBox(x, y, l);
     }
 
     @Override
-    public CollisionObject getMovementBox(int x, int y) 
+    public CollisionObject getMovementBox(int x, int y, Level l) 
     {
-        if(states.contains(getKey(x, y)))
+        if(states.contains(x, y, l))
         {
             return CollisionObject.NULL_BOX;
         }
-        return super.getMovementBox(x, y);
+        return super.getMovementBox(x, y, l);
     }
 
     @Override
-    public void onEntityCollide(Entity ent, int x, int y, Face face) 
+    public void onEntityCollide(Entity ent, int x, int y, Face face, Level l) 
     {
-        super.onEntityCollide(ent, x, y, face);
+        super.onEntityCollide(ent, x, y, face, l);
         if(face == Face.UP)
         {
-            if(states.add(getKey(x, y)))
+            if(states.add(x, y, l))
             {
-                ent.getLevel().updateTile(x, y);
-                Level l = ent.getLevel();               
+                ent.getLevel().updateTile(x, y);         
                 l.spawnEntity(EntityBuilder.buildCrumblingStone(l, Utils.toCoord(x), Utils.toCoord(y)));
                 SoundUtils.playSound(SoundUtils.Sound.STONE_CRUMBLING);
             }
@@ -59,14 +58,14 @@ public class CrumblingStoneTile extends BaseTile
     }
 
     @Override
-    public boolean shouldRender(int x, int y)
+    public boolean shouldRender(int x, int y, Level l)
     {
-        return !states.contains(getKey(x, y));
+        return !states.contains(x, y, l);
     }
 
     @Override
-    public void reset() 
+    public void reset(Level l) 
     {
-        states.clear();
+        states.clear(l);
     } 
 }

+ 2 - 1
src/me/hammerle/supersnuvi/tiles/GoalTile.java

@@ -1,6 +1,7 @@
 package me.hammerle.supersnuvi.tiles;
 
 import me.hammerle.supersnuvi.entity.Entity;
+import me.hammerle.supersnuvi.gamelogic.Level;
 import me.hammerle.supersnuvi.util.CollisionBox;
 import me.hammerle.supersnuvi.util.Face;
 
@@ -13,7 +14,7 @@ public class GoalTile extends BaseTile
     }
 
     @Override
-    public void onEntityCollide(Entity ent, int x, int y, Face face) 
+    public void onEntityCollide(Entity ent, int x, int y, Face face, Level l) 
     {
         if(ent.getItemCollector().isHero())
         {

+ 3 - 2
src/me/hammerle/supersnuvi/tiles/KillTile.java

@@ -1,6 +1,7 @@
 package me.hammerle.supersnuvi.tiles;
 
 import me.hammerle.supersnuvi.entity.Entity;
+import me.hammerle.supersnuvi.gamelogic.Level;
 import me.hammerle.supersnuvi.util.CollisionBox;
 import me.hammerle.supersnuvi.util.Face;
 
@@ -13,9 +14,9 @@ public class KillTile extends BaseTile
     }
 
     @Override
-    public void onEntityCollide(Entity ent, int x, int y, Face face) 
+    public void onEntityCollide(Entity ent, int x, int y, Face face, Level l) 
     {
-        super.onEntityCollide(ent, x, y, face);
+        super.onEntityCollide(ent, x, y, face, l);
         ent.getHealth().addHealth(-14.3f);
     }
 }

+ 10 - 1
src/me/hammerle/supersnuvi/tiles/Location.java

@@ -1,14 +1,18 @@
 package me.hammerle.supersnuvi.tiles;
 
+import me.hammerle.supersnuvi.gamelogic.Level;
+
 public class Location 
 {
     private final Tile tile;
+    private final Level l;
     private final int x;
     private final int y;
     
-    public Location(Tile tile, int x, int y)
+    public Location(Tile tile, Level l, int x, int y)
     {
         this.tile = tile;
+        this.l = l;
         this.x = x;
         this.y = y;        
     }
@@ -17,6 +21,11 @@ public class Location
     {
         return tile;
     }
+    
+    public Level getLevel() 
+    {
+        return l;
+    }
 
     public int getX() 
     {

+ 4 - 2
src/me/hammerle/supersnuvi/tiles/NullTile.java

@@ -1,5 +1,7 @@
 package me.hammerle.supersnuvi.tiles;
 
+import me.hammerle.supersnuvi.gamelogic.Level;
+
 public class NullTile extends Tile
 {
     public NullTile()
@@ -7,13 +9,13 @@ public class NullTile extends Tile
     }
 
     @Override
-    public boolean shouldRender(int x, int y)
+    public boolean shouldRender(int x, int y, Level l)
     {
         return false;
     }
 
     @Override
-    public boolean shouldAiUseCollisionBox(int x, int y)
+    public boolean shouldAiUseCollisionBox(int x, int y, Level l)
     {
         return false;
     }

+ 3 - 3
src/me/hammerle/supersnuvi/tiles/Ramp.java

@@ -4,11 +4,11 @@ import me.hammerle.supersnuvi.util.CollisionLine;
 
 public class Ramp extends BaseTile
 {
-    public Ramp()
+    public Ramp(float tMinX, float fMinY, float tMaxX, float tMaxY, float x1, float y1, float x2, float y2)
     {
-        super(0.375f, 0.0f, 0.4375f, 0.0625f);
+        super(tMinX, fMinY, tMaxX, tMaxY);
         
-        CollisionLine line = new CollisionLine(0.0f, Tile.SIZE, Tile.SIZE, 0.0f);
+        CollisionLine line = new CollisionLine(x1, y1, x2, y2);
         super.setCollisionBox(line);
         super.setMovementBox(line);
     }

+ 0 - 9
src/me/hammerle/supersnuvi/tiles/SkyTile.java

@@ -1,9 +0,0 @@
-package me.hammerle.supersnuvi.tiles;
-
-public class SkyTile extends BaseTile
-{
-    public SkyTile()
-    {
-        super(0.0f, 0.0f, 0.0625f, 0.0625f);
-    }
-}

+ 2 - 1
src/me/hammerle/supersnuvi/tiles/SlipperyTile.java

@@ -1,6 +1,7 @@
 package me.hammerle.supersnuvi.tiles;
 
 import me.hammerle.supersnuvi.entity.Entity;
+import me.hammerle.supersnuvi.gamelogic.Level;
 import me.hammerle.supersnuvi.util.Face;
 
 public class SlipperyTile extends BaseBoxTile
@@ -11,7 +12,7 @@ public class SlipperyTile extends BaseBoxTile
     }
 
     @Override
-    public void onEntityCollide(Entity ent, int x, int y, Face face) 
+    public void onEntityCollide(Entity ent, int x, int y, Face face, Level l) 
     {
         if(face == Face.UP)
         {

+ 2 - 3
src/me/hammerle/supersnuvi/tiles/SpikeTile.java

@@ -4,7 +4,6 @@ import me.hammerle.snuviengine.api.Texture;
 import me.hammerle.supersnuvi.entity.Entity;
 import me.hammerle.supersnuvi.gamelogic.Level;
 import me.hammerle.supersnuvi.util.CollisionBox;
-import me.hammerle.supersnuvi.util.CollisionObject;
 import me.hammerle.supersnuvi.util.Face;
 
 public class SpikeTile extends BaseTile
@@ -26,9 +25,9 @@ public class SpikeTile extends BaseTile
     }
 
     @Override
-    public void onEntityCollide(Entity ent, int x, int y, Face face) 
+    public void onEntityCollide(Entity ent, int x, int y, Face face, Level l) 
     {
-        super.onEntityCollide(ent, x, y, face);
+        super.onEntityCollide(ent, x, y, face, l);
         if(frame >= 1)
         {
             ent.getHealth().addHealth(-42.857f);

+ 3 - 1
src/me/hammerle/supersnuvi/tiles/StartTile.java

@@ -1,9 +1,11 @@
 package me.hammerle.supersnuvi.tiles;
 
+import me.hammerle.supersnuvi.gamelogic.Level;
+
 public class StartTile extends Tile
 {
     @Override
-    public boolean shouldRender(int x, int y)
+    public boolean shouldRender(int x, int y, Level l)
     {
         return false;
     }

+ 7 - 11
src/me/hammerle/supersnuvi/tiles/Tile.java

@@ -1,6 +1,7 @@
 package me.hammerle.supersnuvi.tiles;
 
 import me.hammerle.supersnuvi.entity.Entity;
+import me.hammerle.supersnuvi.gamelogic.Level;
 import me.hammerle.supersnuvi.util.CollisionObject;
 import me.hammerle.supersnuvi.util.Face;
 
@@ -64,7 +65,7 @@ public abstract class Tile
         return this;
     }
     
-    public CollisionObject getCollisionBox(int x, int y)
+    public CollisionObject getCollisionBox(int x, int y, Level l)
     {
         if(collisionBox != null)
         {
@@ -73,12 +74,12 @@ public abstract class Tile
         return CollisionObject.NULL_BOX.reset();
     }
     
-    public boolean shouldAiUseCollisionBox(int x, int y)
+    public boolean shouldAiUseCollisionBox(int x, int y, Level l)
     {
         return true;
     }
     
-    public CollisionObject getMovementBox(int x, int y)
+    public CollisionObject getMovementBox(int x, int y, Level l)
     {
         if(movementCollision != null)
         {
@@ -87,7 +88,7 @@ public abstract class Tile
         return CollisionObject.NULL_BOX.reset();
     }
     
-    public void onEntityCollide(Entity ent, int x, int y, Face face)
+    public void onEntityCollide(Entity ent, int x, int y, Face face, Level l)
     {
         
     }
@@ -96,12 +97,7 @@ public abstract class Tile
     {
     }
     
-    public long getKey(int x, int y)
-    {
-        return x | (((long) y) << 32);
-    }
-    
-    public void reset()
+    public void reset(Level l)
     {
     }
     
@@ -150,7 +146,7 @@ public abstract class Tile
         return Tile.SIZE;
     }
     
-    public boolean shouldRender(int x, int y)
+    public boolean shouldRender(int x, int y, Level l)
     {
         return true;
     }

+ 2 - 1
src/me/hammerle/supersnuvi/tiles/TrampolinTile.java

@@ -1,6 +1,7 @@
 package me.hammerle.supersnuvi.tiles;
 
 import me.hammerle.supersnuvi.entity.Entity;
+import me.hammerle.supersnuvi.gamelogic.Level;
 import me.hammerle.supersnuvi.util.Face;
 import me.hammerle.supersnuvi.util.SoundUtils;
 
@@ -12,7 +13,7 @@ public class TrampolinTile extends BaseBoxTile
     }
 
     @Override
-    public void onEntityCollide(Entity ent, int x, int y, Face face) 
+    public void onEntityCollide(Entity ent, int x, int y, Face face, Level l) 
     {
         if(face == Face.UP)
         {

+ 3 - 3
src/me/hammerle/supersnuvi/tiles/WaterTile.java

@@ -27,9 +27,9 @@ public class WaterTile extends BaseTile
     }
 
     @Override
-    public void onEntityCollide(Entity ent, int x, int y, Face face) 
+    public void onEntityCollide(Entity ent, int x, int y, Face face, Level l) 
     {
-        super.onEntityCollide(ent, x, y, face);
+        super.onEntityCollide(ent, x, y, face, l);
         ent.getMovement().setInWater(true);
         if(ent.getMotionY() > 0.0f)
         {
@@ -38,7 +38,7 @@ public class WaterTile extends BaseTile
     }
 
     @Override
-    public boolean shouldAiUseCollisionBox(int x, int y)
+    public boolean shouldAiUseCollisionBox(int x, int y, Level l)
     {
         return false;
     }

+ 81 - 0
src/me/hammerle/supersnuvi/util/BlockDataStorage.java

@@ -0,0 +1,81 @@
+package me.hammerle.supersnuvi.util;
+
+import java.util.HashSet;
+import java.util.Objects;
+import me.hammerle.supersnuvi.gamelogic.Level;
+
+public class BlockDataStorage
+{
+    private static class Data
+    {
+        private final int x;
+        private final int y;
+        private final Level level;
+        
+        private Data(int x, int y, Level level)
+        {
+            this.x = x;
+            this.y = y;
+            this.level = level;
+        }
+
+        @Override
+        public int hashCode()
+        {
+            int hash = 5;
+            hash = 97 * hash + this.x;
+            hash = 97 * hash + this.y;
+            hash = 97 * hash + Objects.hashCode(this.level);
+            return hash;
+        }
+
+        @Override
+        public boolean equals(Object obj)
+        {
+            if(this == obj)
+            {
+                return true;
+            }
+            if(obj == null)
+            {
+                return false;
+            }
+            if(getClass() != obj.getClass())
+            {
+                return false;
+            }
+            final Data other = (Data) obj;
+            if(this.x != other.x)
+            {
+                return false;
+            }
+            if(this.y != other.y)
+            {
+                return false;
+            }
+            return Objects.equals(this.level, other.level);
+        }
+    }
+    
+    private final HashSet<Data> data = new HashSet<>();
+    
+    public BlockDataStorage()
+    {
+        
+    }
+    
+    public boolean add(int x, int y, Level level)
+    {
+        return data.add(new Data(x, y, level));
+    }
+    
+    public boolean contains(int x, int y, Level level)
+    {
+        return data.contains(new Data(x, y, level));
+    }
+    
+    public void clear(Level level)
+    {
+        data.removeIf(d -> d.level == level);
+    }
+}