<?xml version="1.0" encoding="UTF-8"?>\r
<classpath>\r
<classpathentry kind="src" path="src"/>\r
- <classpathentry kind="src" path="res"/>\r
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
<classpathentry combineaccessrules="false" kind="src" path="/gdx"/>\r
<classpathentry combineaccessrules="false" kind="src" path="/gdx-backend-jogl"/>\r
public static Pixmap level;\r
public static TextureRegion titleScreen;\r
public static TextureRegion shot;\r
+ public static TextureRegion[][] buttons; \r
\r
public static TextureRegion winScreen1;\r
public static TextureRegion winScreen2;\r
player2 = split("res/player.png", 16, 32, true);\r
walls = split("res/walls.png", 10, 10);\r
gremlins = split("res/gremlins.png", 30, 30);\r
-\r
+ buttons = split("res/buttons.png", 32, 32);\r
shot = new TextureRegion(guys[0][0].getTexture(), 3, 27, 2, 2);\r
winScreen1 = load("res/winscreen1.png", 320, 240);\r
winScreen2 = load("res/winscreen2.png", 320, 240);\r
package com.mojang.metagun;\r
\r
-import com.badlogic.gdx.Input.Keys;\r
+import com.badlogic.gdx.Application.ApplicationType;\r
import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.InputAdapter;\r
+import com.badlogic.gdx.Input.Keys;\r
import com.badlogic.gdx.InputProcessor;\r
\r
public class Input implements InputProcessor {\r
}\r
\r
public void tick() {\r
- if(Gdx.input.getAccelerometerY() < -1.2f)\r
- set(Keys.KEYCODE_DPAD_LEFT, true);\r
- else if(Gdx.input.getAccelerometerY() > 1.2f)\r
- set(Keys.KEYCODE_DPAD_RIGHT, true);\r
- else {\r
- set(Keys.KEYCODE_DPAD_LEFT, false);\r
- set(Keys.KEYCODE_DPAD_RIGHT, false);\r
- }\r
+ for (int i = 0; i < buttons.length; i++) {\r
+ oldButtons[i] = buttons[i];\r
+ } \r
\r
- for (int i = 0; i < buttons.length; i++) {\r
- oldButtons[i] = buttons[i];\r
- } \r
+ if(Gdx.app.getType() == ApplicationType.Android) { \r
+ boolean left = false;\r
+ boolean right = false;\r
+ boolean z = false;\r
+ boolean s = false;\r
+ \r
+ for(int i = 0; i < 2; i++) {\r
+ int x = (int)((Gdx.input.getX(i) / (float)Gdx.graphics.getWidth()) * 320);\r
+ if(!Gdx.input.isTouched(i)) continue;\r
+ if(x < 32) {\r
+ set(Keys.KEYCODE_DPAD_LEFT, true);\r
+ left |= true;\r
+ }\r
+ if(x > 32 && x < 90) {\r
+ set(Keys.KEYCODE_DPAD_RIGHT, true);\r
+ right |= true;\r
+ }\r
+ if(x > 320-64 && x < 320-32) {\r
+ set(Keys.KEYCODE_Z, true);\r
+ z |= true; \r
+ }\r
+ if(x > 320-32 && x < 320) {\r
+ set(Keys.KEYCODE_X, true);\r
+ s |= true;\r
+ }\r
+ } \r
+ \r
+ if(left==false) set(Keys.KEYCODE_DPAD_LEFT, false);\r
+ if(right==false) set(Keys.KEYCODE_DPAD_RIGHT, false);\r
+ if(z==false) set(Keys.KEYCODE_Z, false);\r
+ if(s==false) set(Keys.KEYCODE_X, false);\r
+ } \r
}\r
\r
\r
}\r
\r
@Override public boolean touchDown (int x, int y, int pointer, int button) {\r
- if(x < Gdx.graphics.getWidth() / 5) \r
- set(Keys.KEYCODE_Z, true);\r
- if(x > Gdx.graphics.getWidth() - Gdx.graphics.getWidth() / 5)\r
- set(Keys.KEYCODE_Y, true);\r
return false;\r
}\r
\r
- @Override public boolean touchUp (int x, int y, int pointer, int button) { \r
- set(Keys.KEYCODE_Z, false); \r
- set(Keys.KEYCODE_Y, false);\r
+ @Override public boolean touchUp (int x, int y, int pointer, int button) { \r
return false;\r
}\r
\r
import com.badlogic.gdx.graphics.g2d.SpriteBatch;\r
import com.mojang.metagun.screen.GameScreen;\r
import com.mojang.metagun.screen.Screen;\r
+import com.mojang.metagun.screen.TitleScreen;\r
\r
public class Metagun implements ApplicationListener {\r
public static final int GAME_WIDTH = 320;\r
private Input input = new Input();\r
private boolean started = false;\r
private float accum = 0;\r
- BitmapFont font;\r
- SpriteBatch batch;\r
\r
public void create() {\r
Art.load();\r
Sound.load();\r
Gdx.input.setInputProcessor(input);\r
running = true;\r
-// setScreen(new TitleScreen());\r
- setScreen(new GameScreen());\r
-// font = new BitmapFont(); \r
-// batch = new SpriteBatch();\r
+ setScreen(new TitleScreen()); \r
}\r
\r
public void pause() {\r
public void render() {\r
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);\r
accum += Gdx.graphics.getDeltaTime();\r
- while(accum > 1.0f / 60.0f) { \r
- screen.tick(input);\r
+ while(accum > 1.0f / 60.0f) { \r
+ screen.tick(input); \r
input.tick();\r
accum -= 1.0f / 60.0f;\r
}\r
\r
package com.mojang.metagun.screen;\r
\r
+import com.badlogic.gdx.Application.ApplicationType;\r
+import com.badlogic.gdx.Gdx;\r
import com.mojang.metagun.Art;\r
import com.mojang.metagun.Input;\r
import com.mojang.metagun.Metagun;\r
String msg = "PRESS X TO TRY AGAIN";\r
drawString(msg, 160 - msg.length() * 3, 120 - 3);\r
}\r
+ if(Gdx.app.getType() == ApplicationType.Android) {\r
+ draw(Art.buttons[0][0], 0, 240-32);\r
+ draw(Art.buttons[1][0], 32, 240-32);\r
+ draw(Art.buttons[2][0], 320-64, 240-32);\r
+ draw(Art.buttons[3][0], 320-32, 240-32);\r
+ }\r
spriteBatch.end();\r
}\r
\r
}\r
\r
public void tick(Input input) {\r
- if (!input.oldButtons[Input.ESCAPE] && input.buttons[Input.ESCAPE] ||\r
- Gdx.input.isTouched()) {\r
+ if (!input.oldButtons[Input.ESCAPE] && input.buttons[Input.ESCAPE] || Gdx.input.isTouched()) {\r
setScreen(parent);\r
return;\r
}\r
package com.mojang.metagun.screen;\r
\r
+import com.badlogic.gdx.Gdx;\r
import com.mojang.metagun.Art;\r
import com.mojang.metagun.Input;\r
import com.mojang.metagun.Sound;\r
public void tick(Input input) {\r
time++;\r
if (time > 240) {\r
- if (input.buttons[Input.SHOOT] && !input.oldButtons[Input.SHOOT]) {\r
+ if (input.buttons[Input.SHOOT] && !input.oldButtons[Input.SHOOT] || Gdx.input.isTouched()) {\r
Sound.startgame.play();\r
setScreen(new GameScreen());\r
input.releaseAllKeys();\r