hwoarang69 11 Newbie Poster

hi i am new at game development and i need help getting started. i wanted to create a basic 2d side scroller kind of like mario.

i want to create this game in java using slick libary and using a 2d array map. here is what i mean.

BBBSSBBBBBSSBBBBBB
BBBBBBBBBGBBBBBBBB
MBBBBBBBGGBBBBBBBB
GGGGDDDGGGGGGGGGGG
DDDDDDDDDDDDDDDDDD

so this is my 2d array.
M = main char
G = ground
D = hole or death
B = background
S = sky

this game has 3 files so far.
game.java = main game file
menu.java = the main menu
play.java = when game starts

/**********/
game.java
/**********/
/* state = different screens
 * This class control every thing 
 * */
package javagame;

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

public class Game extends StateBasedGame 
{
    public static final String gamename = "MARIO!";
    public static final int menu = 0;
    public static final int play = 1;

    /*** constructor Method***/
    public Game(String gamename)
    {
        super(gamename);               //add title at top of screen
        this.addState(new Menu(menu)); //working with two state
        this.addState(new Play(play)); //working with two state
    }

    //contain all states 
    public void initStatesList(GameContainer gc) throws SlickException
    {
        this.getState(menu).init(gc, this); //build menu state
        this.getState(play).init(gc, this);  //build play state
        this.enterState(menu);      //user start off at menu state
    }

    public static void main(String []args)
    {
        //window wich hold the game
        AppGameContainer appgc;
        try 
        {
            //create window and add title
            appgc = new AppGameContainer(new Game(gamename));
            //set size of window
            appgc.setDisplayMode(640, 360, false); //false = not full screen
            appgc.start(); //start window
        }
        catch(SlickException e)
        {
            e.printStackTrace();  //print error if have any
        }
    }//end of main method
}








/*******/
menu.java
/********/
package javagame;

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

public class Menu extends BasicGameState //create basic window
{   
    Image playNOW;
    Image exitGAME;

    /*** constructor Method***/
    public Menu(int state)
    {
    }

    /* create variables with new */
    public void init(GameContainer gc, StateBasedGame sbg)  throws SlickException
    {
        playNOW = new Image("res/playNOW.png");   //get image
        exitGAME = new Image("res/exitGAME.png"); //get image
    }

    /* draw stuff on screen */
    public void render(GameContainer gc, StateBasedGame sbg, Graphics g)  throws SlickException
    {
        g.drawString("Welcome to this game!", 100, 50);   //print gmae titile
        playNOW.draw(100,100);                            //print image
        exitGAME.draw(100,200);                           //print image

    }

    /* Animations */
    public void update(GameContainer gc, StateBasedGame sbg, int delta)  throws SlickException
    {
        Input input = gc.getInput();
        int Xpos = Mouse.getX();
        int Ypos = Mouse.getY();
        //Play now button
        if((Xpos>100 && Xpos<311) && (Ypos>209 && Ypos<260))
        {
            if(Mouse.isButtonDown((0))) //0 left mouse button down
            {
                sbg.enterState(1);      //enter state 1
            }
        }
        //exit button
        if((Xpos>100 && Xpos<311) && (Ypos>109 && Ypos<160))
        {
            if(Mouse.isButtonDown((0))) //0 left mouse button down
            {
                System.exit(0);         //exit program
            }
        }
    }

    public int getID()
    {
        return 0;
    }
}

/*********/
play.java
/*********/
i dont know what do do here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.