-
Notifications
You must be signed in to change notification settings - Fork 0
Project Setup
JGugino edited this page Jun 30, 2020
·
3 revisions
To begin working with the Luci2D framework first you can either compile the jar file yourself by cloning the 'master' branch of the repository. Alternatively, you can download a pre-compiled jar file from here. The pre-compiled jar will always be compiled from the most stable version of Luci2D, so you can rely on this to be stable for production projects.
Eclipse Setup
Basic Game Setup
To begin start by opening the Eclipse IDE, once started click 'File, New -> Java Project' and follow the prompts to set up a basic Java Project.
- Once you have created a new project you to want add the
Luci2D_(version).jar
to your projects referenced libraries, also at this point, it is useful to add ares
class folder to your build path as well for future use with referencing images/audio. - To create the resource folder that Luci2D relies on to load images/audio files, first right-click the root of the newly created project the selectNew -> Folder
. Once the folder is created drag and drop the downloadLuci2D_(version).jar
into the folder, and when prompted to copy files click ok.
- Right-click the root of your newly created projects and select the
Properties
option. Once the window opens SelectJava Build Path
on the left side of the window, then click theLibraries
tab on the right-side panel in theProperties
window. After theLibraries
tab is selected press theAdd JARs
button, then navigate to theLuci2D_(version).jar
you added to the res folder and then press OK.
- Now to add the
res
folder as a class folder, within the sameProperties
window you added the jar file in press theAdd Class Folder
button then select theres
folder inside your project.
- To get a basic window up and running with Luci2D is quite simple, to begin by creating a new java file which includes a
main
method. The package structure does not affect any functionally so you can organize your project any way you see fit.
- Once you have created the new class make sure the class extends
Game
, and implement any required methods (All classes that inherit from theGame
class need thestart(GameManager _gm, Renderer _r)
,update(GameManager _gm, double _delta)
, andrender(GameManager _gm, Renderer _r)
methods.).package com.gugino.demo; import com.gugino.engine.Game; import com.gugino.engine.GameManager; import com.gugino.engine.loops.Renderer; public class DemoGame extends Game{ public DemoGame(){ } public static void main(String[] args) { } public void start(GameManager _gm, Renderer _r){ } public void update(GameManager _gm, double _delta){ } public void render(GameManager _gm, Renderer _r){ } }
- After you have your class extending
Game
and you have all the required methods implemented, inside the constructor for your class put the following code to initialize theGameManager
. When creating a new instanceGameManager
there is 2 version of the constructor, version 1 takes in theWindow Width
,Window Height
, and a reference to theGame
class. Version 2 takes in theWindow Title
,Window Width
,Window Height
,isResizable
, and a reference to theGame
class.public DemoGame(){ //GameManager(_windowTitle, _windowWidth, _windowHeight, _resizable, _game) new GameManager("Demo Game", 800, 600, false, this); }
- After you have the
GameManager
created all that's left now is to create an instance of the created class inside the main method.public DemoGame(){ //GameManager(_windowTitle, _windowWidth, _windowHeight, _resizable, _game) new GameManager("Demo Game", 800, 600, false, this); } public static void main(String[] args){ new DemoGame(); }
-
NOTE: To hide the debug information that shows by default, simply change the
showDebugInformation
boolean inside the created instance ofGameManager
tofalse
.public DemoGame(){ GameManager _gm = new GameManager("Demo Game", 800, 600,false, this); _gm.showDebugInformation = false; }