From 54e7238f3ad56f7891ed0521554c8ac9c12446ce Mon Sep 17 00:00:00 2001 From: Allexit Date: Wed, 8 Apr 2015 19:19:14 +0300 Subject: [PATCH] A static image of the player is now drawn --- core/assets/sprites/staticplayer.png | Bin 0 -> 742 bytes .../saltosion/gladiator/GladiatorBrawler.java | 24 +++++-- .../gladiator/util/GlobalStrings.java | 9 +++ .../gladiator/util/SpriteLoader.java | 61 ++++++++++++++++++ .../gladiator/desktop/DesktopLauncher.java | 4 ++ 5 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 core/assets/sprites/staticplayer.png create mode 100644 core/src/com/saltosion/gladiator/util/GlobalStrings.java create mode 100644 core/src/com/saltosion/gladiator/util/SpriteLoader.java diff --git a/core/assets/sprites/staticplayer.png b/core/assets/sprites/staticplayer.png new file mode 100644 index 0000000000000000000000000000000000000000..6e60cea04a00f1f3130208f567d505ae5b660ae1 GIT binary patch literal 742 zcmVWFU8GbZ8()Nlj2>E@cM*00K%$L_t(|+U=XaOT$1E z$G<5-bZMm`9XfQVe}PpB{z9ZKf_85=U0pf}UBpFj>f&0r{sDDxv2;@?H4gs3K@bWS zsi2^XqNR0dViMEV(&k>8ySL;r1oHjdd+**|UZiHT*#yVt0p}(F2mk_r03ZPHY%=u= zY{cfZ@p0jdFAva*x4L&VfOcY8Ll8+&03fzVq>M@O6aWYTT;ASWx;^W1m<+(<)3XSHcFQ4`04T(hZHKq#ya0g7MG*p;t;J+M0I0L? z6bMWKEKPYGR|hahex+Oe#+6ypGMG7lh4pW3d~-d`R~?W}jcMck%!i@kQ(B(jS^#G8 zRy#l$QFj7pC!Ts6%mhF;@p=e#l-vd2zv5ky1oOEd^10y9i60n%c(SU2=vO@JYH(m7 z5KmT7x_H&@qci@Y*caHE1odIj%}xq+5(u^cP-lO+$LA;@cm^%pEdH$rFQ9-hPylK& zd??m&RQwgvF9bVHva3-tvlRdUY_1q*(AR=wJ{veZe textures = new HashMap(); + + static { + loadTexture(GlobalStrings.STATICPLAYER, "sprites/staticplayer.png"); + } + + /** + * Returns a sprite, which is a piece from texture. + * @param texKey + * @param x + * @param y + * @param width + * @param height + * @return + */ + public static Sprite loadSprite(String texKey, int x, int y, int width, int height) { + TextureRegion tr = new TextureRegion(textures.get(texKey), x, y, width, height); + return new Sprite(tr); + } + + /** + * Returns a sprite, which is originally a texture. + * @param texKey + * @return + */ + public static Sprite loadSprite(String texKey) { + return new Sprite(textures.get(texKey)); + } + + /** + * Load texture from path. + * @param filePath + */ + public static Texture loadTexture(String key, String filePath) { + Texture t = new Texture(Gdx.files.internal(filePath)); + textures.put(key, t); + return t; + } + + /** + * Disposes all the textures loaded so far. + */ + public static void dispose () { + for (Texture tex : textures.values()) { + tex.dispose(); + } + } + +} diff --git a/desktop/src/com/saltosion/gladiator/desktop/DesktopLauncher.java b/desktop/src/com/saltosion/gladiator/desktop/DesktopLauncher.java index be850b0..fec2a25 100644 --- a/desktop/src/com/saltosion/gladiator/desktop/DesktopLauncher.java +++ b/desktop/src/com/saltosion/gladiator/desktop/DesktopLauncher.java @@ -3,10 +3,14 @@ package com.saltosion.gladiator.desktop; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.saltosion.gladiator.GladiatorBrawler; +import com.saltosion.gladiator.util.GlobalStrings; public class DesktopLauncher { public static void main (String[] arg) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); + config.title = GlobalStrings.GAME_NAME; + config.width = 720; + config.height = 480; new LwjglApplication(new GladiatorBrawler(), config); } }