From 107d9b29535be2cad37c8c5a48769c68689e6b33 Mon Sep 17 00:00:00 2001 From: fred-boy Date: Sun, 29 Sep 2019 00:42:30 +0700 Subject: [PATCH] Make all Assets final --- .../cavedroid/game/mobs/FallingGravel.java | 3 +-- .../cavedroid/game/mobs/FallingSand.java | 3 +-- .../src/ru/deadsoftware/cavedroid/misc/Assets.java | 14 +++----------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java index fe4e46a..7b23d4d 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingGravel.java @@ -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 diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java index 315fcfc..ac20ffb 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java @@ -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 diff --git a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java index d86d3f8..944dec0 100644 --- a/core/src/ru/deadsoftware/cavedroid/misc/Assets.java +++ b/core/src/ru/deadsoftware/cavedroid/misc/Assets.java @@ -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 textureRegions = new HashMap<>(); public static final ArrayMap 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 json/texture_regions.json, 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(); } -- 2.29.2