Back to project page game-api-android.
The source code is released under:
MIT License
If you think the Android project game-api-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package testGames; // w ww.j av a 2 s . c om import android.gameengine.icadroids.engine.GameEngine; import android.gameengine.icadroids.engine.GameFPSCounter; import android.gameengine.icadroids.engine.GameThread; import android.gameengine.icadroids.engine.GameView; import android.gameengine.icadroids.engine.Viewport; import android.gameengine.icadroids.input.OnScreenButtons; import android.gameengine.icadroids.input.TouchInput; import android.gameengine.icadroids.objects.MoveableGameObject; import android.gameengine.icadroids.tiles.GameTiles; import android.graphics.Color; /** * Deze test test de functionaliteiten van de viewport, de gametiles, de * GameEngine, onscreenButtons en de Sprite. * * @author Edward van Raak */ public class AndroidCraft_demo extends GameEngine { MoveableGameObject player; public AndroidCraft_demo() { super(); player = new Player(); addGameObject(player, 150, 150); setPlayer(player); player.setSprite("blokframe"); Viewport.useViewport = true; GameFPSCounter.USE_FPS_COUNTER = true; //setBackground("tonk"); GameThread.MAX_FPS = 5000; player.startAnimate(); } @Override public void update() { super.update(); /* * if (TouchInput.onPress) { player.setSpeed(3); * player.moveTowardsAPoint(TouchInput.xPos, TouchInput.yPos); } */ } @Override public void initialize() { setBackground("bg"); OnScreenButtons.use = false; TouchInput.use = true; OnScreenButtons.feedback = true; // OnScreenButtons.opacity = 195; GameView.BACKGROUND_COLOR = Color.BLACK; String[] tileResources = { "tile1", "tile4", "tile5", "tile6" }; int[][] Map = { { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, 3, 3, -1, -1, -1, -1, 3, 3, -1, -1, -1, -1, 3, 3, 3, 3, 3, -1, -1, -1, 3, -1, 3, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, 3, -1, 3, -1, -1, -1, 3, -1, 3, -1, -1, -1, 3, -1, -1, -1, 3, -1, -1, 3, -1, -1, -1, 3, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, 3, -1, -1, 3, -1, -1, 3, -1, -1, 3, -1, -1, 3, -1, -1, -1, 3, -1, -1, 3, -1, -1, -1, 3, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, 3, -1, -1, 3, -1, -1, 3, -1, -1, 3, -1, -1, 3, -1, -1, -1, 3, -1, -1, 3, 3, 3, 3, 3, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, -1, -1, -1, 3, -1, -1, 3, -1, -1, 3, -1, -1, 3, -1, -1, 3, -1, -1, -1, 3, -1, -1, 3, -1, -1, -1, 3, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, -1, -1, -1, 3, -1, 3, -1, -1, -1, 3, -1, 3, -1, -1, -1, 3, -1, -1, -1, 3, -1, -1, 3, -1, -1, -1, 3, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, -1, -1, -1, 3, 3, -1, -1, -1, -1, 3, 3, -1, -1, -1, -1, 3, 3, 3, 3, 3, -1, -1, 3, -1, -1, -1, 3, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, }; GameTiles gt = new GameTiles(tileResources, Map, 64); setTileMap(gt); } }