This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void render() { | |
Gdx.gl.glClearColor(1, 1, 1, 1); | |
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); | |
renderer.setView(camera); | |
renderer.render(); | |
SpriteBatch batch = renderer.getSpriteBatch(); | |
batch.begin(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void render() { | |
Gdx.gl.glClearColor(1, 1, 1, 1); | |
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); | |
renderer.setView(camera); | |
renderer.render(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final int WHITE = -1; | |
private static final int EMPTY = 0; | |
private static final int BLACK = 1; | |
public void play(int x, int y) { | |
if (board[x][y] == EMPTY) { | |
board[x][y] = currentPlayer; | |
currentPlayer *= -1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean tap(float x, float y, int count, int button) { | |
// where x and y are tap inputs | |
Vector3 touchPoint = new Vector3(x, y, 0); | |
camera.unproject(touchPoint); | |
game.play((int) touchPoint.x, (int) touchPoint.y); | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InputMultiplexer multiplexer = new InputMultiplexer(); | |
multiplexer.addProcessor(new ZoomMoveKeyProcessor(camera)); | |
multiplexer.addProcessor(new GestureDetector(new ZoomPanDetector(camera))); | |
multiplexer.addProcessor(new GestureDetector(new PutStoneDetector(this, camera))); | |
Gdx.input.setInputProcessor(multiplexer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void create() { | |
float w = Gdx.graphics.getWidth(); | |
float h = Gdx.graphics.getHeight(); | |
TiledMap map = new TmxMapLoader().load("data/goban19.tmx"); | |
renderer = new OrthogonalTiledMapRenderer(map, unitScale); | |
camera = new OrthographicCamera(); | |
camera.setToOrtho(true, w * unitScale, h * unitScale); | |
WIDTH = ((TiledMapTileLayer) map.getLayers().get(0)).getWidth(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean delete(Context context) { | |
boolean result = context.getContentResolver().delete( | |
getPath(getClass(), id), null, null) > 0; | |
if (result) { | |
id = -1; | |
} | |
return result; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TypeHandler { | |
public String getSQLType() { | |
return "TEXT"; | |
} | |
public Object getSQLValue(Object object) { | |
return object; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T extends Storable> T getById(Context context, | |
Class<T> clazz, long id) { | |
try { | |
T result = clazz.newInstance(); | |
Cursor content = context.getContentResolver().query( | |
getPath(clazz, id), null, null, null, null); | |
if (content.moveToFirst()) { | |
result.loadCursor(content); | |
} | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void save(Context context) { | |
Map<String, Object> mapRepr = asMap(); | |
Parcel p = Parcel.obtain(); | |
p.writeMap(mapRepr); | |
p.setDataPosition(0); | |
ContentValues values = ContentValues.CREATOR.createFromParcel(p); | |
if (id == -1) { | |
Uri insertUri = context.getContentResolver().insert( | |
getPath(getClass()), values); | |
id = Long.parseLong(insertUri.getLastPathSegment()); |