I have been playing around with the Slick2D package this week and have got the very basic layout for the games code setup now. This will allow me to keep the code nicely structured and cleaner, it will also allow the game to run once the code has been written and compiled. The code that I have written this week after reading the documentation and looking at some basic examples of game code is :
import org.newdawn.slick.*;
public class SlickTest extends BasicGame {
public SlickTest() {
super("Jetson's Journey || EPQ Game");
}
public void render(GameContainer gc, Graphics g) throws SlickException {
}
public void init(GameContainer gc) throws SlickException {
}
public void update(GameContainer gc, int arg1) throws SlickException {
}
public static void main(String[] args) throws SlickException {
AppGameContainer app = new AppGameContainer(new Game(), 1280, 960, false);
app.start();
}
The code above, denoted by the bold and italics, is the basic structure of a Slick2D game, the render method will be used to render assets onto the screen once I have imported them into the project, the init method will initialise everything needed within the game once the game starts this includes all variables, art assets and sound assets, the update method will be the section of code that will update the game logic making everything within the game like movement, collision and collecting coins possible. The last section of code, the main method is what initialises the whole game creating the game window and starting the game code running.
No comments:
Post a Comment