Skip to content

Project Setup

JGugino edited this page Jun 30, 2020 · 3 revisions

Setting up your project

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

Eclipse 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.

project_create

  1. 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 a res 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 select New -> Folder. Once the folder is created drag and drop the download Luci2D_(version).jar into the folder, and when prompted to copy files click ok.

create_res_folder

  • Right-click the root of your newly created projects and select the Properties option. Once the window opens Select Java Build Path on the left side of the window, then click the Libraries tab on the right-side panel in the Properties window. After the Libraries tab is selected press the Add JARs button, then navigate to the Luci2D_(version).jar you added to the res folder and then press OK.

include_jar_file

  • Now to add the res folder as a class folder, within the same Properties window you added the jar file in press the Add Class Folder button then select the res folder inside your project.

include_class_folder


Basic Game Setup

  1. 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.

game_class_create

  1. Once you have created the new class make sure the class extends Game, and implement any required methods (All classes that inherit from the Game class need the start(GameManager _gm, Renderer _r), update(GameManager _gm, double _delta), and render(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){
    
        }
    }
  2. 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 the GameManager. When creating a new instance GameManager there is 2 version of the constructor, version 1 takes in the Window Width, Window Height, and a reference to the Game class. Version 2 takes in the Window Title, Window Width, Window Height, isResizable, and a reference to the Game class.
     public DemoGame(){
          //GameManager(_windowTitle, _windowWidth, _windowHeight, _resizable, _game)
         new GameManager("Demo Game", 800, 600, false, this);
     } 
  3. 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 of GameManager to false.
      public DemoGame(){
          GameManager _gm = new GameManager("Demo Game", 800, 600,false, this);
          _gm.showDebugInformation = false;
      }

Goto Top

Clone this wiki locally