hole in one, demo android/dekstop scala game using libgdx

I’ve produced this very simple game

source code available here https://github.com/bernardjason/holeinone

I’ve pulled together some code I had to show how to put together something using libgdx and scala that can run on either desktop or android platform. I’ve not tried it with a Mac. This wont work with HTML flavour libgdx as it’s scala.

The game uses the arrow keys, mouse or screen press to move the gun. Press and hold the spacebar, mouse button or screen then release to fire a missile at the bouncing ball.

The intention of this code is something to pick the bones out of or use as a start for something else.

Things of note
file local.properties contains the location of the android sdk. So this needs to be changed to where you’ve installed it.

core/build.gradle has been changed to build scala source

class FlatTerrain extends class BaseTerrain. This class supports an uneven terrain as well as the simple flat terrain shown in the game.

class bernardcjason.gdx.basic.shape.Cuboid shows mapping parts of a texture to a cube. This is a change to the usual mapping of a texture shape which is
base

to a linear

terrain

For collision detection I’ve not used Bullet physics but rather sphere collision bernardcjason.gdx.basic.shape.CollideSphere.

blogdog, add foreign key constraint

I updated blogdog so that it shows sqlite within play framework using a foreign key. The trick is to get slick when it initialises to add the correct PRAGMA for sqlite. This is the value in application.conf

slick.dbs.default.db.connectionInitSql=”PRAGMA foreign_keys = ON”

then ensure db is created correctly (from evolutions 1.sql)

create table “BLOGS” (ID INTEGER PRIMARY KEY,USERS_ID INTEGER NOT NULL, USER VARCHAR NOT NULL,”WHEN” TIMESTAMP NOT NULL, WHAT VARCHAR NOT NULL , FOREIGN KEY(USERS_ID) REFERENCES USERS(ID));

note that foreign key cannot be a string value

full source is here https://github.com/bernardjason/blogdog