Package gr.skill

Source Code of gr.skill.Skill

/*
* Created on Oct 20, 2007
*/
package gr.skill;

import gr.bluevibe.fire.components.Component;
import gr.bluevibe.fire.components.Movie;
import gr.bluevibe.fire.components.Panel;
import gr.bluevibe.fire.components.Row;
import gr.bluevibe.fire.displayables.FireScreen;
import gr.bluevibe.fire.displayables.SplashScreen;
import gr.bluevibe.fire.util.CommandListener;
import gr.bluevibe.fire.util.FireIO;
import gr.bluevibe.fire.util.Lang;

import java.util.Hashtable;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

/**
* @author padeler
*
*/
public class Skill extends MIDlet implements CommandListener
{
  private FireScreen screen;
 
 
 
  private Command exitCommand = new Command(Lang.get("Exit"), Command.BACK, 1);
  private Command startCommand = new Command(Lang.get("Start"), Command.BACK, 1);
 
  private int highestScore=0;

 
  /**
   *
   */
  public Skill()
  {
  }

  /**
   * @see javax.microedition.midlet.MIDlet#startApp()
   */
  protected void startApp() throws MIDletStateChangeException
  {
 
    Hashtable mediaMap = new Hashtable();
    mediaMap.put(FireScreen.THEME_FILE,"themef.png"); // THEME_FILE is the default key for the theme image
    mediaMap.put("logo","cafe.png"); // some other media we are going to use later on the tutorial.
 
   
    FireIO.setup(mediaMap,10,null);
   
   
        SplashScreen loading = new SplashScreen();
        loading.setTitle("Skill"); // set the title of the splash screen
        loading.setLogo(FireIO.getLocalImage("logo")); // show a nice logo.
       
        Display.getDisplay(this).setCurrent(loading); // show the load screen.
       
        Lang.loadBundle(); // this is optional if you dont want to use the Lang class for i18n
       
        FireScreen.setLogoPossition(FireScreen.LEFT);
       
       
        // Thirdly we initialize the FireScreen.
        screen = FireScreen.getScreen(Display.getDisplay(this));
        screen.setFullScreenMode(true); // set the FireScreen to full screen mode.
        screen.setOrientationChangeKey(new Integer(Canvas.KEY_STAR))// no preset key is the default. You can reset that by setting null key.
        screen.setInteractiveBusyMode(false); // false is the default value.
        Panel main = createMainPanel();
//      screen.setCurrent(new Cave(this)); // set the current panel on the FireScreen.
      screen.setCurrent(main); // set the current panel on the FireScreen.
 
  }
 
  private Panel createGamePanel()
  {
   
    Panel res = new Panel();
    res.setShowBorderDecorations(false);
    World w = new World(this);
    w.addCommand(new Command("",Command.OK,1));
    w.setCommandListener(this);
    w.setSelected(true)

    res.add(w);
    res.resetPointer();
    return res;
   
  }
 
 
  private Panel createMainPanel()
  {
    Panel main= new Panel();
    main.setCommandListener(this);
    main.addCommand(exitCommand);
   
    Row sep = new Row();
    sep.setFilled(new Integer(FireScreen.defaultFilledRowColor));
    main.add(sep);
   
    sep = new Row("Highest Score: "+highestScore);
    sep.setFilled(new Integer(FireScreen.defaultFilledRowColor));
    main.add(sep);
   
    sep = new Row();
    sep.setFilled(new Integer(FireScreen.defaultFilledRowColor));
    main.add(sep);
   
   
    Row start = new Row(FireIO.getLocalImage("lightbulb"), Lang.get("Start new game"));
    int strWidth = start.getFont().stringWidth(start.getText())+10;
    start.setFullSizeHighlight(true);
    start.setCommandListener(this);
    start.addCommand(startCommand);
    start.setAlignment(FireScreen.CENTRE);
    start.setForcedTextWidth(new Integer(strWidth));
    main.add(start);
    return main;

  }

  public void gameOver(int score)
  {
    if(highestScore<score) highestScore = score;
    screen.setCurrent(createMainPanel());
  }

 
 
  /**
   * @see javax.microedition.midlet.MIDlet#pauseApp()
   */
  protected void pauseApp()
  {

  }

  /**
   * @see javax.microedition.midlet.MIDlet#destroyApp(boolean)
   */
  protected void destroyApp(boolean arg0) throws MIDletStateChangeException
  {

  }

  public void commandAction(Command cmd, Component c)
  {
    if(cmd==exitCommand)
    { // exit requested , check the comments on the destroyApp method.
      notifyDestroyed();
      return;
    }
    if(cmd==startCommand)
    {
      screen.setCurrent(createGamePanel());
      return;
    }
  }
}
TOP

Related Classes of gr.skill.Skill

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.