Advertisement
Guest User

javaMain

a guest
Dec 28th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.34 KB | None | 0 0
  1. package user;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.logging.Logger;
  5. import main.Grid;
  6. import main.Level;
  7. import main.Map;
  8. import main.PrimsAlg;
  9. import main.RecursiveBacktracking;
  10. import main.RecursiveDivision;
  11. import org.newdawn.slick.*;
  12. import org.newdawn.slick.state.*;
  13.  
  14. public class Main extends StateBasedGame {
  15.  
  16.     private static Main instance = null;
  17.     public static AppGameContainer app;
  18.     private static final String name = "GAME";
  19.     public static final int map = 10;
  20.     public static final int recBack = 0;
  21.     public static final int recDiv = 1;
  22.     public static final int Prim = 2;
  23.     private int currentState;
  24.     private ArrayList<Grid> grid = new ArrayList<>();
  25.  
  26.     public Main(String name) {
  27.         super(name);
  28.     }
  29.  
  30.     public String getName() {
  31.         return name;
  32.        
  33.     }
  34.  
  35.     public static void main(String[] args) {
  36.         try {
  37.             app = new AppGameContainer(getInstance());
  38.             app.setDisplayMode(800, 800, false);
  39.             app.setTargetFrameRate(60);
  40.             app.start();
  41.         } catch (SlickException ex) {
  42.             Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  43.         }
  44.     }
  45.  
  46.     @Override
  47.     public void initStatesList(GameContainer gc) throws SlickException {
  48.         this.addState(new Level(recBack, new RecursiveBacktracking()));
  49.         this.addState(new Level(recDiv, new RecursiveDivision()));
  50.         this.addState(new Level(Prim, new PrimsAlg()));
  51.         this.addState(new Map(map));
  52.         this.enterState(recBack);  
  53.        
  54. //        this.getState(recBack).init(gc, this);
  55. //        this.getState(recDiv).init(gc, this);
  56. //        this.getState(Prim).init(gc, this);
  57. //        this.getState(map).init(gc, this);
  58. //        
  59. //        this.enterState(recBack);  
  60.     }
  61.  
  62.     public Grid getGrid() {
  63.         if(grid.size() <= currentState){
  64.             grid.add(currentState, new Grid(currentState + 2, 3));
  65.         }
  66.         return grid.get(currentState);
  67.     }
  68.  
  69.     public void setCurrentState(int id){
  70.         currentState = id;
  71.     }
  72.    
  73.     public int getmyOwnCurrentState(){
  74.         return currentState;
  75.     }
  76.    
  77.     public static Main getInstance() {
  78.         if (instance == null) {
  79.             instance = new Main(name);
  80.         }
  81.         return instance;
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement