📄 tetrisgame.java
字号:
package javagapi;
import java.io.IOException;
import java.io.DataOutputStream;
import java.io.DataInputStream;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Font;
/**
* (C) 2002 Sony Ericsson Mobile Communications AB. All rights reserved.
*
* This java code has been automatically generated by a syntax tree
* analyzer from the embedded C source code.
*
* @author LD/SEM/GUN/MI Stefan Olsson
*
* @version 1.0
*/
class TetrisGame extends GameShell {
Image Image_8bit_256 = null ;
Image Image_8bit_257 = null ;
Image Image_8bit_258 = null ;
Image Image_8bit_259 = null ;
Image Image_8bit_260 = null ;
Image Image_8bit_261 = null ;
Image Image_8bit_262 = null ;
Image Image_8bit_263 = null ;
Image Image_8bit_264 = null ;
Image Image_8bit_265 = null ;
Image Image_8bit_266 = null ;
Image Image_8bit_267 = null ;
public String getGameName() {
return "Tetris";
}
public boolean loadImages ( ) {
try {Image_8bit_256 = Image.createImage("/tetris/Image_8bit_257.png"); } catch(IOException ex) {return false;}
try {Image_8bit_257 = Image.createImage("/tetris/Image_8bit_257.png"); } catch(IOException ex) {return false;}
try {Image_8bit_258 = Image.createImage("/tetris/Image_8bit_258.png"); } catch(IOException ex) {return false;}
try {Image_8bit_259 = Image.createImage("/tetris/Image_8bit_259.png"); } catch(IOException ex) {return false;}
try {Image_8bit_260 = Image.createImage("/tetris/Image_8bit_260.png"); } catch(IOException ex) {return false;}
try {Image_8bit_261 = Image.createImage("/tetris/Image_8bit_261.png"); } catch(IOException ex) {return false;}
try {Image_8bit_262 = Image.createImage("/tetris/Image_8bit_262.png"); } catch(IOException ex) {return false;}
try {Image_8bit_263 = Image.createImage("/tetris/Image_8bit_263.png"); } catch(IOException ex) {return false;}
try {Image_8bit_264 = Image.createImage("/tetris/Image_8bit_264.png"); } catch(IOException ex) {return false;}
try {Image_8bit_265 = Image.createImage("/tetris/Image_8bit_265.png"); } catch(IOException ex) {return false;}
try {Image_8bit_266 = Image.createImage("/tetris/Image_8bit_266.png"); } catch(IOException ex) {return false;}
try {Image_8bit_267 = Image.createImage("/tetris/Image_8bit_267.png"); } catch(IOException ex) {return false;}
return true;
}
void GACharOut ( /* uns */ int id , short x , short y )
{
switch ( id )
{
case 256 : { g.drawImage ( Image_8bit_256 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 257 : { g.drawImage ( Image_8bit_257 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 258 : { g.drawImage ( Image_8bit_258 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 259 : { g.drawImage ( Image_8bit_259 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 260 : { g.drawImage ( Image_8bit_260 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 261 : { g.drawImage ( Image_8bit_261 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 262 : { g.drawImage ( Image_8bit_262 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 263 : { g.drawImage ( Image_8bit_263 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 264 : { g.drawImage ( Image_8bit_264 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 265 : { g.drawImage ( Image_8bit_265 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 266 : { g.drawImage ( Image_8bit_266 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
case 267 : { g.drawImage ( Image_8bit_267 , x , y , Graphics.TOP|Graphics.LEFT ) ; break ; }
}
}
int GAGetCharHeight ( /* uns */ int id )
{
switch ( id )
{
case 256 : return Image_8bit_256 . getHeight ( ) ;
case 257 : return Image_8bit_257 . getHeight ( ) ;
case 258 : return Image_8bit_258 . getHeight ( ) ;
case 259 : return Image_8bit_259 . getHeight ( ) ;
case 260 : return Image_8bit_260 . getHeight ( ) ;
case 261 : return Image_8bit_261 . getHeight ( ) ;
case 262 : return Image_8bit_262 . getHeight ( ) ;
case 263 : return Image_8bit_263 . getHeight ( ) ;
case 264 : return Image_8bit_264 . getHeight ( ) ;
case 265 : return Image_8bit_265 . getHeight ( ) ;
case 266 : return Image_8bit_266 . getHeight ( ) ;
case 267 : return Image_8bit_267 . getHeight ( ) ;
}
return 0;
}
int GAGetCharWidth ( /* uns */ int id )
{
switch ( id )
{
case 256 : return Image_8bit_256 . getWidth ( ) ;
case 257 : return Image_8bit_257 . getWidth ( ) ;
case 258 : return Image_8bit_258 . getWidth ( ) ;
case 259 : return Image_8bit_259 . getWidth ( ) ;
case 260 : return Image_8bit_260 . getWidth ( ) ;
case 261 : return Image_8bit_261 . getWidth ( ) ;
case 262 : return Image_8bit_262 . getWidth ( ) ;
case 263 : return Image_8bit_263 . getWidth ( ) ;
case 264 : return Image_8bit_264 . getWidth ( ) ;
case 265 : return Image_8bit_265 . getWidth ( ) ;
case 266 : return Image_8bit_266 . getWidth ( ) ;
case 267 : return Image_8bit_267 . getWidth ( ) ;
}
return 0;
}
///* static */ void TetrisKillGame ( ) ;
//void TerminateGameMain ( ) ;
//Font_t SystemFontTetrisBitmaps_8bit = new Font_t () ;
/* static */ final int [] TE_BOX_FILL_COLOR /* expr */ = {
GACOLOR_GRAY ,
GACOLOR_CYAN ,
GACOLOR_GREEN ,
GACOLOR_RED ,
GACOLOR_BLUE ,
GACOLOR_PURPLE ,
GACOLOR_YELLOW ,
GACOLOR_DARK_GRAY
} ;
final int [] g_nScoreLayer /* expr */ = { 0 , 50 , 200 , 400 , 1000 } ;
final int [] g_nScoreLayerBonus /* expr */ = { 0 , 30 , 100 , 200 , 500 } ;
final /* uns */ int [] g_nNextLevel /* expr */ = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100 } ;
final /* uns */ int [] g_nStartSpeeds /* expr */ = { 1000 , 900 , 800 , 700 , 600 , 500 , 400 , 300 , 200 , 100 } ;
final /* uns */ int [] [] [] g_Shapes /* expr */ /* expr */ /* expr */ = { { { 0 , 24 , 24 , 0 } ,
{ 0 , 24 , 24 , 0 } ,
{ 0 , 24 , 24 , 0 } ,
{ 0 , 24 , 24 , 0 } }
,
{ { 16 , 16 , 16 , 16 } ,
{ 0 , 60 , 0 , 0 } ,
{ 16 , 16 , 16 , 16 } ,
{ 0 , 60 , 0 , 0 } }
,
{ { 0 , 12 , 24 , 0 } ,
{ 16 , 24 , 8 , 0 } ,
{ 0 , 12 , 24 , 0 } ,
{ 16 , 24 , 8 , 0 } }
,
{ { 0 , 24 , 12 , 0 } ,
{ 8 , 24 , 16 , 0 } ,
{ 0 , 24 , 12 , 0 } ,
{ 8 , 24 , 16 , 0 } }
,
{ { 24 , 16 , 16 , 0 } ,
{ 0 , 56 , 8 , 0 } ,
{ 16 , 16 , 48 , 0 } ,
{ 32 , 56 , 0 , 0 } }
,
{ { 24 , 8 , 8 , 0 } ,
{ 4 , 28 , 0 , 0 } ,
{ 8 , 8 , 12 , 0 } ,
{ 0 , 28 , 16 , 0 } }
,
{ { 16 , 24 , 16 , 0 } ,
{ 0 , 56 , 16 , 0 } ,
{ 16 , 48 , 16 , 0 } ,
{ 16 , 56 , 0 , 0 } }
} ;
/* typedef struct */ class
Shape {
public int xShift ;
public /* uns */ int bottomY ;
public int chShape ;
public /* uns */ int chRotation ;
public /* uns */ int [] chFigure = new int [ 4 ] ;
}
;
/* typedef struct */ class
NextShape {
public int chNShape ;
public int chNRotation ;
}
;
/* typedef struct */ class
SaveGame implements GameSaveable{
public int xShift ;
public /* uns */ int bottomY ;
public /* uns */ int chShapeAndRotation ;
public /* uns */ int chNextShape ;
public /* uns */ int [] chScoreAndStartLevel = new int [ 3 ] ;
public /* uns */ int chBlockCnt ;
public /* uns */ int chLevel ;
public /* uns */ int [] chPlFld = new int [ 22 ] ;
public /* uns */ int BackGroundPicSelection ;
public void serialize( DataOutputStream dos ) throws IOException {
dos.writeInt(xShift);
dos.writeInt(bottomY);
dos.writeInt(chShapeAndRotation);
dos.writeInt(chNextShape);
for(int i = 0; i<3; i++)
dos.writeInt(chScoreAndStartLevel[i]);
dos.writeInt(chBlockCnt);
dos.writeInt(chLevel);
for(int i = 0; i<22; i++)
dos.writeInt(chPlFld[i]);
dos.writeInt(BackGroundPicSelection);
}
public void unSerialize( DataInputStream dis ) throws IOException {
xShift = dis.readInt();
bottomY = dis.readInt();
chShapeAndRotation = dis.readInt();
chNextShape = dis.readInt();
for(int i = 0; i<3; i++)
chScoreAndStartLevel[i] = dis.readInt();
chBlockCnt = dis.readInt();
chLevel = dis.readInt();
for(int i = 0; i<22; i++)
chPlFld[i] = dis.readInt();
BackGroundPicSelection = dis.readInt();
}
}
;
/* typedef struct */ class
TE_EEArray_t implements GameSaveable{
public /* uns */ int chInfo ;
public GAPI_HighscoreEntry_t HighScoreListEntries = new GAPI_HighscoreEntry_t () ;
public boolean SoundOn ;
public SaveGame sgSaveGame = new SaveGame () ;
public void serialize( DataOutputStream dos ) throws IOException {
dos.writeInt(chInfo);
HighScoreListEntries.serialize(dos);
dos.writeBoolean(SoundOn);
sgSaveGame.serialize(dos);
}
public void unSerialize( DataInputStream dis ) throws IOException {
chInfo = dis.readInt();
HighScoreListEntries.unSerialize(dis);
SoundOn = dis.readBoolean();
sgSaveGame.unSerialize(dis);
}
}
;
/* NPOINTERGROUP */ TE_EEArray_t TE_SaveData_p = null ;
final int [] g_blocks /* expr */ = { 5 , 6 , 5 , 6 , 2 , 5 } ;
private int Letter_cc = 0; //constructor count
class
Letter {
public int[] x_pos ;
public int[] y_pos ;
public int[] y_stop ;
public int[] shape ;
public int[] rotation ;
public Letter() {
Letter_cc++;
//System.out.println("class TetrisGame.Letter creating Letter "+Letter_cc);
switch(Letter_cc) {
case 1: {
x_pos = x_pos1;
y_pos = y_pos1;
y_stop = y_stop1;
shape = shape1;
rotation = rotation1;
break;
}
case 2:{
x_pos = x_pos2;
y_pos = y_pos2;
y_stop = y_stop2;
shape = shape2;
rotation = rotation2;
break;
}
case 3:{
x_pos = x_pos3;
y_pos = y_pos3;
y_stop = y_stop3;
shape = shape3;
rotation = rotation3;
break;
}
case 4:{
x_pos = x_pos4;
y_pos = y_pos4;
y_stop = y_stop4;
shape = shape4;
rotation = rotation4;
break;
}
case 5:{
x_pos = x_pos5;
y_pos = y_pos5;
y_stop = y_stop5;
shape = shape5;
rotation = rotation5;
break;
}
case 6:{
x_pos = x_pos6;
y_pos = y_pos6;
y_stop = y_stop6;
shape = shape6;
rotation = rotation6;
break;
}
}
}
}
final int [] x_pos1 /* expr */ = { 1 - 2 , 2 - 3 , 0 - 3 , 1 - 2 , 3 - 3 } ;
final int [] x_pos2 /* expr */ = { ( 0 - 2 ) , ( 3 - 3 ) , ( 0 - 3 ) , ( 1 - 2 ) , ( 0 - 3 ) , ( 1 - 2 ) } ;
final int [] x_pos3 /* expr */ = { 1 - 2 , 2 - 3 , 0 - 3 , 1 - 2 , 3 - 3 } ;
final int [] x_pos4 /* expr */ = { 0 - 3 , 3 - 3 , 0 - 3 , 3 - 3 , 0 - 3 , 2 - 2 } ;
final int [] x_pos5 /* expr */ = { 0 - 3 , 0 - 3 } ;
final int [] x_pos6 /* expr */ = { 0 - 4 , 2 - 3 , 2 - 3 , 0 - 3 , 1 - 3 } ;
final int [] y_pos1 /* expr */ = { 13 , 22 , 59 , 35 , 48 } ;
final int [] y_pos2 /* expr */ = { 10 , 24 , 37 , 50 , 57 , 66 } ;
final int [] y_pos3 /* expr */ = { 20 , 27 , 52 , 42 , 62 } ;
final int [] y_pos4 /* expr */ = { 19 , 12 , 29 , 37 , 56 , 60 } ;
final int [] y_pos5 /* expr */ = { 43 , 58 } ;
final int [] y_pos6 /* expr */ = { 37 , 19 , 26 , 42 , 67 } ;
final int [] y_stop1 /* expr */ = { 1 , 5 , 7 , 7 , 7 } ;
final int [] y_stop2 /* expr */ = { 1 , 2 , 4 , 4 + 1 , 7 , 7 + 1 } ;
final int [] y_stop3 /* expr */ = { 1 , 5 , 7 , 7 , 7 } ;
final int [] y_stop4 /* expr */ = { 3 , 2 , 4 + 1 , 5 , 7 , 7 + 1 } ;
final int [] y_stop5 /* expr */ = { 3 , 7 } ;
final int [] y_stop6 /* expr */ = { 2 , 1 + 1 , 3 + 1 , 5 + 1 , 7 + 1 } ;
final int [] shape1 /* expr */ = { 6 , 1 , 4 , 6 , 5 } ;
final int [] shape2 /* expr */ = { 4 , 0 , 6 , 1 , 6 , 1 } ;
final int [] shape3 /* expr */ = { 6 , 1 , 4 , 6 , 5 } ;
final int [] shape4 /* expr */ = { 1 , 5 , 3 , 3 , 4 , 4 } ;
final int [] shape5 /* expr */ = { 1 , 1 } ;
final int [] shape6 /* expr */ = { 5 , 2 , 3 , 3 , 2 } ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -