Sedang memuat Tutorial Game java ...

Tutorial Game java

Thursday, April 14th, 2016 - Java

Project Game Dorong Kotak dengan J2ME dan Netbeans – Aplikasi Game Dorong Kotak ini di gunakan untuk aplikasi mobile HP JAVA yang di buat dengan menggunakan J2ME dan Netbeans 6.0.1 sebagai editor nya. Platform yang dapat digunakan untuk membuat aplikasi mobile device seperti pada peger, telpon selular, dan PDA. J2ME juga digunakan untuk membuat berbagai macam aplikasi mobile device, seperti aplikasi game dan lain-lain.

Tujuan pembuatan game ini adalah untuk menghasilkan program aplikasi game asah otak dan menarik, serta mudah untuk digunakannya. Tujuan berikutnya adalah untuk meminimalisir opini negatif yang timbul dan meperbaiki citra game menjadi lebih baik lagi.

Berikut Diskripsi Source pembuatan Aplikasi Game Dorong Kotak.

  • Deskripsi Aplikasi
  • Membuat Project & Class
  • Menjalankan Aplikasi
  1. Diskripsi Aplikasi

Sebuah Game kecil dan sederhana bernama dorong kotak atau Push Box” ini di haruskan meletakan setiap kotak ke tempatnya masing-masing dengan cara mendorongnya.

Tampilan Aplikasi

Tampilan Aplikasi

2.  Membuat Project dan Class

  • Buka Netbeans IDE 6.0.1
  • Klik icon New Project pada menubar Netbeans,
  • Pilih Mobility dan MIDP Application.

  • Beri Nama Project : game_dorong_kotak.

  • Setelah selesai, klik tombol finish.
  • Klik Kanan pada project, Kemudian Pilih New  >> MIDlet
  • Kemudian Beri nama : MIDlet_dorong_puzzle.
  • Kemudian Klik Finish.

3. Membuat Code Program (Listing Coding).

  • Seleksi semua code yang ada di dalam MIDlet, setelah itu tekan tombol delete pada keyboard untuk menghapus code.
  • Ketikan kode berikut ini ke dalam jendela kode MIDlet_dorong_puzzle.

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class MIDlet_dorong_Puzzle extends MIDlet implements CommandListener {
Display tampil;
private kanpas KANPAS;
private nilainya SKOR;
private Screen LAYAR_SKOR;
private Screen LAYAR_LEVEL;
private Alert ALERT;
private Command undoCommand = new Command(“Undo”, Command.BACK, 1);
private Command restartCommand =
new Command(“Start Over”, Command.CANCEL, 21);
private Command exitCommand = new Command(“Exit”, Command.EXIT, 60);
private Command scoresCommand =
new Command(“Show Scores”, Command.SCREEN, 25);
private Command okCommand = new Command(“OK”, Command.OK, 30);
private Command levelCommand =
new Command(“Change Level”, Command.OK, 24);
private Command nextCommand =
new Command(“Next Level”, Command.SCREEN, 22);
private Command prevCommand =
new Command(“Previous Level”, Command.SCREEN, 23);
public MIDlet_dorong_Puzzle() {
tampil = Display.getDisplay(this);
SKOR = new nilainya();
KANPAS = new kanpas(this, SKOR);
ALERT = new Alert(“Warning”);
}
public void startApp() {
if (!SKOR.open()) {
System.out.println(“Score open failed”);
}

KANPAS.init();
KANPAS.addCommand(undoCommand);
KANPAS.addCommand(scoresCommand);
KANPAS.addCommand(restartCommand);
KANPAS.addCommand(levelCommand);
KANPAS.addCommand(exitCommand);
KANPAS.addCommand(nextCommand);
KANPAS.addCommand(prevCommand);
KANPAS.setCommandListener(this);

tampil.setCurrent(KANPAS);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
tampil.setCurrent(null);
KANPAS.destroy();
if (SKOR != null)
SKOR.close();
}
public void commandAction(Command c, Displayable s) {
if (c == undoCommand) {
KANPAS.undoMove();
} else if (c == restartCommand) {
KANPAS.restartLevel();
} else if (c == levelCommand) {
LAYAR_LEVEL = KANPAS.getLevelScreen();
LAYAR_LEVEL.addCommand(okCommand);
LAYAR_LEVEL.setCommandListener(this);
tampil.setCurrent(LAYAR_LEVEL);
} else if (c == okCommand && s == LAYAR_LEVEL) {

if (!KANPAS.gotoLevel()) {
ALERT.setString(“ERROR”);
tampil.setCurrent(ALERT, KANPAS);
} else {
tampil.setCurrent(KANPAS);
}
} else if (c == scoresCommand) {
LAYAR_SKOR = KANPAS.getScoreScreen();
LAYAR_SKOR.addCommand(okCommand);
LAYAR_SKOR.setCommandListener(this);
tampil.setCurrent(LAYAR_SKOR);
} else if (c == okCommand && s == LAYAR_SKOR) {
tampil.setCurrent(KANPAS);
} else if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
} else if (c == List.SELECT_COMMAND && s == KANPAS) {
LAYAR_SKOR = KANPAS.getScoreScreen();
LAYAR_SKOR.addCommand(okCommand);
LAYAR_SKOR.setCommandListener(this);
tampil.setCurrent(LAYAR_SKOR);
KANPAS.nextLevel(1);
} else if (c == nextCommand) {
if (!KANPAS.nextLevel(1)) {
ALERT.setString(“ERROR ” +
(KANPAS.getLevel() + 1));
tampil.setCurrent(ALERT, KANPAS);
} else {
tampil.setCurrent(KANPAS);
}
if (s == KANPAS) {
KANPAS.repaint();
}
} else if (c == prevCommand) {
if (!KANPAS.nextLevel(-1)) {
ALERT.setString(“ERROR ” +
(KANPAS.getLevel() – 1));
tampil.setCurrent(ALERT, KANPAS);
} else {
tampil.setCurrent(KANPAS);
}
if (s == KANPAS) {
KANPAS.repaint();
}

} else {
System.out.println(“ERROR ” + c);
}
}
}

NB: Kalau malas ngetik dan COpas Silahkan download disini : Surya-java
atau di sini : Surya-java

  • Hasil penambahan file pada Java netbeans terlihat seperti berikut ini :

  • Buat class baru. Klik kanan project, New, pilih Java Class. buat nama class menjadi : “kanpas”
  • seleksi semua program kanpas, tekan tombol delete pada keyboard dan ketikan code berikut:

import java.io.*;
import javax.microedition.lcdui.*;
import java.util.Timer;
import java.util.TimerTask;

class kanpas extends Canvas {
private int level = 1;
private boolean solved;

private int cell = 1;
private int w, h;
private int bwidth, bheight;

private nilai board;
private nilainya score;
private MIDlet_dorong_Puzzle pushpuzzle;
private Display display;
private Timer timer;
private TimerTask timertask;
private CommandListener listener;
private TextBox levelText;

private static int wallColor =   0x7f7f7f;
private static int groundColor = 0xffffff;
private static int packetColor = 0x000000;
private static int storeColor =  0x000000;
private static int pusherColor = 0x000000;
private static boolean useDottedLine = false;

public kanpas(MIDlet_dorong_Puzzle pushpuzzle, nilainya s) {
this.pushpuzzle = pushpuzzle;
display = Display.getDisplay(pushpuzzle);
score = s;
board = new nilai();
initColors();
}

public void init() {
h = getHeight();
w = getWidth();

level = score.getLevel();
if (!readScreen(level)) {
level = 0;
readScreen(level);
}
repaint();
}
public void destroy() {
cancelTo();
if (timer != null) {
timer.cancel();
timer = null;
}
}

private void initColors() {
boolean isColor = display.isColor();
int numColors = display.numColors();

if (isColor) {
setColors(0x006D55, 0xffffff, 0xff6d00, 0xb60055, 0x6d6dff);
} else {
if (numColors > 2) {
setColors(0x999999, 0xffffff, 0x666666, 0xbbbbbb, 0x000000);
} else {
setColors(0x6a6a6a, 0xffffff, 0x6a6a6a, 0x000000, 0x000000);
useDottedLine = true;
}
}
}

private void setColors(int w, int g, int pa, int s, int pu) {
if (w != -1)
wallColor =   w;
if (g != -1)
groundColor = g;
if (pa != -1)
packetColor = pa;
if (s != -1)
storeColor =  s;
if (pu != -1)
pusherColor = pu;
}

private int parseColor(String s) {
if (s == null)
return -1;
return Integer.parseInt(s, 16);
}

public void undoMove() {
int dir = board.undoMove();
if (dir >= 0) {
repaintNear(board.getPusherLocation(), dir);
}
solved = board.solved();
}

public void restartLevel() {
readScreen(level);
repaint();
solved = false;
}

public boolean nextLevel(int offset) {
updateScores();
if (level + offset >= 0 && readScreen(level+offset)) {
level += offset;
score.setLevel(level);
solved = false;
return true;
}
return false;
}

public int getLevel() {
return level;
}

public Screen getLevelScreen() {
if (levelText == null) {
levelText = new TextBox(“Pilih Level”,
Integer.toString(level),
4, TextField.NUMERIC);
} else {
levelText.setString(Integer.toString(level));
}
return levelText;
}

public boolean gotoLevel() {
if (levelText != null) {
String s = levelText.getString();
int l = Integer.parseInt(s);

updateScores();
if (l >= 0 && readScreen(l)) {
level = l;
score.setLevel(level);
solved = false;
repaint();
return true;
}
}
return false;
}

private boolean readScreen(int lev) {
if (lev <= 0) {
board.screen0();
} else {
InputStream is = null;
try {
is = getClass().getResourceAsStream(
“puzzle.”
+ lev);
if (is != null) {
board.read(is, lev);
is.close();
} else {
System.out.println(
“error”
+ lev);
return false;
}
} catch (java.io.IOException ex) {
return false;
}
}
bwidth = board.getWidth();
bheight = board.getHeight();

cell = ((h-14) / bheight < w / bwidth) ? (h-14) / bheight : w / bwidth;
return true;
}

public Screen getScoreScreen() {
Form wokeh = null;
int currPushes = board.getPushes();
int bestPushes = score.getPushes();
int currMoves = board.getMoves();
int bestMoves = score.getMoves();
boolean newbest = solved &&
(bestPushes == 0 || currPushes < bestPushes);

wokeh = new Form(null);

wokeh.append(new StringItem(
newbest ? “New Best:n” : “Current:n”,
currPushes + ” pushesn” +
currMoves  + ” moves”));

wokeh.append(new StringItem(
newbest ? “Old Best:n” : “Best:n”,
bestPushes + ” pushesn” +
bestMoves  + ” moves”));

String title = “Scores”;
if (newbest) {
title = “Congratulations”;
}
wokeh.setTitle(title);
return wokeh;
}

protected void keyRepeated(int keyCode) {
int action = getGameAction(keyCode);
switch (action) {
case Canvas.LEFT:
case Canvas.RIGHT:
case Canvas.UP:
case Canvas.DOWN:
keyPressed(keyCode);
break;
default:
break;
}
}

protected void keyPressed(int keyCode) {
boolean newlySolved = false;

synchronized (board) {

cancelTo();
int action = getGameAction(keyCode);
int move = 0;
switch (action) {
case Canvas.LEFT:
move = nilai.LEFT;
break;
case Canvas.RIGHT:
move = nilai.RIGHT;
break;
case Canvas.DOWN:
move = nilai.DOWN;
break;
case Canvas.UP:
move = nilai.UP;
break;

default:
return;
}

int pos = board.getPusherLocation();
int dir = board.move(move);
repaintNear(pos, dir);

if (!solved && board.solved()) {
newlySolved = solved = true;
}
}

if (newlySolved && listener != null) {
listener.commandAction(List.SELECT_COMMAND, this);
}
}

private void updateScores() {
if (!solved)
return;
int sp = score.getPushes();
int bp = board.getPushes();
int bm = board.getMoves();
if (sp == 0 || bp < sp) {
score.setLevelScore(bp, bm);
}
}

private void animateTo(int x, int y) {
if (timer == null)
timer = new Timer();

if (timertask != null) {
timertask.cancel();
timertask = null;
}
timertask = new om_waktu(this, board, x, y);
timer.schedule(timertask, (long)100, (long)100);
}

private void cancelTo() {
if (timertask != null)
timertask.cancel();
}

protected void pointerPressed(int x, int y) {
animateTo(x/cell, y/cell);
}

public void setCommandListener(CommandListener l) {
super.setCommandListener(l);
listener = l;
}

void repaintNear(int loc, int dir) {
int x = loc & 0x7fff;
int y = (loc >> 16) & 0x7fff;

int size = 1;
if (dir >= 0) {
size += 1;
if ((dir & nilai.MOVEPACKET) != 0) {
size += 1;
}
}
int dx = 1;
int dy = 1;
switch (dir & 3) {
case nilai.UP:
y -= size-1;
dy = size;
break;
case nilai.DOWN:
dy = size;
break;
case nilai.RIGHT:
dx = size;
break;
case nilai.LEFT:
x -= size-1;
dx = size;
break;
}
repaint(x * cell, y * cell, dx * cell, dy * cell);
}

protected void paint(Graphics g) {

synchronized (board) {

int x = 0, y =  0, x2 = bwidth, y2 = bheight;

int clipx = g.getClipX();
int clipy = g.getClipY();
int clipw = g.getClipWidth();
int cliph = g.getClipHeight();
x = clipx / cell;
y = clipy / cell;
x2 = (clipx + clipw + cell-1) / cell;
y2 = (clipy + cliph + cell-1) / cell;
if (x2 > bwidth)
x2 = bwidth;
if (y2 > bheight)
y2 = bheight;

g.setColor(groundColor);
g.fillRect(0, 0, w, h);

for (y = 0; y < y2; y++) {
for (x = 0; x < x2; x++) {
byte v = board.get(x, y);
switch (v & ~nilai.PUSHER) {
case nilai.WALL:
g.setColor(wallColor);
g.fillRect(x*cell, y*cell, cell, cell);
break;

case nilai.PACKET:
case nilai.PACKET | nilai.STORE:
g.setColor(packetColor);
g.fillRect(x*cell+1, y*cell+1, cell-2, cell-2);
break;
case nilai.STORE:
g.setColor(storeColor);
if (useDottedLine) {
g.setStrokeStyle(Graphics.DOTTED);
}
g.drawRect(x*cell+1, y*cell+1, cell-2, cell-2);
break;

case nilai.GROUND:
default:

break;
}
if ((v & nilai.PUSHER) != 0) {
g.setColor(pusherColor);
g.fillArc(x*cell, y*cell, cell, cell, 0, 360);
}
}
}
g.drawString(“Dorong Kotak Level ” + level, 0, h-14,
Graphics.TOP|Graphics.LEFT);
}
}
}

NB : Download Source Code nya yang saya ketik di notepad disini : kanpas.TXT
Kalau source code nya yang sudah saya jalan kan dan di ketik di netbeans disini kanpas.Java

  • Selanjut nya buat class baru, cara nya sama. Buat nama class nya “nilai“, dan ketik source nya di bawah ini: 

import javax.microedition.lcdui.*;

public class nilai {
private int level;
private byte[] array;
private byte[] pathmap;
private int width, height;
private int pusher;
private int packets = 0;
private int stored = 0;
private byte[] moves;
private int nmoves;
private int npushes;

public static final int LEFT = 0;
public static final int RIGHT = 3;
public static final int UP = 1;
public static final int DOWN = 2;
public static final int MOVEPACKET = 4;

public static final byte GROUND = 0;
public static final byte STORE = 1;
public static final byte PACKET = 2;
public static final byte WALL = 4;
public static final byte PUSHER = 8;

public nilai() {
moves = new byte[200];
screen0();
}

public void screen0() {
width = 9;
height = 7;
array = new byte[width * height];
level = 0;
nmoves = 0;
npushes = 0;
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
byte t = (x == 0 || y == 0 ||
x == width – 1 || y == height – 1) ?
WALL : GROUND;
set(x, y, t);
}
}
packets = 2;
stored = 0;
set(2, 2, PACKET);
set(4, 4, PACKET);
set(4, 2, STORE);
set(6, 4, STORE);
pusher = index(1, 1);
}

public int move(int move) {
int obj = pusher + indexOffset(move);
if ((array[obj] & WALL) != 0)
return -1;

int m = movePacket(obj, move);
if (m < 0)
return -1;

pusher = obj;
saveMove(m);
return m;
}

private int movePacket(int index, int move) {
if ((array[index] & PACKET) == 0)
return move;

int dest = index + indexOffset(move);
if (array[dest] > STORE)
return -1;

array[index] &= ~PACKET;
if ((array[index] & STORE) != 0)
stored–;

array[dest] |= PACKET;
if ((array[dest] & STORE) != 0)
stored++;

npushes++;
return move + MOVEPACKET;
}

private void saveMove(int move) {
if (nmoves >= moves.length) {
byte[] n = new byte[moves.length + 50];
System.arraycopy(moves, 0, n, 0, moves.length);
moves = n;
}
moves[nmoves++] = (byte)move;
}

public int undoMove() {
if (nmoves <= 0)
return -1;
int move = moves[–nmoves];
int rev = (move & 3) ^ 3;
int back = pusher + indexOffset(rev);

if ((move & MOVEPACKET) != 0) {
npushes–;
movePacket(pusher + indexOffset(move), rev);
}
pusher = back;
return move;
}

public boolean solved() {
return packets == stored;
}

public int runTo(int x, int y, int max) {
int target = index(x, y);
if (target < 0 || target >= array.length)
return -1;
if (target == pusher)
return -1;

if (pathmap == null || pathmap.length != array.length) {
pathmap = new byte[array.length];
}

for (int i = 0; i < pathmap.length; i++)
pathmap[i] = 127;

findTarget(target, (byte)0);

if (pathmap[pusher] == 127) {
return -1;
} else {

int pathlen = pathmap[pusher];
int pathmin = pathlen – max;
int dir = -1;
for (pathlen–; pathlen >= pathmin; pathlen–) {
if (pathmap[pusher – 1] == pathlen) {
dir = LEFT;
saveMove(dir);
pusher–;
} else if (pathmap[pusher + 1] == pathlen) {
dir = RIGHT;
saveMove(dir);
pusher++;
} else if (pathmap[pusher – width] == pathlen) {
dir = UP;
saveMove(dir);
pusher -= width;
} else if (pathmap[pusher + width] == pathlen) {
dir = DOWN;
saveMove(dir);
pusher += width;
} else {

throw new RuntimeException(“runTo abort”);
}
}
return dir;
}
}

private void findTarget(int t, byte pathlen) {
if (array[t] > STORE)
return;

if (pathmap[t] <= pathlen)
return;

pathmap[t] = pathlen++;
if (t == pusher)
return;

findTarget(t – 1, pathlen);
findTarget(t + 1, pathlen);
findTarget(t – width, pathlen);
findTarget(t + width, pathlen);
}

public byte get(int x, int y) {
int offset = index(x, y);
if (offset == pusher)
return (byte)(array[offset] | PUSHER);
else
return array[offset];
}

private void set(int x, int y, byte value) {
array[index(x, y)] = value;
}

private int index(int x, int y) {
if (x < 0 || x >= width ||
y < 0 || y >= height)
return -1;

return y * width + x;
}

public int getPusherLocation() {
int x = pusher % width;
int y = pusher / width;
return (y << 16) + x;
}

private int indexOffset(int move) {
switch (move & 3) {
case LEFT:
return -1;
case RIGHT:
return +1;
case UP:
return -width;
case DOWN:
return +width;
}
return 0;
}

public void read(java.io.InputStream is, int l) {
final int W = 20;
final int H = 20;
byte[] b = new byte[W * H];

int c, w = 0;
int x = 0, y = 0, xn = 0, yn = 0, npackets = 0;
try {
while ((c = is.read()) != -1) {
switch (c) {
case ‘n’:
if (x > w) {
w = x;
}

y++;
x = 0;
break;

case ‘$’:
b[y * W + x++] = PACKET;
npackets++;
break;

case ‘#’:
b[y * W + x++] = WALL;
break;

case ‘ ‘:
b[y * W + x++] = GROUND;
break;

case ‘.’:
b[y * W + x++] = STORE;
break;

case ‘+’:
b[y * W + x++] = STORE;
case ‘@’:
xn = x;
yn = y;
x++;
break;
}
}
} catch (java.io.IOException ex) {
ex.printStackTrace();
}

if (y > 0) {
array = new byte[w * y];
if (y > w) {
width = y;
height = w;
for (y = 0; y < width; y++) {
for (x = 0; x < w; x++) {
array[index(y, x)] = b[y * W + x];
}
}
pusher = index(yn, xn);
} else {
width = w;
height = y;
array = new byte[width * height];
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
array[index(x, y)] = b[y * W + x];
}
}
pusher = index(xn, yn);
}
stored = 0;
packets = npackets;
level = l;
nmoves = 0;
npushes = 0;
}
}

public int getWidth() {
return width;
}

public int getHeight() {
return height;
}

public int getMoves() {
return nmoves;
}

public int getPushes() {
return npushes;
}

private int dx(int dir) {
if (dir == LEFT)
return -1;
if (dir == RIGHT)
return +1;
return 0;
}

private int dy(int dir) {
if (dir == UP)
return -1;
if (dir == DOWN)
return +1;
return 0;
}
}

NB: Bagi yang suka download silahkan downlod source code yang saya ketik di notepad: DiSini nilai.Txt
Dan Source code nya yang saya ketik di Netbeans IDE, Download file nya: nilai.java

  • Buat java class baru dengan nama : “nilainya”. Dan ketikan code berikut:

import javax.microedition.rms.*;
class nilainya {
private int t;
private byte[] h;
private static final int LEVEL_LEN = 5;
private static final byte LEVEL_TAG = 1;
private int gh;
private byte[] jh;
private static final int SCORE_LEN = 13;
private static final byte SCORE_TAG = 2;
private RecordStore ghk;
nilainya() {
ghk = null;
t = 0;
h = new byte[LEVEL_LEN];
h[0] = LEVEL_TAG;
putInt(h, 1, 0);
gh = 0;
jh = new byte[SCORE_LEN];
jh[0] = SCORE_TAG;
putInt(jh, 1, 0);
}
boolean open() {
try {
ghk = RecordStore.openRecordStore(“PushPuzzleScores”, true);
} catch (RecordStoreException ex) {
}

if (ghk == null)
return false;

try {
t = 0;
RecordEnumeration en = ghk.enumerateRecords(null, null, false);
while (en.hasNextElement()) {
int ndx = en.nextRecordId();
if (ghk.getRecordSize(ndx) == LEVEL_LEN) {
int l = ghk.getRecord(ndx, h, 0);
if (l == LEVEL_LEN &&
h[0] == LEVEL_TAG) {
t = ndx;
break;
}
}
}
} catch (RecordStoreException ex) {
ex.printStackTrace();
return false;
}

return true;
}
int getLevel() {
return getInt(h, 1);
}
boolean setLevel(int level) {
putInt(h, 1, level);
putInt(jh, 1, level);
if (ghk == null)
return false;
try {
if (t == 0) {
t = ghk.addRecord(h, 0, h.length);
} else {
ghk.setRecord(t, h, 0, h.length);
}
} catch (RecordStoreException ex) {
System.out.println(“RecordStoreException”);
ex.printStackTrace();
return false;
}
readScore(level);
return true;
}
int getPushes() {
return getInt(jh, 5);
}
int getMoves() {
return getInt(jh, 9);
}
boolean readScore(int level) {
try {
gh = 0;
RecordEnumeration en = ghk.enumerateRecords(null, null, false);
while (en.hasNextElement()) {
int ndx = en.nextRecordId();
if (ghk.getRecordSize(ndx) == SCORE_LEN) {
int l = ghk.getRecord(ndx, jh, 0);
if (l == SCORE_LEN &&
jh[0] == SCORE_TAG &&
getInt(jh, 1) == level) {
gh = ndx;
return true;
}
}
}
} catch (RecordStoreException ex) {
ex.printStackTrace();
return false;
}

jh[0] = SCORE_TAG;
putInt(jh, 1, level);
putInt(jh, 5, 0);
putInt(jh, 9, 0);
return true;
}

boolean setLevelScore(int pushes, int moves) {

putInt(jh, 5, pushes);
putInt(jh, 9, moves);

try {

if (gh == 0) {
gh = ghk.addRecord(jh, 0, jh.length);
} else {
ghk.setRecord(gh, jh, 0, jh.length);
}

} catch (RecordStoreException ex) {
ex.printStackTrace();
return false;
}
return true;
}

private int getInt(byte[] buf, int offset) {
return (buf[offset+0] & 0xff) << 24 |
(buf[offset+1] & 0xff) << 16 |
(buf[offset+2] & 0xff) << 8 |
(buf[offset+3] & 0xff);
}

private void putInt(byte[] buf, int offset, int value) {
buf[offset+0] = (byte)((value >> 24) & 0xff);
buf[offset+1] = (byte)((value >> 16) & 0xff);
buf[offset+2] = (byte)((value >>  8) & 0xff);
buf[offset+3] = (byte)((value >>  0) & 0xff);
}

void close() {
try {
if (ghk != null) {
ghk.closeRecordStore();
}
} catch (RecordStoreException ex) {
ex.printStackTrace();
}
}

}


NB: Bagi yang suka download silahkan downlod source code yang saya ketik di notepad: DiSini nilainya.Txt
Dan Source code nya yang saya ketik di Netbeans IDE, Download file nya: nilainya.java

  • Buat Class baru lagi dan cara nya masih sama seperti tadi, buat dengan nama: “om_waktu”.  Dan ketikan program berikut:

import java.util.TimerTask;
class om_waktu extends TimerTask {
int x, y;
nilai papan;
kanpas canvas;
om_waktu(kanpas c, nilai b, int x, int y) {
canvas = c;
papan = b;
this.x = x;
this.y = y;
}
public void run() {
try {
int pos = papan.getPusherLocation();
int dir = papan.runTo(x, y, 1);
if (dir < 0) {
cancel();
} else {
canvas.repaintNear(pos, dir);
}
} catch (Exception ex) {

}
}
}

NB: Bagi yang suka download silahkan downlod source code yang saya ketik di notepad: om_waktu.txt
Dan Source code nya yang saya ketik di Netbeans IDE, Download file nya: om_waktu.java

Keterangan:
Jika anda bingung atau terlalu susah membuat java class dari : kanpas.java, nilai.java, nilainya.java, dan om_waktu.java , serta menempatkan file puzzle nya, maka anda tidak perlu membuat dan mengetik.
Anda cukup mengetik program (source code) : ” MIDlet_dorong_kotak ” saja. dan yang lain cukup downloand file dari :

Setelah di download semua file, extarck file tersebut. Dan semua file yang di extract tadi copy pastekan di folder : ” E:Documents and SettingsAcer TM4750My DocumentsNetBeansProjectsgame_dorong_kotaksrc ” lihat gambar berikut.

4. Menjalankan program.

………..Next……

Incoming search terms:

  • download aplikasi 3g konventer java
  • allinurl: FLASH s0
  • download sertifikat pengguna
  • download sertifikat bb
  • download pembaruan nirkabel andromax a
  • framaroot j110g
  • cara mode melalui *#*#4636#*#*
  • cara masuk download mode coolpad e570
  • Busybox vivo y15
  • Huiyeee Download Tool
  • fileroot zip download
  • driver usb coolpad e502
  • kingroot apk for polytron r2507
  • vivi v5 1601 update file download com
  • download tema buat mito a230
  • download king root for bbz10
  • download fileroot zip
  • donwload kingroot buat polytron 2507
  • custom rom blackberry untuk max c2 new
  • Aplikasi java perubah tampilan jaringan
Tutorial Game java | Puji Asro | 4.5
/* */