Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package spilprojekt4.core; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.openide.util.Lookup; import spilprojekt4.common.Entity; import spilprojekt4.common.EntityType; import spilprojekt4.common.GameData; import spilprojekt4.common.World; import spilprojekt4.common.services.IServiceInitializer; import spilprojekt4.common.services.IServiceProcessor; /** * * @author Magnus */ public class Game implements ApplicationListener { private World world; private GameData gameData; private OrthographicCamera cam; public Game() { } @Override public void create() { world = new World(); gameData = new GameData(); gameData.setDisplayWidth(Gdx.graphics.getWidth()); gameData.setDisplayHeight(Gdx.graphics.getHeight()); gameData.setTileSize(16); gameData.setMapWidth(gameData.getDisplayWidth() / gameData.getTileSize() * 2); gameData.setMapHeight(gameData.getDisplayHeight() / gameData.getTileSize()); cam = new OrthographicCamera(gameData.getDisplayWidth(), gameData.getDisplayHeight()); cam.translate(gameData.getDisplayWidth() / 2, gameData.getDisplayHeight() / 2); cam.update(); for (IServiceInitializer i : Lookup.getDefault().lookupAll(IServiceInitializer.class)) { i.start(gameData, world); } Gdx.input.setInputProcessor(new InputController(gameData)); } @Override public void render() { update(); } private void update() { gameData.getKeys().update(); gameData.setDelta(Gdx.graphics.getDeltaTime()); gameData.setMouseX(Gdx.input.getX()); gameData.setMouseY(gameData.getDisplayHeight() - Gdx.input.getY()); for (IServiceProcessor e : Lookup.getDefault().lookupAll(IServiceProcessor.class)) { e.process(gameData, world); } } @Override public void resize(int i, int i1) { } @Override public void pause() { } @Override public void resume() { } @Override public void dispose() { } }