If you want to create a Java project using the SaxionApp Gameloop features you need to do some setup first.
Before you setup your project, make sure you have a little understanding of the GameLoop concept that is introduced in the SaxionApp. Some of you might recognize it from IT’s in the game. If not, please watch the following videos:
We are going to start a new project from scratch (so, no template) and import the SaxionApp library.
Create a new project named ChillyGame. Use at least JDK version 17
N.b. In this example I add it to my desktop. You can do better! Organize your projects for this course! This project runs for multiple weeks so maybe add it to the root of you OOP folder
To test if everything is ok, just start with a nice hello world prompt.
N.b. A main method is the first things that Java runs when you start your program, in there is the start of your program
A JAR file is a library. A library is set of classes and methods that can be used to extend the functionality of Java.
Download version V1.0.0b of the SaxionApp JAR file here.
Add a folder in your project named lib. We’ll use this to add libraries to the project.
Drag the JAR file into the folder so you end up with this
To let Java know that you use a library you must configure your project.
Now you have added a lot of classes and functionality that we created to your project. Let’s use it!
implements GameLoop
and import the GameLoop class from the SaxionApp.Start using the SaxionApp Gameloop by updating the code in your main method.
init()
will be called once at the start of your project.loop()
will be called at the interval you specified in your main method. The last parameter of the method (in our case 40) is the number of milliseconds between every call to this method.keyboardEvent(KeyboardEvent keyboardEvent)
will be called everytime you press a key on your keyboard.mouseEvent(MouseEvent mouseEvent)
will be called everytime you press a mousebutton inside your game window.