aman.greenity@gmail.com
hey guys makin the game nd i m attaching the source code 4 d same...
can anybody temme how to attach a score card and timer???
the rule of the game will be
that there will be some fruit lying in the ground and the
person need to eat them at a particular time..
so can anybody help me??

package javagame;

import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

public class Game extends StateBasedGame{

public static final String gamename = "Ham Blaster! 2.0";
public static final int menu = 0;
public static final int play = 1;

public Game(String gamename){
super(gamename);
this.addState(new Menu(menu));
this.addState(new Play(play));
}

public void initStatesList(GameContainer gc) throws SlickException{
this.getState(menu).init(gc, this);
this.getState(play).init(gc, this);
this.enterState(menu);
}

public static void main(String[] args) {
AppGameContainer appgc;
try{
appgc = new AppGameContainer(new Game(gamename));
appgc.setDisplayMode(640, 360, false);
appgc.start();
}catch(SlickException e){
e.printStackTrace();
}
}

}


package javagame;

import org.lwjgl.input.Mouse;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

public class Menu extends BasicGameState{

Image playNow;
Image exitGame;

public Menu(int state){
}

public void init(GameContainer gc, StateBasedGame sbg) throws SlickException{
playNow = new Image("res/playNow.png");
exitGame = new Image("res/exitGame.png");
}

public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
g.drawString("Welcome to Bucky Land!", 100, 50);
playNow.draw(100,100);
exitGame.draw(100,200);
}

public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
int posX = Mouse.getX();
int posY = Mouse.getY();
//play now button
if((posX>100 && posX<311)&&(posY>209 && posY<260)){
if(Mouse.isButtonDown(0)){
sbg.enterState(1);
}
}
//exit game
if((posX>100 && posX<311)&&(posY>109 && posY<160)){
if(Mouse.isButtonDown(0)){
System.exit(0);
}
}
}

public int getID(){
return 0;
}
}


package javagame;

import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

public class Play extends BasicGameState{

Animation bucky, movingUp, movingDown, movingLeft, movingRight; //4 animations, bucky will be set to one
Image worldMap;
boolean quit = false;
int[] duration = {200,200}; //duration or length of the frame
float buckyPositionX = 0; //bucky will start at coordinates 0,0
float buckyPositionY = 0;
float shiftX = buckyPositionX + 320; //this will shift the screen so bucky appears in middle
float shiftY = buckyPositionY + 160; //half the length and half the width of the screen

public Play(int state){
}

public void init(GameContainer gc, StateBasedGame sbg) throws SlickException{
worldMap = new Image("res/world.png");
Image[] walkUp = {new Image("res/buckysBack.png"), new Image("res/buckysBack.png")}; //these are the images to be used in the "walkUp" animation
Image[] walkDown = {new Image("res/buckysFront.png"), new Image("res/buckysFront.png")};
Image[] walkLeft = {new Image("res/buckysLeft.png"), new Image("res/buckysLeft.png")};
Image[] walkRight = {new Image("res/buckysRight.png"), new Image("res/buckysRight.png")};

movingUp = new Animation(walkUp, duration, false); //each animation takes array of images, duration for each image, and autoUpdate (just set to false)
movingDown = new Animation(walkDown, duration, false);
movingLeft = new Animation(walkLeft, duration, false);
movingRight = new Animation(walkRight, duration, false);
bucky = movingDown; //by default as soon as game loads, bucky will be facing down
}

public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
worldMap.draw(buckyPositionX,buckyPositionY); //draw the map at 0,0 to start
bucky.draw(shiftX,shiftY); //draw bucky at 320, 160 (center of the screen)
g.drawString("Buckys X: "+buckyPositionX+"\nBuckys Y: "+buckyPositionY, 400, 20); //indicator to see where bucky is in his world

//when they press escape
if(quit==true){
g.drawString("Resume (R)", 250, 100);
g.drawString("Main Menu (M)", 250, 150);
g.drawString("Quit Game (Q)", 250, 200);
if(quit==false){
g.clear();
}
}
}

public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
Input input = gc.getInput();

//during the game if the user hits the up arrow...
if(input.isKeyDown(Input.KEY_UP)){
bucky = movingUp; //change bucky to up image
buckyPositionY += delta * .1f; //increase the Y coordinates of bucky (move him up)
if(buckyPositionY>162){
buckyPositionY -= delta * .1f; //dont let him keep going up if he reaches the top
}
}
if(input.isKeyDown(Input.KEY_DOWN)){
bucky = movingDown;
buckyPositionY -= delta * .1f;
if(buckyPositionY<-600){
buckyPositionY += delta * .1f;
}
}
if(input.isKeyDown(Input.KEY_LEFT)){
bucky = movingLeft;
buckyPositionX += delta * .1f;
if(buckyPositionX>324){
buckyPositionX -= delta * .1f;
}
}
if(input.isKeyDown(Input.KEY_RIGHT)){
bucky = movingRight;
buckyPositionX -= delta * .1f;
if(buckyPositionX<-840){
buckyPositionX += delta * .1f;
}
}

//escape
if(input.isKeyDown(Input.KEY_ESCAPE)){
quit = true;
}

//when they hit escape
if(quit==true){
if(input.isKeyDown(Input.KEY_R)){
quit = false;
}
if(input.isKeyDown(Input.KEY_M)){
sbg.enterState(0);
try{
Thread.sleep(250);
}catch(InterruptedException e){
e.printStackTrace();
}
}
if(input.isKeyDown(Input.KEY_Q)){
System.exit(0);
}
}
}

public int getID(){
return 1;
}
}


// note : the code i have written are of 3 different classes (game,menu ,play)