Skip to content

Creating Game

piitex edited this page Nov 13, 2024 · 5 revisions

Construction

THIS IS NOT FINISHED!!!

Before You Begin

Please ensure your machine meets the requirements outlined in the README. Next ensure you have the proper Java version installed and you followed the installation instructions.

Please confirm the list.

  • You have Java installed.
  • You have RenJava installed.
  • Your PC supports the framework (windows/linux)
  • You created the example project (Hero Adventure)

Open both RenJava and HeroAdventure in your IDEA. I will be using Intellij Community.

Initializing Game

Before we start customizing and adding to our game we need to install the RSDK. The RSDK automatically installs required assets and creates a testing folder. Please download RSDK and move the .jar file to the base directory of your game. This is typically where the .pom file is.

image

Next from your IDEA run 'mvn clean install'. If you are using intellij follow the steps below. Note, you can hold CTRL to select multiple boxes.

howto

Make sure the project installs without errors or issues. Now we need to launch the RSDK file. To do so we can use the built-in terminal or a command prompt. To make this installation as easy as possible we will do so from a command prompt. This way is not the fastest but it is the easiest.

Create a file called 'launch.bat' inside of the root directory (where the RSDK file is). Copy the following lines and modify the color you wish. Next double click the file to launch it. This will only work if you have the proper java version installed.

Color List:

  • Aqua
  • Blue
  • light_blue
  • Orange
java -jar RSDK-1.3.1-SNAPSHOT.jar --color BLUE

Example output of the file.

C:\Users\Hack\Desktop\HeroAdventure> java -jar .\RSDK-1.3.1-SNAPSHOT.jar --color blue


The project uses the Amazon Corretto Java Distribution. By using this application you herby agree to all terms and conditions of using and distributing this software.


RenJava and all utilities and tools are maintained by piitex. Thank you for using the project.


Checking project environment...
Created game directory. Please place assets into the appropriate folders.
HeroAdventure-1.0.1-SNAPSHOT.jar
Installing Linux JDK...
Linux file exists. TODO: Check to see if the file is completely downloaded.
Installing Windows JDK...
Unzipping Windows JDK...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Finished unzip.
Cleaning up...
Detected directory: jdk21.0.5_11
Creating executable files...
Extracting GUI...
Setting color to blue
Extracting CSS files...
Finished extracting default assets.
Done.

This process may take a few minutes as it installs necessary sdk files. Now you should have a folder called HeroAdventure-1.0-SNAPSHOT. Inside that folder you will see a start.bat and a start_linux.sh. Use these files to test and debug your game.

Customizing Main Menu

To start we will be customizing the main menu. This will demonstrate the basic functions within the framework. Inside of the HeroAdventure class/file we have a few functions that handle the main menu. The first is a splash-screen buildSplashScreen() and the second is the main-screen buildMainMenu(boolean rightClick). To start we will customize the main menu by adding a background image and a simple overlay.

public Container buildMainMenu(boolean rightClick) {
  // To start we need to create a container. A container is a logical box that contains the graphical elements (overlays).
  // The default container is an EmptyContainer
  Container container = new EmptyContainer(1920, 1080); // The two numbers represent the width and height of the container.
  // The width and height are very important. If the container is meant to act as the entire screen you must set the number to your rendered resolution.
  // For HeroAdventure it was set to 1920x1080 which was configured in the @Configuration annotation.
  
  // First let's render the image. We want the image to be rendered in the back so it must be added first.
  // If you add the image last, the image will be rendered on top of other elements which would cover those elements.
  // Reminder: We have this image installed as it was bundled with RSDK. If you did not do the RSDK step this will not work.
  container.addOverlay(new ImageOverlay("gui/main_menu.png"));

  // Now we will add a text in the bottom left of our screen.
  // We haven't quite gotten to fonts yet so the FontLoader class will be explained later. 
  // The other parameter (1500, 975) is the x and y coordinates of the overlay.
  // Below this block of code you will see an example of how the coordinate system works.
  TextOverlay gameText = new TextOverlay(name + ' ' + version, new FontLoader(getConfiguration().getUiFont(), 36), 1500, 975);
  container.addOverlay(gameText);

  // Now we have to return our modified container.
  return container;
}

Coordinates

Coordinates is a key element to understand. The coordinates do not work like your stand plot graph. The top left is the starting point (0, 0). The bottom right is the end point (max-X, max-Y) typically this is (1920,1080). The window bar is not included in the coordinates. Please excuse the terrible drawing.

howto

Compiling and Executing

Now that our main menu is created we can compile and run the project. To compile please run mvn clean install. You can do this within the IDEA if it's supported or by command prompt (you need to have maven installed). Once the target jar is compiled move that jar into our testing directory RSDK created. Make sure to overwrite the file. Now run start.bat for windows and start_linux.sh for Linux.

THE NEXT STEPS ARE UNDER CONSTRUCTION

Clone this wiki locally