Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing of NPC #4

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Multiplayer with NPC
neohwei committed Nov 11, 2017
commit e9e8976d02214b51a4668bbc7363469e05cfb2a9
18 changes: 18 additions & 0 deletions core/src/main/scala/my/game/pkg/client/Client.scala
Original file line number Diff line number Diff line change
@@ -5,10 +5,28 @@ import akka.actor.{ActorSystem, Props}
import my.game.pkg.Distributedlibgdx2dgame
import my.game.pkg.client.actor.ClientActor
import my.game.pkg.client.dictionary.ClientDictionary._
import my.game.pkg.entity.utils.Direction._

class Client(ipAddress:String, port:String, game:Distributedlibgdx2dgame){
val system = ActorSystem("bludBourneClient")
val clientActor = system.actorOf(Props(new ClientActor(ipAddress, port, game)), "client")

def quit(){
clientActor ! Quit
}

/**
*
* @param uuid
* @param map
* @param x
* @param y
* @param direction
* @param frameTime
*/
def sendStatus(uuid:String, map:String, x:Float, y:Float, direction:Direction, frameTime:Float): Unit ={
clientActor ! Update(uuid, map, x, y, direction, frameTime)
}

clientActor ! Connect
}
28 changes: 24 additions & 4 deletions core/src/main/scala/my/game/pkg/client/actor/ClientActor.scala
Original file line number Diff line number Diff line change
@@ -2,17 +2,22 @@ package my.game.pkg.client.actor

import akka.actor.{Actor, ActorRef}
import akka.util.Timeout

import my.game.pkg.Distributedlibgdx2dgame
import my.game.pkg.client.dictionary.ClientDictionary._
import my.game.pkg.entity.{PlayerEntity, RemotePlayer}
import my.game.pkg.screen.MainGameScreen
import my.game.server.dictionary.ServerDictionary._

import scala.util.control.Breaks._

class ClientActor(val ipAddress:String, val port:String, val game:Distributedlibgdx2dgame) extends Actor{

val remote = context.actorSelection(s"akka.tcp://bludbourne@$ipAddress:$port/user/serverconenction")
val remoteConnection = context.actorSelection(s"akka.tcp://bludbourne@$ipAddress:$port/user/serverconenction")
val remoteGameServer = context.actorSelection(s"aka.tcp://bludbourne@ipAddress:$port/user/gameserver")


def receive = {
case Connect => remote ! Connect
case Connect => remoteConnection ! Connect
case Connected(uuid) =>
game.connectServerScreen.updateConnection(true)
game.gameUUID = Option(uuid)
@@ -21,7 +26,22 @@ class ClientActor(val ipAddress:String, val port:String, val game:Distributedlib
}

def connected:Receive = {
case UpdatePlayerStatus(uuid, x, y, direction, frameTime) =>
case Quit => remoteConnection ! Quit
case Update(uuid, map, x, y, direction, frameTime) => remoteGameServer ! Update(uuid, map, x, y, direction, frameTime)
case UpdatePlayerStatus(uuid, x, y, direction, frameTime) =>
var exist : Boolean = false
breakable{
for(remotePlayer <- MainGameScreen.remotePlayers){
if(remotePlayer.gameUUID.equals(uuid)){
remotePlayer.update(x,y,direction,frameTime)
exist = true
break
}
}
}
if(!exist){
MainGameScreen.remotePlayers += RemotePlayer("Remote", uuid, x, y, direction, frameTime, PlayerEntity.spritePatchRogue)
}
}
}

Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ package my.game.pkg.controller

import com.badlogic.gdx.{Gdx, Input, InputProcessor}
import com.badlogic.gdx.math.Vector3

import my.game.pkg.Distributedlibgdx2dgame
import my.game.pkg.entity.Player
import my.game.pkg.entity.utils.{Direction, State}

@@ -124,7 +124,7 @@ class PlayerController(val player:Player) extends InputProcessor{
* Update status of player controller
* @param delta:Float Delta value of the time frame
*/
def update(delta:Float){
def update(delta:Float, game:Distributedlibgdx2dgame){
if(KeyManager.LEFT){
player.update(delta, Direction.LEFT, State.WALKING)
} else if(KeyManager.RIGHT){
@@ -134,6 +134,9 @@ class PlayerController(val player:Player) extends InputProcessor{
} else if(KeyManager.DOWN){
player.update(delta, Direction.DOWN, State.WALKING)
} else if(KeyManager.QUIT){
game.client match{
case Some(x) => x.quit()
}
Gdx.app.exit()
} else {
player.update(delta, State.IDLE)
2 changes: 1 addition & 1 deletion core/src/main/scala/my/game/pkg/entity/NPC.scala
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import com.badlogic.gdx.math.Vector2
import my.game.pkg.entity.utils.Direction.Direction

//positionX and position Y are for the coordinate of the NPC
class NPC (spritePatch : String, val mapName : String, val positionX : Float, val positionY : Float) extends PlayerEntity(spritePatch){
class NPC (spritePatch : String, val mapName : String, val positionX : Float, val positionY : Float) extends Player("NPC", spritePatch){

init(new Vector2(positionX, positionY))

126 changes: 121 additions & 5 deletions core/src/main/scala/my/game/pkg/entity/Player.scala
Original file line number Diff line number Diff line change
@@ -5,9 +5,9 @@ import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.{Animation, Sprite, TextureRegion}
import com.badlogic.gdx.math.{Rectangle, Vector2}
import com.badlogic.gdx.utils.Array

import java.util.UUID

import my.game.pkg.Distributedlibgdx2dgame
import my.game.pkg.entity.utils.Direction
import my.game.pkg.entity.utils.Direction._
import my.game.pkg.entity.utils.State
@@ -17,15 +17,131 @@ import my.game.pkg.map.MapManager

class Player(val playername : String, spritePatch : String) extends PlayerEntity (spritePatch) {

//for testing purpose, remove after
override def move(){
val velocity = new Vector2(10f, 10f)
var previousDirection = Direction.UP
var state = State.IDLE
val currentPlayerPosition = new Vector2()
val nextPlayerPosition = new Vector2()
val boundingBox = new Rectangle()
val frameSprite = new Sprite(currentFrame.getTexture, 0, 0, PlayerEntity.FRAME_WIDTH, PlayerEntity.FRAME_HEIGHT)
currentFrame = walkDownFrames.get(0)
/**
* Update the player to latest status
* @param delta:Float Delta time value of the frame
* @param direction:Direction Direction of the player
* @param currentState:State State of the player
*/
def update(delta:Float, direction:Direction, currentState:State){
frameTime = (frameTime + delta)%5
setBoundingSize(0f, 0.5f)
previousDirection = currentDirection
currentDirection = direction
state = currentState

velocity.scl(delta)
if(currentState != State.IDLE){
currentDirection match{
case Direction.LEFT =>
nextPlayerPosition.x = currentPlayerPosition.x - velocity.x
nextPlayerPosition.y = currentPlayerPosition.y
currentFrame = walkLeftAnimation.getKeyFrame(frameTime)
case Direction.RIGHT =>
nextPlayerPosition.x = currentPlayerPosition.x + velocity.x
nextPlayerPosition.y = currentPlayerPosition.y
currentFrame = walkRightAnimation.getKeyFrame(frameTime)
case Direction.UP =>
nextPlayerPosition.y = currentPlayerPosition.y + velocity.y
nextPlayerPosition.x = currentPlayerPosition.x
currentFrame = walkUpAnimation.getKeyFrame(frameTime)
case Direction.DOWN =>
nextPlayerPosition.y = currentPlayerPosition.y - velocity.y
nextPlayerPosition.x = currentPlayerPosition.x
currentFrame = walkDownAnimation.getKeyFrame(frameTime)
case _ =>
}

}
else{
currentDirection match{
case Direction.LEFT =>
currentFrame = walkLeftAnimation.getKeyFrame(0)
case Direction.RIGHT =>
currentFrame = walkRightAnimation.getKeyFrame(0)
case Direction.UP =>
currentFrame = walkUpAnimation.getKeyFrame(0)
case Direction.DOWN =>
currentFrame = walkDownAnimation.getKeyFrame(0)
case _ =>
}
}
velocity.scl(1 / delta)
}

/**
* Overloading method for updating the player status
* @param delta:Float Delta time value of the frame
* @param currentState:State State of the player
*/
def update(delta:Float, currentState:State){
update(delta, currentDirection, currentState)
}

/**
* Initialize position of the player
* @param position:Vector2 Position of the player
*/
def init(position:Vector2){
currentPlayerPosition.x = position.x.toInt
currentPlayerPosition.y = position.y.toInt
nextPlayerPosition.x = position.x.toInt
nextPlayerPosition.y = position.y.toInt
}

/**
* Set bounding box size for the player
* @param widthReduce:Float Width reduced in percentage
* @param heightReduce:Float Height reduced in percentage
*/
def setBoundingSize(widthReduce:Float, heightReduce:Float){
val width = PlayerEntity.FRAME_WIDTH * (1.0f - widthReduce)
val height = PlayerEntity.FRAME_HEIGHT * (1.0f - heightReduce)

if(width == 0 || height == 0){
Gdx.app.debug(Player.TAG, s"Width and Height are 0! $width:$height")
}

val minX = nextPlayerPosition.x / MapManager.UNIT_SCALE
val minY = nextPlayerPosition.y / MapManager.UNIT_SCALE

boundingBox.set(minX, minY, width, height)
}

/**
* Dispose of asset when not needed
*/
def dispose(){
AssetsManager.unloadAsset(spritePatch)
}

/**
* Move player
*/
def move(game:Distributedlibgdx2dgame, mapName : String){
currentPlayerPosition.x = nextPlayerPosition.x
currentPlayerPosition.y = nextPlayerPosition.y
frameSprite.setX(currentPlayerPosition.x)
frameSprite.setY(currentPlayerPosition.y)

println(s"Position X : ${currentPlayerPosition.x}, Position Y : ${currentPlayerPosition.y}")
try {
game.client match {
case Some(x) => game.gameUUID.foreach {
uuid => x.sendStatus(uuid, mapName, currentPlayerPosition.x, currentPlayerPosition.y, currentDirection, frameTime)
}
}
}catch{
case e : Exception =>println("Player maybe playing offline")
}
}

}

object Player{
119 changes: 2 additions & 117 deletions core/src/main/scala/my/game/pkg/entity/PlayerEntity.scala
Original file line number Diff line number Diff line change
@@ -11,16 +11,10 @@ import my.game.pkg.entity.utils.{Direction, State}
import my.game.pkg.entity.utils.State.State
import my.game.pkg.map.MapManager

class PlayerEntity (val spritePatch : String) {
abstract class PlayerEntity (val spritePatch : String) {

val velocity = new Vector2(8f, 8f)
var currentDirection = Direction.LEFT
var previousDirection = Direction.UP
var state = State.IDLE
var frameTime:Float = 0f
val nextPlayerPosition = new Vector2()
val currentPlayerPosition = new Vector2()
val boundingBox = new Rectangle()

AssetsManager.loadTextureAsset(spritePatch)
val texture:Option[Texture] = AssetsManager.getTextureAsset(spritePatch)
@@ -46,116 +40,7 @@ class PlayerEntity (val spritePatch : String) {
val walkRightAnimation = new Animation[TextureRegion](0.25f, walkRightFrames, Animation.PlayMode.LOOP)
val walkUpAnimation = new Animation[TextureRegion](0.25f, walkUpFrames, Animation.PlayMode.LOOP)

var currentFrame = walkDownFrames.get(0)
val frameSprite = new Sprite(currentFrame.getTexture(), 0, 0, PlayerEntity.FRAME_WIDTH, PlayerEntity.FRAME_HEIGHT)

/**
* Update the player to latest status
* @param delta:Float Delta time value of the frame
* @param direction:Direction Direction of the player
* @param currentState:State State of the player
*/
def update(delta:Float, direction:Direction, currentState:State){
frameTime = (frameTime + delta)%5
setBoundingSize(0f, 0.5f)
previousDirection = currentDirection
currentDirection = direction
state = currentState

velocity.scl(delta)
if(currentState != State.IDLE){
currentDirection match{
case Direction.LEFT =>
nextPlayerPosition.x = currentPlayerPosition.x - velocity.x
nextPlayerPosition.y = currentPlayerPosition.y
currentFrame = walkLeftAnimation.getKeyFrame(frameTime)
case Direction.RIGHT =>
nextPlayerPosition.x = currentPlayerPosition.x + velocity.x
nextPlayerPosition.y = currentPlayerPosition.y
currentFrame = walkRightAnimation.getKeyFrame(frameTime)
case Direction.UP =>
nextPlayerPosition.y = currentPlayerPosition.y + velocity.y
nextPlayerPosition.x = currentPlayerPosition.x
currentFrame = walkUpAnimation.getKeyFrame(frameTime)
case Direction.DOWN =>
nextPlayerPosition.y = currentPlayerPosition.y - velocity.y
nextPlayerPosition.x = currentPlayerPosition.x
currentFrame = walkDownAnimation.getKeyFrame(frameTime)
case _ =>
}

}
else{
currentDirection match{
case Direction.LEFT =>
currentFrame = walkLeftAnimation.getKeyFrame(0)
case Direction.RIGHT =>
currentFrame = walkRightAnimation.getKeyFrame(0)
case Direction.UP =>
currentFrame = walkUpAnimation.getKeyFrame(0)
case Direction.DOWN =>
currentFrame = walkDownAnimation.getKeyFrame(0)
case _ =>
}
}
velocity.scl(1 / delta)
}

/**
* Overloading method for updating the player status
* @param delta:Float Delta time value of the frame
* @param currentState:State State of the player
*/
def update(delta:Float, currentState:State){
update(delta, currentDirection, currentState)
}

/**
* Initialize position of the player
* @param position:Vector2 Position of the player
*/
def init(position:Vector2){
currentPlayerPosition.x = position.x.toInt
currentPlayerPosition.y = position.y.toInt
nextPlayerPosition.x = position.x.toInt
nextPlayerPosition.y = position.y.toInt
}

/**
* Set bounding box size for the player
* @param widthReduce:Float Width reduced in percentage
* @param heightReduce:Float Height reduced in percentage
*/
def setBoundingSize(widthReduce:Float, heightReduce:Float){
val width = PlayerEntity.FRAME_WIDTH * (1.0f - widthReduce)
val height = PlayerEntity.FRAME_HEIGHT * (1.0f - heightReduce)

if(width == 0 || height == 0){
Gdx.app.debug(PlayerEntity.TAG, s"Width and Height are 0! $width:$height")
}

val minX = nextPlayerPosition.x / MapManager.UNIT_SCALE
val minY = nextPlayerPosition.y / MapManager.UNIT_SCALE

boundingBox.set(minX, minY, width, height)
}

/**
* Dispose of asset when not needed
*/
def dispose(){
AssetsManager.unloadAsset(spritePatch)
}

/**
* Move player
*/
def move(){
currentPlayerPosition.x = nextPlayerPosition.x
currentPlayerPosition.y = nextPlayerPosition.y
frameSprite.setX(currentPlayerPosition.x)
frameSprite.setY(currentPlayerPosition.y)
}
var currentFrame:TextureRegion = walkDownFrames.get(0)
}

object PlayerEntity{
30 changes: 28 additions & 2 deletions core/src/main/scala/my/game/pkg/entity/RemotePlayer.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,40 @@
package my.game.pkg.entity

class RemotePlayer(val playername : String, val gameUUID : String, spritePatch : String) extends PlayerEntity(spritePatch){
import com.badlogic.gdx.graphics.g2d.Sprite
import my.game.pkg.entity.utils.Direction
import my.game.pkg.entity.utils.Direction._

class RemotePlayer(val playername : String, val gameUUID : String, x : Float, y : Float, direction : Direction, frame:Float, spritePatch : String) extends PlayerEntity(spritePatch){

val frameSprite = new Sprite(currentFrame.getTexture(), x.asInstanceOf[Int], y.asInstanceOf[Int], PlayerEntity.FRAME_WIDTH, PlayerEntity.FRAME_HEIGHT)

def update(x:Float, y:Float, direction:Direction, frame:Float): Unit ={
frameSprite.setX(x)
frameSprite.setY(y)
frameTime = frame
currentDirection = direction

currentDirection match{
case Direction.LEFT =>
currentFrame = walkLeftAnimation.getKeyFrame(frameTime)
case Direction.RIGHT =>
currentFrame = walkRightAnimation.getKeyFrame(frameTime)
case Direction.UP =>
currentFrame = walkUpAnimation.getKeyFrame(frameTime)
case Direction.DOWN =>
currentFrame = walkDownAnimation.getKeyFrame(frameTime)
case _=>
}
}

}

object RemotePlayer{
/**
* Apply method for creating RemotePlayer
* @return RemotePlayer New instance of RemotePlayer
*/
def apply(playername : String, gameUUID : String, spritePatch : String):RemotePlayer = new RemotePlayer(playername, gameUUID, spritePatch)
def apply(playername : String, gameUUID:String, x:Float, y:Float, direction:Direction, frame:Float, spritePatch : String):RemotePlayer = new RemotePlayer(playername, gameUUID,x,y,direction,frame, spritePatch)

private val TAG:String = RemotePlayer.getClass().getSimpleName()
}
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package my.game.pkg.entity.utils

import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.math.Vector2
import my.game.pkg.Distributedlibgdx2dgame
import my.game.pkg.entity.{NPC, PlayerEntity}
import my.game.pkg.map.MapManager

@@ -42,15 +43,15 @@ class CastleOfDoomNPCs extends MapNPCs {
}
}

def moveNPCs(): Unit ={
def moveNPCs(game : Distributedlibgdx2dgame, mapName:String): Unit ={
if(firstMove) {
firstMove = false
CastleNPC1.move()
CastleNPC2.move()
CastleNPC3.move()
CastleNPC4.move()
CastleNPC5.move()
CastleNPC6.move()
CastleNPC1.move(game, mapName)
CastleNPC2.move(game, mapName)
CastleNPC3.move(game, mapName)
CastleNPC4.move(game, mapName)
CastleNPC5.move(game, mapName)
CastleNPC6.move(game, mapName)
}
}

3 changes: 2 additions & 1 deletion core/src/main/scala/my/game/pkg/entity/utils/MapNPCs.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package my.game.pkg.entity.utils

import com.badlogic.gdx.graphics.g2d.Batch
import my.game.pkg.Distributedlibgdx2dgame
import my.game.pkg.map.MapManager

//base class for different map NPCs class
abstract class MapNPCs {
def initNPCs()
def updateMovingNPCs(delta : Float)
def moveNPCs()
def moveNPCs(game : Distributedlibgdx2dgame, mapName : String)
def drawNPCs(batch : Batch)
def disposeNPCs()
}
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package my.game.pkg.entity.utils

import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.math.Vector2
import my.game.pkg.Distributedlibgdx2dgame
import my.game.pkg.entity.{MovingNPC, PlayerEntity}
import my.game.pkg.map.MapManager

@@ -29,9 +30,9 @@ class TopWorldNPCs extends MapNPCs {
}
}

def moveNPCs(): Unit ={
TopWorldMovingNPC1.move()
TopWorldMovingNPC2.move()
def moveNPCs(game : Distributedlibgdx2dgame, mapName:String): Unit ={
TopWorldMovingNPC1.move(game, mapName)
TopWorldMovingNPC2.move(game, mapName)
if(firstMove) {
firstMove = false
}
11 changes: 6 additions & 5 deletions core/src/main/scala/my/game/pkg/entity/utils/TownNPCs.scala
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package my.game.pkg.entity.utils

import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.math.Vector2
import my.game.pkg.Distributedlibgdx2dgame
import my.game.pkg.entity.{MovingNPC, NPC, PlayerEntity}
import my.game.pkg.map.MapManager

@@ -35,13 +36,13 @@ class TownNPCs extends MapNPCs {
}
}

def moveNPCs(): Unit ={
TownMovingNPC1.move()
TownMovingNPC2.move()
def moveNPCs(game : Distributedlibgdx2dgame, mapName : String): Unit ={
TownMovingNPC1.move(game, mapName)
TownMovingNPC2.move(game, mapName)
if(firstMove) {
firstMove = false
TownNPC1.move()
TownNPC2.move()
TownNPC1.move(game, mapName)
TownNPC2.move(game, mapName)
}
}

20 changes: 11 additions & 9 deletions core/src/main/scala/my/game/pkg/screen/MainGameScreen.scala
Original file line number Diff line number Diff line change
@@ -12,9 +12,10 @@ import my.game.pkg.Distributedlibgdx2dgame
import my.game.pkg.map.MapManager
import my.game.pkg.controller.PlayerController
import my.game.pkg.entity.utils.{MapNPCs, TownNPCs}
import my.game.pkg.entity.{MovingNPC, NPC, Player, PlayerEntity}
import my.game.pkg.entity._

import scala.collection.JavaConverters._
import scala.collection.mutable.ListBuffer

class MainGameScreen(val game:Distributedlibgdx2dgame) extends Screen{

@@ -38,9 +39,7 @@ class MainGameScreen(val game:Distributedlibgdx2dgame) extends Screen{
Gdx.app.debug(MainGameScreen.TAG, s"UnitScale Value is: ${mapRenderer.getUnitScale()}")

MainGameScreen.player.init(MainGameScreen.mapMgr.getPlayerStartUnitScaled)

//init NPCs
//MainGameScreen.NPCs.initNPCs()
MainGameScreen.player.move(game, MainGameScreen.mapMgr.currentMapName)

Gdx.input.setInputProcessor(controller)
}
@@ -61,7 +60,7 @@ class MainGameScreen(val game:Distributedlibgdx2dgame) extends Screen{
camera.position.set(currentPlayerSprite.getX(), currentPlayerSprite.getY(), 0f)
camera.update

controller.update(delta)
controller.update(delta, game)

//update moving NPCs
MainGameScreen.NPCs.updateMovingNPCs(delta)
@@ -71,13 +70,13 @@ class MainGameScreen(val game:Distributedlibgdx2dgame) extends Screen{
updatePortalLayerActivation(MainGameScreen.player.boundingBox)

if(!isCollisionWithMapLayer(MainGameScreen.player.boundingBox)){
MainGameScreen.player.move()
MainGameScreen.player.move(game, MainGameScreen.mapMgr.currentMapName)
}

//move NPCs
MainGameScreen.NPCs.moveNPCs()
MainGameScreen.NPCs.moveNPCs(game, MainGameScreen.mapMgr.currentMapName)

controller.update(delta)
controller.update(delta, game)

//update moving NPCs
MainGameScreen.NPCs.updateMovingNPCs(delta)
@@ -86,7 +85,9 @@ class MainGameScreen(val game:Distributedlibgdx2dgame) extends Screen{
mapRenderer.render()
mapRenderer.getBatch().begin()
mapRenderer.getBatch().draw(currentPlayerFrame, currentPlayerSprite.getX, currentPlayerSprite.getY, 1, 1)

for(remotePlayer <- MainGameScreen.remotePlayers){
mapRenderer.getBatch.draw(remotePlayer.currentFrame, remotePlayer.frameSprite.getX, remotePlayer.frameSprite.getY)
}
//draw NPCs
MainGameScreen.NPCs.drawNPCs(mapRenderer.getBatch)

@@ -204,6 +205,7 @@ object MainGameScreen {

var mapMgr:MapManager = MapManager()
val player = Player("Tony", PlayerEntity.spritePatchWarrior)
val remotePlayers = new ListBuffer[RemotePlayer]()

//set first NPCs to TOWN NPCs
var NPCs = MapNPCs(MapManager.TOWN)
2 changes: 1 addition & 1 deletion desktop/src/main/scala/my/game/pkg/Main.scala
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ object Main extends App {
config.height = Settings.height
config.width = Settings.width
config.foregroundFPS = 30
config.backgroundFPS = -1
config.backgroundFPS = 30
val app:Application = new LwjglApplication(new Distributedlibgdx2dgame, config)

Gdx.app = app