SlideShare a Scribd company logo
LẬP TRÌNH J2ME CHO THIẾT BỊ DI ĐỘNG
PHẦN 5

Giáo viên : Trịnh Thị Vân Anh

Hà nội, 8-2007
Eliminator: Game Menu, EliminatorBasicMenu (1)


Basic Main Menu

import javax.microedition.lcdui.*;
public class MainMenuScreen extends List
implements CommandListener {
private Eliminator midlet;
private Command selectCommand = new
Command("Select", Command.ITEM,1);
private Command exitCommand = new
Command("Exit", Command.EXIT,1);
private Alert alert;
public MainMenuScreen(Eliminator midlet) {
super("Eliminator",Choice.IMPLICIT);
this.midlet = midlet;
append("New Game",null);
append("Settings",null);
append("High Scores", null);
append("Help",null);
append("About",null);

addCommand(exitCommand);
addCommand(selectCommand);
setCommandListener(this);
}
public void commandAction(Command c,
Displayable d) {
if (c == exitCommand) {
midlet.mainMenuScreenQuit();
return;
} else if (c == selectCommand) {
processMenu(); return;
} else {
processMenu(); return;
}
}

2
Eliminator: Game Menu, EliminatorBasicMenu (2)
private void processMenu() {
try {
List down = (List)midlet.display.getCurrent();
switch (down.getSelectedIndex()) {
case 0: scnNewGame(); break;
case 1: scnSettings(); break;
case 2: scnHighScores(); break;
case 3: scnHelp(); break;
case 4: scnAbout(); break;};
} catch (Exception ex) {

alert = new
Alert("Settings","Settings.......",null,null);

// Proper Error Handling should be done here

,"High Scores.......",null,null);

System.out.println("processMenu::"+ex);} }

alert.setTimeout(Alert.FOREVER);

private void scnNewGame() {

alert.setType(AlertType.INFO);

midlet.mainMenuScreenShow(null); }

midlet.mainMenuScreenShow(alert);

private void scnSettings() {

}

alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.INFO);
midlet.mainMenuScreenShow(alert);
}
private void scnHighScores() {
alert = new Alert("High Scores"

3
Eliminator: Game Menu, EliminatorBasicMenu (3)
private void scnHelp() {
alert = new Alert("Help","Help....................",null,null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.INFO);
midlet.mainMenuScreenShow(alert);
}
private void scnAbout() {
alert = new Alert("About","EliminatornVersion 1.0.0nby Jason Lam",null,null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.INFO);
midlet.mainMenuScreenShow(alert);
}
}

4
Eliminator: Game Menu, EliminatorBasicMenu (4)


Main Midlet Source Code:

import javax.microedition.midlet.*;

isSplash = false;

import javax.microedition.lcdui.*;

try {

public class Eliminator extends MIDlet {

splashLogo =Image.createImage("/splash.png");

protected Display display;

new SplashScreen(display, mainMenuScreen,
splashLogo,3000);

private Image splashLogo;
private boolean isSplash = true;
MainMenuScreen mainMenuScreen;
public Eliminator() {}
public void startApp() {
display = Display.getDisplay(this);
mainMenuScreen = new
MainMenuScreen(this);

} catch(Exception ex) {
mainMenuScreenShow(null);
}
} else {
mainMenuScreenShow(null);
}
}

if(isSplash) {

5
Eliminator: Game Menu, EliminatorBasicMenu (5)
public Display getDisplay() {
return display;}
public void pauseApp() {}
public void destroyApp(boolean unconditional)
{
System.gc();
notifyDestroyed();
}
private Image createImage(String filename) {
Image image = null;
try {
image = Image.createImage(filename);
} catch (Exception e) {
}return image;
}

public void mainMenuScreenShow(Alert alert)
{
if (alert==null)
display.setCurrent(mainMenuScreen);
else
display.setCurrent(alert,mainMenuScreen);
}
public void mainMenuScreenQuit() {
destroyApp(true);
}
}

6
Eliminator: Game Menu, EliminatorSubMenu (1)
private void scnNewGame() {
midlet.mainMenuScreenShow();
}
private void scnSettings() {
midlet.settingsScreenShow();
}
private void scnHighScore() {
midlet.highScoreScreenShow();
}
private void scnHelp() {
midlet.helpScreenShow();
}
private void scnAbout() {
midlet.aboutScreenShow();
}
}

7
Eliminator: Game Menu, EliminatorSubMenu (2)
High Score Screen Source Code:
import javax.microedition.lcdui.*;
public class HighScoreScreen extends Form implements CommandListener {
private Eliminator midlet;
private Command backCommand = new Command("Back", Command.BACK,1);
private Command resetCommand = new Command("Rest", Command.SCREEN,1);
public HighScoreScreen (Eliminator midlet) {
super("High Score");
this.midlet = midlet;
StringItem stringItem = new StringItem(null,"JL 100nJL 50nJL 10");
append(stringItem);
addCommand(backCommand);
addCommand(resetCommand); setCommandListener(this); }
public void commandAction(Command c, Displayable d) {
if (c == backCommand) {
midlet.mainMenuScreenShow();
return;
}if (c == resetCommand) { // not implemented yet
System.out.println("Reset High Scores Not Implemented Yet");
}}}


8
Eliminator: Game Menu, EliminatorSubMenu (3)
Help Screen Source Code:
import javax.microedition.lcdui.*;
public class HelpScreen extends Form implements CommandListener {
private Eliminator midlet;
private Command backCommand = new Command("Back", Command.BACK, 1);
public HelpScreen (Eliminator midlet) {
super("Help");
this.midlet = midlet;
StringItem stringItem = new StringItem(null,"It is the year 3023, many things have changed over
the years " +
…………
);
append(stringItem); addCommand(backCommand);
setCommandListener(this); }
public void commandAction(Command c, Displayable d) {
if (c == backCommand) {
midlet.mainMenuScreenShow();
return;
}}}


9
Eliminator: Game Menu, EliminatorSubMenu (4)
About Screen Source Code:
import javax.microedition.lcdui.*;
public class AboutScreen extends Form implements CommandListener {
private Eliminator midlet;
private Command backCommand = new Command("Back", Command.BACK, 1);
public AboutScreen (Eliminator midlet) {
super("About");
this.midlet = midlet;
StringItem stringItem = new StringItem(null,"EliminatornVersion 1.0.0nBy Jason Lam");
append(stringItem);
addCommand(backCommand); setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
if (c == backCommand) {
midlet.mainMenuScreenShow();
return;
}}}


10
Eliminator: Terrain (Scrolling Background)
private TiledLayer loadTerrain() throws
Exception {
Image tileImages =
Image.createImage("/terrain.png");
TiledLayer tiledLayer = new
TiledLayer(TILE_NUM_COL,TILE_NUM_
ROW,tileImages,TILE_WIDTH,TILE_HEI
GHT);
// Define Terrain Map
int[][] map = {
{0,0,0,0,0,0}, {3,0,0,0,0,0}, {6,0,0,0,0,0},
{6,0,0,0,1,2}, {6,0,0,0,4,5}, {6,0,0,0,7,8},
{6,0,0,0,0,0},{9,0,1,2,3,0}, {0,0,4,5,6,0},
{0,0,7,8,9,0},{0,0,0,0,0,0}, {0,0,0,0,0,0},
{0,0,0,0,0,0},{3,0,0,0,0,0}, {6,0,0,0,0,0},

{6,0,0,0,1,2}, {6,0,0,0,4,5}, {6,0,0,0,7,8},
{6,0,0,0,0,0}, {9,0,1,2,3,0}, {0,0,4,5,6,0},
{0,0,7,8,9,0}, {0,0,0,0,0,0},{0,0,0,0,0,0},
{0,0,0,0,0,0},{3,0,0,0,0,0}, {6,0,0,0,0,0},
{6,0,0,0,1,2},{6,0,0,0,4,5}, {6,0,0,0,7,8},
{6,0,0,0,0,0},{9,0,0,0,0,0}, {0,0,0,0,0,0},
{0,0,0,0,0,0},{0,0,0,0,0,0}, {3,0,0,0,0,1}
};

// Map Terrain Map with actual graphic from terrain.png

for (int row=0; row<TILE_NUM_ROW; row++) {
for (int col=0; col<TILE_NUM_COL; col++) {
tiledLayer.setCell(col,row,map[row][col]);
}
}return tiledLayer;
}
Ví dụ: EliminatorScrolling

11
Eliminator: Player , ví dụ : EliminatorPlayer
Player Sprite
public class PlayerSprite extends Sprite {
private static final int MOVE = 3;
private int x,y;
private int scnWidth,scnHeight;
private int frameWidth, frameHeight;
private int frame;
private int lives;
public PlayerSprite(Image image, int frameWidth,
int frameHeight, int scnWidth, int scnHeight)
throws Exception {
super(image, frameWidth, frameHeight);
x = frameWidth/2;
y = frameHeight/2;
this.scnWidth = scnWidth;
this.scnHeight = scnHeight;
this.frameWidth = frameWidth;
this.frameHeight = frameHeight;
this.frame = 1; this.lives = 3;}


public void startPosition() {
setPosition(scnWidth/2,scnHeight/2);}
public void moveLeft() {
getXY();
if (x - MOVE > 0)
move(MOVE * -1,0);}
public void moveRight() {
getXY();
if (x + MOVE + frameWidth < scnWidth)
move(MOVE,0);}
public void moveUp() {
getXY();
if (y - MOVE > 0)
move(0,MOVE * -1);}
public void moveDown() {
getXY();
if (y + MOVE + frameHeight < scnHeight)
move(0,MOVE);}

12

More Related Content

What's hot

The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 59 of 196
The Ring programming language version 1.7 book - Part 59 of 196The Ring programming language version 1.7 book - Part 59 of 196
The Ring programming language version 1.7 book - Part 59 of 196
Mahmoud Samir Fayed
 
Phonegap for Android
Phonegap for AndroidPhonegap for Android
Phonegap for Android
Dr. Ramkumar Lakshminarayanan
 
The Ring programming language version 1.8 book - Part 64 of 202
The Ring programming language version 1.8 book - Part 64 of 202The Ring programming language version 1.8 book - Part 64 of 202
The Ring programming language version 1.8 book - Part 64 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.5 book - Part 10 of 31
The Ring programming language version 1.5 book - Part 10 of 31The Ring programming language version 1.5 book - Part 10 of 31
The Ring programming language version 1.5 book - Part 10 of 31
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 55 of 185
The Ring programming language version 1.5.4 book - Part 55 of 185The Ring programming language version 1.5.4 book - Part 55 of 185
The Ring programming language version 1.5.4 book - Part 55 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 62 of 196
The Ring programming language version 1.7 book - Part 62 of 196The Ring programming language version 1.7 book - Part 62 of 196
The Ring programming language version 1.7 book - Part 62 of 196
Mahmoud Samir Fayed
 
Create xo game in android studio
Create xo game in android studioCreate xo game in android studio
Create xo game in android studio
MahmoodGhaemMaghami
 
The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185
Mahmoud Samir Fayed
 
551 pd fsam_fayed_ring_doc_1.5.2
551 pd fsam_fayed_ring_doc_1.5.2551 pd fsam_fayed_ring_doc_1.5.2
551 pd fsam_fayed_ring_doc_1.5.2Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 66 of 210
The Ring programming language version 1.9 book - Part 66 of 210The Ring programming language version 1.9 book - Part 66 of 210
The Ring programming language version 1.9 book - Part 66 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 56 of 180
The Ring programming language version 1.5.1 book - Part 56 of 180The Ring programming language version 1.5.1 book - Part 56 of 180
The Ring programming language version 1.5.1 book - Part 56 of 180
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 67 of 212
The Ring programming language version 1.10 book - Part 67 of 212The Ring programming language version 1.10 book - Part 67 of 212
The Ring programming language version 1.10 book - Part 67 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.2 book - Part 54 of 181
The Ring programming language version 1.5.2 book - Part 54 of 181The Ring programming language version 1.5.2 book - Part 54 of 181
The Ring programming language version 1.5.2 book - Part 54 of 181
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 50 of 184
The Ring programming language version 1.5.3 book - Part 50 of 184The Ring programming language version 1.5.3 book - Part 50 of 184
The Ring programming language version 1.5.3 book - Part 50 of 184
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 57 of 189
The Ring programming language version 1.6 book - Part 57 of 189The Ring programming language version 1.6 book - Part 57 of 189
The Ring programming language version 1.6 book - Part 57 of 189
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 66 of 184
The Ring programming language version 1.5.3 book - Part 66 of 184The Ring programming language version 1.5.3 book - Part 66 of 184
The Ring programming language version 1.5.3 book - Part 66 of 184
Mahmoud Samir Fayed
 

What's hot (20)

The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212The Ring programming language version 1.10 book - Part 70 of 212
The Ring programming language version 1.10 book - Part 70 of 212
 
The Ring programming language version 1.7 book - Part 59 of 196
The Ring programming language version 1.7 book - Part 59 of 196The Ring programming language version 1.7 book - Part 59 of 196
The Ring programming language version 1.7 book - Part 59 of 196
 
Phonegap for Android
Phonegap for AndroidPhonegap for Android
Phonegap for Android
 
The Ring programming language version 1.8 book - Part 64 of 202
The Ring programming language version 1.8 book - Part 64 of 202The Ring programming language version 1.8 book - Part 64 of 202
The Ring programming language version 1.8 book - Part 64 of 202
 
The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189The Ring programming language version 1.6 book - Part 59 of 189
The Ring programming language version 1.6 book - Part 59 of 189
 
The Ring programming language version 1.5 book - Part 10 of 31
The Ring programming language version 1.5 book - Part 10 of 31The Ring programming language version 1.5 book - Part 10 of 31
The Ring programming language version 1.5 book - Part 10 of 31
 
The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180
 
The Ring programming language version 1.5.4 book - Part 55 of 185
The Ring programming language version 1.5.4 book - Part 55 of 185The Ring programming language version 1.5.4 book - Part 55 of 185
The Ring programming language version 1.5.4 book - Part 55 of 185
 
The Ring programming language version 1.7 book - Part 62 of 196
The Ring programming language version 1.7 book - Part 62 of 196The Ring programming language version 1.7 book - Part 62 of 196
The Ring programming language version 1.7 book - Part 62 of 196
 
Create xo game in android studio
Create xo game in android studioCreate xo game in android studio
Create xo game in android studio
 
The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185The Ring programming language version 1.5.4 book - Part 51 of 185
The Ring programming language version 1.5.4 book - Part 51 of 185
 
551 pd fsam_fayed_ring_doc_1.5.2
551 pd fsam_fayed_ring_doc_1.5.2551 pd fsam_fayed_ring_doc_1.5.2
551 pd fsam_fayed_ring_doc_1.5.2
 
The Ring programming language version 1.9 book - Part 66 of 210
The Ring programming language version 1.9 book - Part 66 of 210The Ring programming language version 1.9 book - Part 66 of 210
The Ring programming language version 1.9 book - Part 66 of 210
 
The Ring programming language version 1.5.1 book - Part 56 of 180
The Ring programming language version 1.5.1 book - Part 56 of 180The Ring programming language version 1.5.1 book - Part 56 of 180
The Ring programming language version 1.5.1 book - Part 56 of 180
 
The Ring programming language version 1.10 book - Part 67 of 212
The Ring programming language version 1.10 book - Part 67 of 212The Ring programming language version 1.10 book - Part 67 of 212
The Ring programming language version 1.10 book - Part 67 of 212
 
The Ring programming language version 1.5.2 book - Part 54 of 181
The Ring programming language version 1.5.2 book - Part 54 of 181The Ring programming language version 1.5.2 book - Part 54 of 181
The Ring programming language version 1.5.2 book - Part 54 of 181
 
The Ring programming language version 1.5.3 book - Part 50 of 184
The Ring programming language version 1.5.3 book - Part 50 of 184The Ring programming language version 1.5.3 book - Part 50 of 184
The Ring programming language version 1.5.3 book - Part 50 of 184
 
The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88The Ring programming language version 1.3 book - Part 40 of 88
The Ring programming language version 1.3 book - Part 40 of 88
 
The Ring programming language version 1.6 book - Part 57 of 189
The Ring programming language version 1.6 book - Part 57 of 189The Ring programming language version 1.6 book - Part 57 of 189
The Ring programming language version 1.6 book - Part 57 of 189
 
The Ring programming language version 1.5.3 book - Part 66 of 184
The Ring programming language version 1.5.3 book - Part 66 of 184The Ring programming language version 1.5.3 book - Part 66 of 184
The Ring programming language version 1.5.3 book - Part 66 of 184
 

Viewers also liked

Marco común para las normas de Contabilidad
Marco común para las normas de ContabilidadMarco común para las normas de Contabilidad
Marco común para las normas de ContabilidadSerginaFontalvo
 
Callsheet
CallsheetCallsheet
CallsheetGMeah
 
Los angeles del sistal legislacion 2
Los angeles del sistal legislacion 2Los angeles del sistal legislacion 2
Los angeles del sistal legislacion 2poli_morote
 
[Whitepaper] Morden PR
[Whitepaper] Morden PR[Whitepaper] Morden PR
[Whitepaper] Morden PR
Hiệp Hội PR Việt Nam PRSVN
 
Congressional Briefing 10222009
Congressional Briefing 10222009Congressional Briefing 10222009
Congressional Briefing 10222009jaythomas
 
Changing Oceans Expedition 2012 - Laura Wicks, MASTS
Changing Oceans Expedition 2012 - Laura Wicks, MASTSChanging Oceans Expedition 2012 - Laura Wicks, MASTS
Changing Oceans Expedition 2012 - Laura Wicks, MASTS
Heriot-Watt University
 

Viewers also liked (7)

Marco común para las normas de Contabilidad
Marco común para las normas de ContabilidadMarco común para las normas de Contabilidad
Marco común para las normas de Contabilidad
 
Callsheet
CallsheetCallsheet
Callsheet
 
Los angeles del sistal legislacion 2
Los angeles del sistal legislacion 2Los angeles del sistal legislacion 2
Los angeles del sistal legislacion 2
 
[Whitepaper] Morden PR
[Whitepaper] Morden PR[Whitepaper] Morden PR
[Whitepaper] Morden PR
 
Congressional Briefing 10222009
Congressional Briefing 10222009Congressional Briefing 10222009
Congressional Briefing 10222009
 
Con trai thời @
Con trai thời @Con trai thời @
Con trai thời @
 
Changing Oceans Expedition 2012 - Laura Wicks, MASTS
Changing Oceans Expedition 2012 - Laura Wicks, MASTSChanging Oceans Expedition 2012 - Laura Wicks, MASTS
Changing Oceans Expedition 2012 - Laura Wicks, MASTS
 

Similar to J2 me 07_5

ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
rajkumarm401
 
Whenever I run my application my Game appears with the pict.pdf
Whenever I run my application my Game appears with the pict.pdfWhenever I run my application my Game appears with the pict.pdf
Whenever I run my application my Game appears with the pict.pdf
aarthitimesgd
 
Why am I getting an out of memory error and no window of my .pdf
Why am I getting an out of memory error and no window of my .pdfWhy am I getting an out of memory error and no window of my .pdf
Why am I getting an out of memory error and no window of my .pdf
aakarcreations1
 
Contoh bahan latihan programan mobile java
Contoh bahan latihan programan mobile javaContoh bahan latihan programan mobile java
Contoh bahan latihan programan mobile java
Jurnal IT
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
udit652068
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.
Kuldeep Jain
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3
Jieyi Wu
 
Flappy bird
Flappy birdFlappy bird
Flappy bird
SantiagoYepesSerna
 
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdf
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdfImport java.awt.; Import acm.program.; Import acm.graphics.;.pdf
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdf
apexcomputer54
 
This is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdfThis is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdf
anjandavid
 
Sumsem2014 15 cp0399-13-jun-2015_rm01_programs
Sumsem2014 15 cp0399-13-jun-2015_rm01_programsSumsem2014 15 cp0399-13-jun-2015_rm01_programs
Sumsem2014 15 cp0399-13-jun-2015_rm01_programsAbhijit Borah
 
Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)
Danny Preussler
 
Spin Up Desktop Apps with Electron.js
Spin Up Desktop Apps with Electron.jsSpin Up Desktop Apps with Electron.js
Spin Up Desktop Apps with Electron.js
Steve Godin
 
Tic Tac Toe game with GUI please dont copy and paste from google. .pdf
Tic Tac Toe game with GUI please dont copy and paste from google. .pdfTic Tac Toe game with GUI please dont copy and paste from google. .pdf
Tic Tac Toe game with GUI please dont copy and paste from google. .pdf
formaxekochi
 
Sequence diagrams
Sequence diagramsSequence diagrams
Sequence diagrams
Alfonso Torres
 

Similar to J2 me 07_5 (20)

ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
 
Whenever I run my application my Game appears with the pict.pdf
Whenever I run my application my Game appears with the pict.pdfWhenever I run my application my Game appears with the pict.pdf
Whenever I run my application my Game appears with the pict.pdf
 
Why am I getting an out of memory error and no window of my .pdf
Why am I getting an out of memory error and no window of my .pdfWhy am I getting an out of memory error and no window of my .pdf
Why am I getting an out of memory error and no window of my .pdf
 
662305 LAB12
662305 LAB12662305 LAB12
662305 LAB12
 
Contoh bahan latihan programan mobile java
Contoh bahan latihan programan mobile javaContoh bahan latihan programan mobile java
Contoh bahan latihan programan mobile java
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
 
ETM Server
ETM ServerETM Server
ETM Server
 
Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.Chat application in java using swing and socket programming.
Chat application in java using swing and socket programming.
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3
 
Flappy bird
Flappy birdFlappy bird
Flappy bird
 
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdf
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdfImport java.awt.; Import acm.program.; Import acm.graphics.;.pdf
Import java.awt.; Import acm.program.; Import acm.graphics.;.pdf
 
This is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdfThis is Java,I am currently stumped on how to add a scoreboard for.pdf
This is Java,I am currently stumped on how to add a scoreboard for.pdf
 
Applications
ApplicationsApplications
Applications
 
Sumsem2014 15 cp0399-13-jun-2015_rm01_programs
Sumsem2014 15 cp0399-13-jun-2015_rm01_programsSumsem2014 15 cp0399-13-jun-2015_rm01_programs
Sumsem2014 15 cp0399-13-jun-2015_rm01_programs
 
Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)Android Code Puzzles (DroidCon Amsterdam 2012)
Android Code Puzzles (DroidCon Amsterdam 2012)
 
662305 LAB13
662305 LAB13662305 LAB13
662305 LAB13
 
Spin Up Desktop Apps with Electron.js
Spin Up Desktop Apps with Electron.jsSpin Up Desktop Apps with Electron.js
Spin Up Desktop Apps with Electron.js
 
Tic Tac Toe game with GUI please dont copy and paste from google. .pdf
Tic Tac Toe game with GUI please dont copy and paste from google. .pdfTic Tac Toe game with GUI please dont copy and paste from google. .pdf
Tic Tac Toe game with GUI please dont copy and paste from google. .pdf
 
Sequence diagrams
Sequence diagramsSequence diagrams
Sequence diagrams
 
Tdd in unity
Tdd in unityTdd in unity
Tdd in unity
 

More from vanliemtb

Tran van chien
Tran van chienTran van chien
Tran van chienvanliemtb
 
Tom tat lv th s nguyen xuan bach
Tom tat lv th s nguyen xuan bachTom tat lv th s nguyen xuan bach
Tom tat lv th s nguyen xuan bachvanliemtb
 
Tom tat lv th s ha quang thang 2012
Tom tat lv th s ha quang thang 2012Tom tat lv th s ha quang thang 2012
Tom tat lv th s ha quang thang 2012vanliemtb
 
Tóm tat lv lt.hiệu
Tóm tat lv lt.hiệuTóm tat lv lt.hiệu
Tóm tat lv lt.hiệuvanliemtb
 
Ttlats dinh thi thu phong
Ttlats dinh thi thu phongTtlats dinh thi thu phong
Ttlats dinh thi thu phongvanliemtb
 
Ttlv chu chi linh
Ttlv chu chi linhTtlv chu chi linh
Ttlv chu chi linhvanliemtb
 
Ttlv lưu thanh huy
Ttlv lưu thanh huyTtlv lưu thanh huy
Ttlv lưu thanh huyvanliemtb
 
Ttlv hoang dinh hung
Ttlv hoang dinh hungTtlv hoang dinh hung
Ttlv hoang dinh hungvanliemtb
 
Ttlats dinh thi thu phong
Ttlats dinh thi thu phongTtlats dinh thi thu phong
Ttlats dinh thi thu phongvanliemtb
 
Vi quang hieu
Vi quang hieuVi quang hieu
Vi quang hieuvanliemtb
 
Tom tat lv th s ha quang thang 2012
Tom tat lv th s ha quang thang 2012Tom tat lv th s ha quang thang 2012
Tom tat lv th s ha quang thang 2012vanliemtb
 
Nguyễn ngọc ánh
Nguyễn ngọc ánhNguyễn ngọc ánh
Nguyễn ngọc ánhvanliemtb
 
Lv th s.ck hanh.10
Lv th s.ck hanh.10Lv th s.ck hanh.10
Lv th s.ck hanh.10vanliemtb
 
Nghien+cuu++he+thong+truyen+dan+quang
Nghien+cuu++he+thong+truyen+dan+quangNghien+cuu++he+thong+truyen+dan+quang
Nghien+cuu++he+thong+truyen+dan+quangvanliemtb
 
Mang va cac cong nghe truy nhap
Mang va cac cong nghe truy nhapMang va cac cong nghe truy nhap
Mang va cac cong nghe truy nhapvanliemtb
 
Thong tin quang 2
Thong tin quang 2Thong tin quang 2
Thong tin quang 2vanliemtb
 
Ky thuat so phan 8
Ky thuat so phan 8Ky thuat so phan 8
Ky thuat so phan 8vanliemtb
 
Bao caototnghiep ve vpn
Bao caototnghiep ve vpnBao caototnghiep ve vpn
Bao caototnghiep ve vpnvanliemtb
 

More from vanliemtb (20)

Tran van chien
Tran van chienTran van chien
Tran van chien
 
Tom tat lv th s nguyen xuan bach
Tom tat lv th s nguyen xuan bachTom tat lv th s nguyen xuan bach
Tom tat lv th s nguyen xuan bach
 
Tom tat lv th s ha quang thang 2012
Tom tat lv th s ha quang thang 2012Tom tat lv th s ha quang thang 2012
Tom tat lv th s ha quang thang 2012
 
00050001334
0005000133400050001334
00050001334
 
Tóm tat lv lt.hiệu
Tóm tat lv lt.hiệuTóm tat lv lt.hiệu
Tóm tat lv lt.hiệu
 
Ttlats dinh thi thu phong
Ttlats dinh thi thu phongTtlats dinh thi thu phong
Ttlats dinh thi thu phong
 
Ttlv chu chi linh
Ttlv chu chi linhTtlv chu chi linh
Ttlv chu chi linh
 
Ttlv lưu thanh huy
Ttlv lưu thanh huyTtlv lưu thanh huy
Ttlv lưu thanh huy
 
Ttlv hoang dinh hung
Ttlv hoang dinh hungTtlv hoang dinh hung
Ttlv hoang dinh hung
 
Ttlats dinh thi thu phong
Ttlats dinh thi thu phongTtlats dinh thi thu phong
Ttlats dinh thi thu phong
 
V l0 02714
V l0 02714V l0 02714
V l0 02714
 
Vi quang hieu
Vi quang hieuVi quang hieu
Vi quang hieu
 
Tom tat lv th s ha quang thang 2012
Tom tat lv th s ha quang thang 2012Tom tat lv th s ha quang thang 2012
Tom tat lv th s ha quang thang 2012
 
Nguyễn ngọc ánh
Nguyễn ngọc ánhNguyễn ngọc ánh
Nguyễn ngọc ánh
 
Lv th s.ck hanh.10
Lv th s.ck hanh.10Lv th s.ck hanh.10
Lv th s.ck hanh.10
 
Nghien+cuu++he+thong+truyen+dan+quang
Nghien+cuu++he+thong+truyen+dan+quangNghien+cuu++he+thong+truyen+dan+quang
Nghien+cuu++he+thong+truyen+dan+quang
 
Mang va cac cong nghe truy nhap
Mang va cac cong nghe truy nhapMang va cac cong nghe truy nhap
Mang va cac cong nghe truy nhap
 
Thong tin quang 2
Thong tin quang 2Thong tin quang 2
Thong tin quang 2
 
Ky thuat so phan 8
Ky thuat so phan 8Ky thuat so phan 8
Ky thuat so phan 8
 
Bao caototnghiep ve vpn
Bao caototnghiep ve vpnBao caototnghiep ve vpn
Bao caototnghiep ve vpn
 

Recently uploaded

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 

Recently uploaded (20)

Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 

J2 me 07_5

  • 1. LẬP TRÌNH J2ME CHO THIẾT BỊ DI ĐỘNG PHẦN 5 Giáo viên : Trịnh Thị Vân Anh Hà nội, 8-2007
  • 2. Eliminator: Game Menu, EliminatorBasicMenu (1)  Basic Main Menu import javax.microedition.lcdui.*; public class MainMenuScreen extends List implements CommandListener { private Eliminator midlet; private Command selectCommand = new Command("Select", Command.ITEM,1); private Command exitCommand = new Command("Exit", Command.EXIT,1); private Alert alert; public MainMenuScreen(Eliminator midlet) { super("Eliminator",Choice.IMPLICIT); this.midlet = midlet; append("New Game",null); append("Settings",null); append("High Scores", null); append("Help",null); append("About",null); addCommand(exitCommand); addCommand(selectCommand); setCommandListener(this); } public void commandAction(Command c, Displayable d) { if (c == exitCommand) { midlet.mainMenuScreenQuit(); return; } else if (c == selectCommand) { processMenu(); return; } else { processMenu(); return; } } 2
  • 3. Eliminator: Game Menu, EliminatorBasicMenu (2) private void processMenu() { try { List down = (List)midlet.display.getCurrent(); switch (down.getSelectedIndex()) { case 0: scnNewGame(); break; case 1: scnSettings(); break; case 2: scnHighScores(); break; case 3: scnHelp(); break; case 4: scnAbout(); break;}; } catch (Exception ex) { alert = new Alert("Settings","Settings.......",null,null); // Proper Error Handling should be done here ,"High Scores.......",null,null); System.out.println("processMenu::"+ex);} } alert.setTimeout(Alert.FOREVER); private void scnNewGame() { alert.setType(AlertType.INFO); midlet.mainMenuScreenShow(null); } midlet.mainMenuScreenShow(alert); private void scnSettings() { } alert.setTimeout(Alert.FOREVER); alert.setType(AlertType.INFO); midlet.mainMenuScreenShow(alert); } private void scnHighScores() { alert = new Alert("High Scores" 3
  • 4. Eliminator: Game Menu, EliminatorBasicMenu (3) private void scnHelp() { alert = new Alert("Help","Help....................",null,null); alert.setTimeout(Alert.FOREVER); alert.setType(AlertType.INFO); midlet.mainMenuScreenShow(alert); } private void scnAbout() { alert = new Alert("About","EliminatornVersion 1.0.0nby Jason Lam",null,null); alert.setTimeout(Alert.FOREVER); alert.setType(AlertType.INFO); midlet.mainMenuScreenShow(alert); } } 4
  • 5. Eliminator: Game Menu, EliminatorBasicMenu (4)  Main Midlet Source Code: import javax.microedition.midlet.*; isSplash = false; import javax.microedition.lcdui.*; try { public class Eliminator extends MIDlet { splashLogo =Image.createImage("/splash.png"); protected Display display; new SplashScreen(display, mainMenuScreen, splashLogo,3000); private Image splashLogo; private boolean isSplash = true; MainMenuScreen mainMenuScreen; public Eliminator() {} public void startApp() { display = Display.getDisplay(this); mainMenuScreen = new MainMenuScreen(this); } catch(Exception ex) { mainMenuScreenShow(null); } } else { mainMenuScreenShow(null); } } if(isSplash) { 5
  • 6. Eliminator: Game Menu, EliminatorBasicMenu (5) public Display getDisplay() { return display;} public void pauseApp() {} public void destroyApp(boolean unconditional) { System.gc(); notifyDestroyed(); } private Image createImage(String filename) { Image image = null; try { image = Image.createImage(filename); } catch (Exception e) { }return image; } public void mainMenuScreenShow(Alert alert) { if (alert==null) display.setCurrent(mainMenuScreen); else display.setCurrent(alert,mainMenuScreen); } public void mainMenuScreenQuit() { destroyApp(true); } } 6
  • 7. Eliminator: Game Menu, EliminatorSubMenu (1) private void scnNewGame() { midlet.mainMenuScreenShow(); } private void scnSettings() { midlet.settingsScreenShow(); } private void scnHighScore() { midlet.highScoreScreenShow(); } private void scnHelp() { midlet.helpScreenShow(); } private void scnAbout() { midlet.aboutScreenShow(); } } 7
  • 8. Eliminator: Game Menu, EliminatorSubMenu (2) High Score Screen Source Code: import javax.microedition.lcdui.*; public class HighScoreScreen extends Form implements CommandListener { private Eliminator midlet; private Command backCommand = new Command("Back", Command.BACK,1); private Command resetCommand = new Command("Rest", Command.SCREEN,1); public HighScoreScreen (Eliminator midlet) { super("High Score"); this.midlet = midlet; StringItem stringItem = new StringItem(null,"JL 100nJL 50nJL 10"); append(stringItem); addCommand(backCommand); addCommand(resetCommand); setCommandListener(this); } public void commandAction(Command c, Displayable d) { if (c == backCommand) { midlet.mainMenuScreenShow(); return; }if (c == resetCommand) { // not implemented yet System.out.println("Reset High Scores Not Implemented Yet"); }}}  8
  • 9. Eliminator: Game Menu, EliminatorSubMenu (3) Help Screen Source Code: import javax.microedition.lcdui.*; public class HelpScreen extends Form implements CommandListener { private Eliminator midlet; private Command backCommand = new Command("Back", Command.BACK, 1); public HelpScreen (Eliminator midlet) { super("Help"); this.midlet = midlet; StringItem stringItem = new StringItem(null,"It is the year 3023, many things have changed over the years " + ………… ); append(stringItem); addCommand(backCommand); setCommandListener(this); } public void commandAction(Command c, Displayable d) { if (c == backCommand) { midlet.mainMenuScreenShow(); return; }}}  9
  • 10. Eliminator: Game Menu, EliminatorSubMenu (4) About Screen Source Code: import javax.microedition.lcdui.*; public class AboutScreen extends Form implements CommandListener { private Eliminator midlet; private Command backCommand = new Command("Back", Command.BACK, 1); public AboutScreen (Eliminator midlet) { super("About"); this.midlet = midlet; StringItem stringItem = new StringItem(null,"EliminatornVersion 1.0.0nBy Jason Lam"); append(stringItem); addCommand(backCommand); setCommandListener(this); } public void commandAction(Command c, Displayable d) { if (c == backCommand) { midlet.mainMenuScreenShow(); return; }}}  10
  • 11. Eliminator: Terrain (Scrolling Background) private TiledLayer loadTerrain() throws Exception { Image tileImages = Image.createImage("/terrain.png"); TiledLayer tiledLayer = new TiledLayer(TILE_NUM_COL,TILE_NUM_ ROW,tileImages,TILE_WIDTH,TILE_HEI GHT); // Define Terrain Map int[][] map = { {0,0,0,0,0,0}, {3,0,0,0,0,0}, {6,0,0,0,0,0}, {6,0,0,0,1,2}, {6,0,0,0,4,5}, {6,0,0,0,7,8}, {6,0,0,0,0,0},{9,0,1,2,3,0}, {0,0,4,5,6,0}, {0,0,7,8,9,0},{0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0},{3,0,0,0,0,0}, {6,0,0,0,0,0}, {6,0,0,0,1,2}, {6,0,0,0,4,5}, {6,0,0,0,7,8}, {6,0,0,0,0,0}, {9,0,1,2,3,0}, {0,0,4,5,6,0}, {0,0,7,8,9,0}, {0,0,0,0,0,0},{0,0,0,0,0,0}, {0,0,0,0,0,0},{3,0,0,0,0,0}, {6,0,0,0,0,0}, {6,0,0,0,1,2},{6,0,0,0,4,5}, {6,0,0,0,7,8}, {6,0,0,0,0,0},{9,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0},{0,0,0,0,0,0}, {3,0,0,0,0,1} }; // Map Terrain Map with actual graphic from terrain.png for (int row=0; row<TILE_NUM_ROW; row++) { for (int col=0; col<TILE_NUM_COL; col++) { tiledLayer.setCell(col,row,map[row][col]); } }return tiledLayer; } Ví dụ: EliminatorScrolling 11
  • 12. Eliminator: Player , ví dụ : EliminatorPlayer Player Sprite public class PlayerSprite extends Sprite { private static final int MOVE = 3; private int x,y; private int scnWidth,scnHeight; private int frameWidth, frameHeight; private int frame; private int lives; public PlayerSprite(Image image, int frameWidth, int frameHeight, int scnWidth, int scnHeight) throws Exception { super(image, frameWidth, frameHeight); x = frameWidth/2; y = frameHeight/2; this.scnWidth = scnWidth; this.scnHeight = scnHeight; this.frameWidth = frameWidth; this.frameHeight = frameHeight; this.frame = 1; this.lives = 3;}  public void startPosition() { setPosition(scnWidth/2,scnHeight/2);} public void moveLeft() { getXY(); if (x - MOVE > 0) move(MOVE * -1,0);} public void moveRight() { getXY(); if (x + MOVE + frameWidth < scnWidth) move(MOVE,0);} public void moveUp() { getXY(); if (y - MOVE > 0) move(0,MOVE * -1);} public void moveDown() { getXY(); if (y + MOVE + frameHeight < scnHeight) move(0,MOVE);} 12