I have a character who can walk around a map. I want to add a enemy that scrolls across the screen from both directions left and right allowing the character the ability to shoot the enemy.

1. I need to give my character the ability to shoot.

2. i need the enemy to randomly come on to screen.

3. I need collision detection to be set up on the enemy so if the character runs in to the enemy he dies.

can someone help me expand on my code to set this up or tell me the best way to set this up.

Is it necessary to set up more classes or can I do it all from the play state which is the code I have posted below?


Code:
package javagame;

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

public class Play extends BasicGameState{
	
	Animation bucky, movingUp, movingDown, movingLeft, movingRight;
	Image worldMap;
	boolean quit = false;
	int [] duration = {200,200};
	float buckyPositionX = 0;
	float buckyPositionY = 0;
	float shiftX = buckyPositionX + 360;
	float shiftY = buckyPositionY + 160;
	
	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")};
		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);
		movingDown = new Animation(walkDown, duration, false);
		movingLeft = new Animation(walkLeft, duration, false);
		movingRight = new Animation(walkRight, duration, false);
		bucky = movingDown;
	}
	
	public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
	worldMap.draw(buckyPositionX, buckyPositionY);
	bucky.draw(shiftX, shiftY);
	g.drawString("Buckys X: " + buckyPositionX +"\nBuckys Y: " +buckyPositionY, 500, 50);
	
	if(quit==true){
		g.drawString("Resume (R)", 250, 100);
		g.drawString("Main Menu (M)", 250, 150);
		g.drawString("Quit (Q)", 250, 200);
		if(quit==false){
			g.clear();
		}
	}
	}
	
	public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
		Input input = gc.getInput();
		
		//Up
		
		if(input.isKeyDown(Input.KEY_UP)){
			bucky = movingUp;
			buckyPositionY += delta * .1f;
			if(buckyPositionY>161){
				buckyPositionY -= delta * .1f;
			}
		}
		
		//Down
		if(input.isKeyDown(Input.KEY_DOWN)){
			bucky = movingDown;
			buckyPositionY -= delta * .1f;
		if(buckyPositionY<-598){
			buckyPositionY += delta * .1f;
			}
		}
			
		//Left
		if(input.isKeyDown(Input.KEY_LEFT)){
			bucky = movingLeft;
			buckyPositionX += delta * .1f;
			if(buckyPositionX>358){
				buckyPositionX -= delta * .1f;
			}
		}
		
		//Right
		if(input.isKeyDown(Input.KEY_RIGHT)){
			bucky = movingRight;
			buckyPositionX -= delta * .1f;
		if(buckyPositionX<-796){
			buckyPositionX += delta * .1f;
			}
		}
		
		//Up
		if(input.isKeyDown(Input.KEY_W)){
			bucky = movingUp;
			buckyPositionY += delta * .1f;
		if(buckyPositionY>161){
			buckyPositionY -= delta * .1f;
			}
		}
		//Down
		if(input.isKeyDown(Input.KEY_S)){
			bucky = movingDown;
			buckyPositionY -= delta * .1f;
		if(buckyPositionY<-598){
			buckyPositionY += delta * .1f;
			}
		}
		//Left
		if(input.isKeyDown(Input.KEY_A)){
			bucky = movingLeft;
			buckyPositionX += delta * .1f;
			if(buckyPositionX>358){
				buckyPositionX -= delta * .1f;
			}
		}
		
		//Right
		if(input.isKeyDown(Input.KEY_D)){
			bucky = movingRight;
			buckyPositionX -= delta * .1f;
			if(buckyPositionX<-796){
				buckyPositionX += delta * .1f;
		
			}
	}
		//escape
		if(input.isKeyDown(Input.KEY_ESCAPE)){
			quit = true;
		}
		//quit menu
		if(quit==true){
			if(input.isKeyDown(Input.KEY_R)){
				quit = false;		
			}
			if(input.isKeyDown(Input.KEY_M)){
				sbg.enterState(0);
		}
			if(input.isKeyDown(Input.KEY_Q)){
				System.exit(0);
			}
		}
	}
	public int getID(){
		return 1;
	}
}