Wednesday, August 10, 2011

Basic Menu System Using Slick2D

Hello everyone, just wanted to write a quick post to let you all know that I'm still working hard on Prospectus and I haven't given up on it yet. I've been having a bit of trouble finishing the port of the current version of the game over to Java, so I decided to set it aside for a few days and focus on something else that will keep me encouraged about Prospectus.

With this in mind, I've quickly put together a very simple main menu system which makes excellent use of the Slick2D java library. It is so well put together that I was able to get a basic menu system up and running in a matter of 5 minutes!

The general idea is that your game extends a class called StateBasedGame, thus allowing you to be able to make use of different states easily and effectively. Once you have created this basic game structure, the idea is that you create different classes that extend BasicGameState to represent your different states (MainMenu, Gameplay, PauseScreen, etc.).

The awesome thing about extending BasicGameState is that you are forced to implement three abstract methods. These methods are very similar to methods found in almost every XNA game created today (init, render, update). This allows us access to a familiar game loop that we, as XNA programmers, are comfortable with. This also allows us to use a global input manager that is maintained by our generic gameContainer (created by the StateBasedGame class). From here we can display our menu image, and check for user input, telling us either to enter the game, exit the game, or do whatever we tell it to do.

This is just a quick and easy example of how Slick2D is helping us develop and grow Prospectus into a great game. Here is a short video of the menu test in action.



Thanks for reading and check back for more updates!

2 comments:

  1. Hi Jeff, many thanks for your post. I'm trying to create a simple menu using Slick2D but grope in the dark. I'd like to have a classic menu navigable with keys: up and down arrows to move through items, left and right arrows to change values of selected menu item, simple effects like un/highlight of selected menu item. Do you have any code example? Thank you!

    ReplyDelete
  2. Would it be possible for you to make Prospectus open source? You have many techniques that I can't get my head around, thanks.

    ReplyDelete