DEADSOFTWARE

Move items to JSON
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / misc / Assets.java
1 package ru.deadsoftware.cavedroid.misc;
3 import com.badlogic.gdx.Gdx;
4 import com.badlogic.gdx.graphics.Texture;
5 import com.badlogic.gdx.graphics.g2d.BitmapFont;
6 import com.badlogic.gdx.graphics.g2d.GlyphLayout;
7 import com.badlogic.gdx.graphics.g2d.Sprite;
8 import com.badlogic.gdx.graphics.g2d.TextureRegion;
9 import ru.deadsoftware.cavedroid.CaveGame;
11 public class Assets {
13 private static GlyphLayout layout;
15 public static BitmapFont mcFont;
17 public static Texture gameLogo;
19 public static Texture menuBtnTex;
20 public static TextureRegion[] menuBtn = new TextureRegion[3];
22 public static Texture plTex;
23 public static Sprite[][] plSprite = new Sprite[2][4];
25 public static Texture pigTex;
26 public static Sprite[][] pigSprite = new Sprite[2][2];
28 public static Texture shade;
30 public static Texture gui;
31 public static TextureRegion invBar;
32 public static TextureRegion invBarCur;
33 public static TextureRegion guiCur;
35 public static Texture wreckTex;
36 public static TextureRegion[] wreck = new TextureRegion[10];
38 public static Texture creativeTex;
39 public static TextureRegion creativeInv;
40 public static TextureRegion creativeScr;
42 public static Texture touchGui;
43 public static TextureRegion[] touchArrows = new TextureRegion[4];
44 public static TextureRegion touchLMB, touchRMB;
45 public static TextureRegion touchMode;
46 public static TextureRegion touchSpace;
48 private static void loadPlayer() {
49 plTex = new Texture(Gdx.files.internal("mobs/char.png"));
50 //LOOK TO LEFT
51 //head
52 plSprite[0][0] = new Sprite(new TextureRegion(plTex, 0, 0, 12, 12));
53 plSprite[0][0].flip(false, true);
54 //body
55 plSprite[0][1] = new Sprite(new TextureRegion(plTex, 0, 13, 12, 12));
56 plSprite[0][1].flip(false, true);
57 //hand
58 plSprite[0][2] = new Sprite(new TextureRegion(plTex, 25, 5, 20, 20));
59 plSprite[0][2].flip(false, true);
60 //leg
61 plSprite[0][3] = new Sprite(new TextureRegion(plTex, 25, 27, 20, 20));
62 plSprite[0][3].flip(false, true);
63 //LOOK TO RIGHT
64 //head
65 plSprite[1][0] = new Sprite(new TextureRegion(plTex, 13, 0, 12, 12));
66 plSprite[1][0].flip(false, true);
67 //body
68 plSprite[1][1] = new Sprite(new TextureRegion(plTex, 13, 13, 12, 12));
69 plSprite[1][1].flip(false, true);
70 //hand
71 plSprite[1][2] = new Sprite(new TextureRegion(plTex, 37, 5, 20, 20));
72 plSprite[1][2].flip(false, true);
73 //leg
74 plSprite[1][3] = new Sprite(new TextureRegion(plTex, 37, 27, 20, 20));
75 plSprite[1][3].flip(false, true);
76 }
78 private static void loadPig() {
79 pigTex = new Texture(Gdx.files.internal("mobs/pig.png"));
80 pigSprite[0][0] = new Sprite(new TextureRegion(pigTex, 0, 0, 25, 12));
81 pigSprite[0][0].flip(false, true);
82 pigSprite[1][0] = new Sprite(new TextureRegion(pigTex, 0, 12, 25, 12));
83 pigSprite[1][0].flip(false, true);
84 pigSprite[0][1] = new Sprite(new TextureRegion(pigTex, 4, 26, 12, 12));
85 pigSprite[0][1].flip(false, true);
86 pigSprite[1][1] = new Sprite(new TextureRegion(pigTex, 16, 26, 12, 12));
87 pigSprite[1][1].flip(false, true);
88 }
90 public static void load() {
91 mcFont = new BitmapFont(Gdx.files.internal("font.fnt"), true);
92 mcFont.getData().setScale(.375f);
94 layout = new GlyphLayout();
96 gameLogo = new Texture(Gdx.files.internal("gamelogo.png"));
98 menuBtnTex = new Texture(Gdx.files.internal("buttons.png"));
99 for (int i = 0; i < 3; i++) {
100 menuBtn[i] = new TextureRegion(menuBtnTex, 0, 20 * i, 200, 20);
101 menuBtn[i].flip(false, true);
104 loadPlayer();
105 loadPig();
107 shade = new Texture(Gdx.files.internal("shade.png"));
109 gui = new Texture(Gdx.files.internal("gui.png"));
110 guiCur = new TextureRegion(gui, 0, 0, 16, 16);
111 invBar = new TextureRegion(gui, 0, 16, 182, 22);
112 invBarCur = new TextureRegion(gui, 0, 38, 24, 24);
114 creativeTex = new Texture(Gdx.files.internal("allitems.png"));
115 creativeInv = new TextureRegion(creativeTex, 0, 0, 176, 136);
116 creativeInv.flip(false, true);
117 creativeScr = new TextureRegion(creativeTex, 3, 137, 12, 15);
118 creativeScr.flip(false, true);
120 wreckTex = new Texture(Gdx.files.internal("break.png"));
121 for (int i = 0; i < 10; i++) {
122 wreck[i] = new TextureRegion(wreckTex, 16 * i, 0, 16, 16);
125 if (CaveGame.TOUCH) {
126 touchGui = new Texture(Gdx.files.internal("touch_gui.png"));
127 for (int i = 0; i < 4; i++) {
128 touchArrows[i] = new TextureRegion(touchGui, i * 26, 0, 26, 26);
129 touchArrows[i].flip(false, true);
131 touchLMB = new TextureRegion(touchGui, 0, 26, 26, 26);
132 touchLMB.flip(false, true);
133 touchRMB = new TextureRegion(touchGui, 52, 26, 26, 26);
134 touchRMB.flip(false, true);
135 touchMode = new TextureRegion(touchGui, 26, 26, 26, 26);
136 touchMode.flip(false, true);
137 touchSpace = new TextureRegion(touchGui, 0, 52, 104, 26);
138 touchSpace.flip(false, true);
143 public static int getStringWidth(String s) {
144 layout.setText(mcFont, s);
145 return (int) layout.width;
148 public static int getStringHeight(String s) {
149 layout.setText(mcFont, s);
150 return (int) layout.height;