DEADSOFTWARE

Make all Assets final
authorfred-boy <fredboy@protonmail.com>
Sat, 28 Sep 2019 17:42:30 +0000 (00:42 +0700)
committerfred-boy <fredboy@protonmail.com>
Sun, 29 Sep 2019 04:39:18 +0000 (11:39 +0700)
core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java
core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java
core/src/ru/deadsoftware/cavedroid/misc/Assets.java

index fe4e46af1b855628fcf96836fe01c4d2f998c8bc..7b23d4d619b785177c7bbbe2c25453aaadd7d022 100644 (file)
@@ -2,7 +2,6 @@ package ru.deadsoftware.cavedroid.game.mobs;
 
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavedroid.game.GameItems;
 import ru.deadsoftware.cavedroid.misc.Assets;
 
 /**
@@ -31,7 +30,7 @@ public class FallingGravel extends Mob {
 
     @Override
     public void draw(SpriteBatch spriteBatch, float x, float y) {
-        spriteBatch.draw(Assets.fallingGravelSprite, x, y);
+        spriteBatch.draw(Assets.gravelSprite, x, y);
     }
 
     @Override
index 315fcfc6a92fa3e2cf8f53122d6c518c50ad1358..ac20ffb9bd82574ffbc4692b661c550f05fa81f8 100644 (file)
@@ -2,7 +2,6 @@ package ru.deadsoftware.cavedroid.game.mobs;
 
 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavedroid.game.GameItems;
 import ru.deadsoftware.cavedroid.misc.Assets;
 
 /**
@@ -31,7 +30,7 @@ public class FallingSand extends Mob {
 
     @Override
     public void draw(SpriteBatch spriteBatch, float x, float y) {
-        spriteBatch.draw(Assets.fallingSandSprite, x, y);
+        spriteBatch.draw(Assets.sandSprite, x, y);
     }
 
     @Override
index d86d3f8a17942e2a1d0301e0c7f2ec8399aee166..944dec0cac70dd82b77d5c9a6d2f782b9e64f81b 100644 (file)
@@ -18,15 +18,14 @@ public class Assets {
     public static final JsonReader jsonReader = new JsonReader();
 
     private static final GlyphLayout glyphLayout = new GlyphLayout();
-
-    static BitmapFont minecraftFont;
+    static final BitmapFont minecraftFont = new BitmapFont(Gdx.files.internal("font.fnt"), true);;
 
     public static final Sprite[][] playerSprite = new Sprite[2][4];
     public static final Sprite[][] pigSprite = new Sprite[2][2];
-    public static Sprite fallingSandSprite;
-    public static Sprite fallingGravelSprite;
     public static final HashMap<String, TextureRegion> textureRegions = new HashMap<>();
     public static final ArrayMap<String, Rectangle> guiMap = new ArrayMap<>();
+    public static final Sprite sandSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/sand.png"))));
+    public static final Sprite gravelSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/gravel.png"))));
 
     private static TextureRegion flippedRegion(Texture texture, int x, int y, int width, int height) {
         return new TextureRegion(texture, x, y + height, width, -height);
@@ -74,11 +73,6 @@ public class Assets {
         pigSprite[1][1] = flippedSprite(new TextureRegion(pigTex, 16, 26, 12, 12));
     }
 
-    private static void loadFallingBlocks() {
-        fallingSandSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/sand.png"))));
-        fallingGravelSprite = flippedSprite(new Texture((Gdx.files.internal("textures/blocks/gravel.png"))));
-    }
-
     /**
      * Loads texture names and sizes from <b>json/texture_regions.json</b>, cuts them to TextureRegions
      * and puts to {@link #textureRegions} HashMap
@@ -102,11 +96,9 @@ public class Assets {
     }
 
     public static void load() {
-        minecraftFont = new BitmapFont(Gdx.files.internal("font.fnt"), true);
         minecraftFont.getData().setScale(.375f);
         loadPlayer();
         loadPig();
-        loadFallingBlocks();
         loadJSON();
     }