Menu

Getting Started

Ben Bemis

Before you get started you need to understand the structure of the Nova Flux Library

Driver- This class Drives the games. It manages all the GamePanels and the input to them. There is an ArrayList of GamePanels called panels and the int CurrentPanel help get this accomplished.

GamePanel - this class controls the GameLoop. This is were Thing objects are controlled and rendered along with anything else that the game needs.There is an ArrayList of Thing objects called stuff.Every Thing object should be added to this Array

Thing - this class is your Core object,Entity or whatever other people are calling it these days I call it a Thing.95% of your game Objects will be a subclass of a Thing because Thing objects basic variables and methods that will be useful for just about every Thing you will create.Thing objects should be added to the stuff ArrayList of The GamePanel that they should appear on.

There are much more useful tools in this game Engine that I will cover later but this is all I have time for at the moment. But I would like to add an example of what the subclass of a Driver should look like first

import mapcreator.CreatorApp;
import panels.Level;
import panels.Menu;
import runtime.Driver;

@SuppressWarnings("serial")
public class Game extends Driver{

    public Game(){
        super();
        initPanel(CurrentPanel = 0);
        set4_3Ratio( Driver.WIDTH = 1000);
        setSize(Driver.WIDTH, Driver.HEIGHT);
    }

    @Override
    public void initPanel(int NextPanel) {
        switch(NextPanel){
        case 0:
            panels.add(0, new Menu( (Driver)this) );
            break;

        }
    }

    public static void main(String[] args){

        game =  new Game();
        game.add( panels.get(CurrentPanel) );
        ( panels.get(CurrentPanel) ).setVisible(true);
        game.setVisible(true);

        panels.get(CurrentPanel).startPanel();

//      new CreatorApp(ref.ID.class);
    }

}

also here is a example of a terribly designed Menu which is a subclass of a GamePanel

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;

import main.LM;
import runtime.Driver;
import runtime.GamePanel;
import tools.Button;
import tools.ProgressBar;

public class Menu extends GamePanel{

    /**

     * 
     */
    private static final long serialVersionUID = 1L;

    private Button play,exit;
    private ProgressBar pb;

    public Menu(Driver game) {
        super(game);



        play = new Play();
        exit = new Exit();
    }

    @Override
    public void Step() {
        super.Step();

    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.setColor(Color.BLACK);
        g.fillRect(0, 0, Driver.WIDTH, Driver.HEIGHT);

        play.render(g);
        exit.render(g);
    }

    @Override
    public void mouseMoved(MouseEvent e) {
        super.mouseMoved(e);
        play.MouseMoved(e);
        exit.MouseMoved(e);
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        play.MouseClicked(e);
        exit.MouseClicked(e);
    }


    private class Play extends Button{

        public Play() {
            super("Play", new Rectangle(50, 50, 100, 100), 40);
            Enabled = false;
        }

        @Override
        public void Clicked() {
            super.Clicked();

        }

    }

    private class Exit extends Button{
        public Exit(){
            super("Exit",new Rectangle(50,200,100,100),40);
        }

        @Override
        public void Clicked() {
            super.Clicked();
            game.destroy();
        }
    }

}

MongoDB Logo MongoDB