Thursday, December 22, 2011

First Slick test and menu

I have successfully tested Slick and found it suitable for a simple game.

I have created a simple menu, it has a 1024X768 image as a background and the "buttons" are just images with some text on. I then change the transparency of the buttons as the mouse moves over, so it looks like they get highlighted.

It's a bit difficult to see, but the frame rate is just under 3700 frames per second. That's okay i guess.

Slick has something called states.It separate different sections of the game from each other. My main menu class implements BasicGameState and ComponentListener.

Images are easy to load
private Image background = new Image("gamedata/menu/menuBackground1024X768.png");

Rendering it is easy as well, I use a color, that has an alpha value of 0.45f to make it a bit darker.
background.draw(0, 0, color);

The mouse over effect is achieved by setting 2 color values with different alpha values
areas[0] = new MouseOverArea(container, newCharacter, 350, 220 , 275, 41, this);
areas[0].setNormalColor(new Color(1,1,1,0.7f));
areas[0].setMouseOverColor(new Color(1,1,1,0.9f));

Then implementing the abstract method componentActivated
if (source == areas[0])
game.enterState(CreateCharacterState.ID, new EmptyTransition(), new EmptyTransition());

It looks promising, just need to find someone who can actually make some descent graphics.

No comments:

Post a Comment