import com.sun.kjava.*; public class Iceblox extends Spotlet implements Runnable{ static Bitmap maskBitmap = new Bitmap(new short[] { 160, 16, 20, 0, 0, 0, 0, 0, 2064, -1537, -2305, -1025, -1, 0, -1, -32767, -32767, -32767, 3120, -3969, -3201, -1, -1, 0, -1, 1088, 1992, 10410, 4680, -8161, -7873, -2177, -1, 0, -1, 2049, 6321, 5461, 5736, -16377, -8177, -3265, -1153, 32312, -1, 4356, 8744, 10926, 3120, -14317, -8185, -8177, -3777, 32380, -1, 8193, 10889, 21589, 15416, -29647, -14317, -8185, -4081, 32510, -1, 17424, 25604, 2730, 8260, -28087, -29645, -14317, -8185, 28910, -1, 1, 18605, 21845, 8260, -27032, -28087, -29647, -14319, 31982, -1, 4160, 27172, 10915, 12356, 3120, 5737, 4681, -29647, 16110, -1, 1, 18605, 21877, 3140, 1, 3120, 5736, 4680, 3822, -1, 16642, 24644, 10914, 1092, -32767, 0, 3120, 5736, 32510, -1, 5, 10889, 16725, 1092, -32767, -32767, 0, 3120, 31868, -1, 1032, 8744, 10890, 14392, -16381, -32767, -32768, 0, 30776, -1, 17, 22705, 22359, 0, -8185, -16381, -32767, 0, 0, -1, 4128, 1984, 2794, 0, -4081, -8185, -16381, -32767, 0, -1, 65, 1, 21845, 0, -961, -2017, -4081, -4089, 0, -1, -21845, -21845, -21845 }); final short bitdata[][]= {{16, 16, 2, 0, 0, 0, 0, 0, 0, 960, 1440, 1440, 3696, 7224, 15996, 15804, 31806, 30750, 22554, 19506, 4080, 7224, 15996, 0}, {16, 16, 2, 0, 0, 0, 0, 0, -961, -1057, -2065, -2065, -12301, -16387, -16387, 32766, 32766, 24570, 24570, -20491, -2065, -2017, -3697, -15997}, {16, 16, 2, 0, 0, 0, 0, 0, -961, -1057, -2065, -12305, -16397, 32763, 32765, 32765, 24574, 24574, -24582, -4110, -6163, -16369, -3129, -125}, {16, 16, 2, 0, 0, 0, 0, 0, -961, -1057, -2065, -2061, -12291, -8194, -16386, -16386, 32762, 32762, 24569, 20471, -18457, -4093, -7217, -15873}, {16, 16, 2, 0, 0, 0, 0, 0, -961, -1057, -2641, -2641, -12685, -17347, -16771, 32190, 31806, 22554, 22554, -22507, -3025, -1441, -3697, -15997}, {16, 16, 2, 0, 0, 0, 0, 0, -961, -1057, -2641, -12881, -16781, 31803, 32381, 32189, 23614, 22558, -26598, -6126, -3027, -15793, -3641, -125}, {16, 16, 2, 0, 0, 0, 0, 0, -961, -1057, -2641, -2637, -12675, -9154, -16770, -16962, 31802, 30746, 22553, 18455, -19409, -3517, -7281, -15873}, {16, 16, 2, 0, 0, 0, 0, 0, -1985, -2081, -5153, -5137, -30729, 2043, -5125, -15875, -15875, -16131, -16322, -7986, -3979, -991, -481, -1009}, {16, 16, 2, 0, 0, 0, 0, 0, -1985, -2081, -5153, -5137, -30729, 2043, -5125, -15875, -15875, -15883, -16138, -8074, -3987, -957, -3961, -8177}, {16, 16, 2, 0, 0, 0, 0, 0, -1985, -2081, -5153, -5137, -30729, 2043, -5125, -15875, -15875, -15883, -15890, -7970, -4035, 99, -31231, -6201}, {16, 16, 2, 0, 0, 0, 0, 0, -993, -1041, -1065, -2089, -4127, -8224, -8233, -16509, -16509, -16637, 31747, 29447, -20977, -31681, -1921, -4033}, {16, 16, 2, 0, 0, 0, 0, 0, -993, -1041, -1065, -2089, -4127, -8224, -8233, -16509, -16509, -20605, 28419, 28167, -18929, -15809, -7921, -4089}, {16, 16, 2, 0, 0, 0, 0, 0, -993, -1041, -1065, -2089, -4127, -8224, -8233, -16509, -16509, -20605, 30595, 31495, -17393, -14848, -32671, -7193}, {16, 16, 2, 0, 0, 0, 0, 0, -961, -17443, 21930, 26022, 28278, 31806, 32382, 32190, -17347, -18403, -10213, -6121, -3025, -1441, -3697, -15997}, {16, 16, 2, 0, 0, 0, 0, 0, -961, -2017, -1441, -1441, -6121, -13261, -10645, -28279, -17347, -19891, -17347, -17827, -961, -1441, -1057, -15997}, {16, 16, 2, 0, 0, 0, 0, 0, -1, -961, -1985, -1505, -5537, -13229, -9157, -10647, -3699, -17345, -17842, -19267, -18309, -5009, -2081, -15997} , {16, 16, 2, 0, 0, 0, 0, 0, -1, -1, -897, -1985, -1505, -5537, -9121, -27605, -18839, -1635, -10163, -11329, -17284, -18317, -4897, -15421}, {16, 16, 2, 0, 0, 0, 0, 0, -1, -1, -1, -1, -897, -1985, -1505, -3505, -12213, -17349, 13933, 24974, -12449, -9988, -21455, -15805}, {16, 16, 2, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -961, -2017, -3505, -11697, -22505, -31193, 22747, -21455, -15806}, {16, 16, 2, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -961, -2017, -4081, -11697, -30123, 22059, -22063, 16962 }}; Bitmap logo = new Bitmap(new short[] { 128, 37, 16, 0, 0, 0, 0, 0, -1, -1345, -5462, -1361, -1, -1, -1, -1, -2561, -10915, 21845, 30039, -1, -1, -2561, -1, -5385, -21842, -21846, -5461, -5121, -81, -1345, -1, -10801, 21853, 21845, 30037, -10753, -683, -2721, -1, -21810, -21842, -21846, -5462, -5241, -5462, -17746, 32767, 21885, 21853, 21845, 30037, 30087, -10923, 23900, 32255, -21766, -21826, -21846, -5462, -5245, -21846, -21842, 31423, -10891, 21869, 22527, -10283, 30083, 21845, 23894, -2721, -21782, -20498, -20481, -20502, -5434, -21846, -20817, -5441, -10891, 24525, 22487, 22229, 30151, 21845, 22359, -10881, -21782, -17394, -21842, -21590, -5426, -21766, -20822, -21777, -10763, 22541, 21847, 21845, -2611, 22015, 22357, 21959, -5398, -18418, -21842, -21846, -5426, -21625, -21590, -21629, -10795, 28685, 21847, 21845, 30157, 22275, 22357, 22275, -5398, -20418, -21842, -21846, -17718, -20991, -20822, -17393, -2603, 22653, 21847, 21973, 24013, 22025, -8875, 30735, -5398, -18306, -21761, -21510, -17718, -20961, -17750, -4065, -2699, 24317, 22523, 22333, 24013, 22079, 30037, 24639, -1302, -20482, -20605, -20966, -20786, -21697, -5462, -20353, -2699, 22013, 22011, 22045, 24061, 22462, -10923, 28799, -1350, -21826, -21825, -20678, -20737, -5123, -21830, -18305, -2723, 21853, 21847, -10251, 23895, -2697, 21885, 22591, -1346, -21826, -21845, -21526, -17750, -5458, -21762, -21441, -673, 21853, 21845, 21845, 23893, 30045, 21965, 23583, -1361, -21842, -21845, -21846, -17750, -5458, -21618, -20977, -681, -2721, 21847, 21845, 30037, -10921, 22285, 22031, -1365, -1361, -1365, -21846, -5462, -5457, -20978, -21753, -673, 8188, -9, -2731, -683, -17067, -2553, 22279, -2, 4032, 4094, 16063, -16469, -24913, -1017, -253, -32, 0, 30, 2046, 1013, 2047, -29681, -8189, -256, 0, 0, 480, 127, 248, 31, -4095, -256, 0, 0, 24576, 4111, 0, 31, -4095, -128, 24576, 0, 30720, 15360, 0, 63, -2048, -125, -2041, -2048, 32643, -64, 497, -1985, -2041, -1, -1, -128, -1, -4, 511, -449, -1, -1, -1, -8, -1, -1, -15873, -1, -1, -1, -1, -1, -1, -1, -1025, -1, -1 }); static Graphics g = Graphics.getGraphics(); static Button exitButton = new Button("Exit", 138, 146); static java.util.Random random = new java.util.Random(); static final String credits="By Karl H\u00f6rnell"; static final String toStart="Press any key to start"; static final String gameOver="GAME OVER"; static final String infoStrings[]={"Control the penguin","with the bottom keys", "Push blocks of ice","by moving against them","Break blocks between", "you and another block","Beware of the","evil flames","Snuff flames with", "blocks of ice","Free all coins to","get to the next level"}; static final int blocknum[]={0,24,5,7}; static final int offsets[]={0,-12,12,-1,1}, offsX[]={0,0,0,-1,1},offsY[]={0,-1,1,0,0}, pAnim[]={4,4,4,4,1,2,1,3,4,5,4,6,7,8,9,8,10,11,12,11}, flameSteps[]={3,0,2,2,0,3,0,0,3,0,2,2,0,3,0,0}, flameMask[]={16,32,48,64,48,32},flameEyes[]={4,5,6,7,6,5}; static int map[]=new int[132],stack[]=new int[85]; static Iceblox bloxGame; static boolean initiated=false; static Bitmap pieces[]=new Bitmap[36]; static Thread game; static StringBuffer scoreBuf=new StringBuffer(14); static long nextTime=System.currentTimeMillis(),nowTime; static int toDraw[]=new int[25],numDraw; static int toMask[]=new int[60],numMask; static int i,j,k,l,m,n,dir,wantDir,lastDir,pNext,counter,dsi; static int gameMode=0,lives,score,newscore,coins,level; static int flames,flameMax; static int oDir[]=new int[10],oPos[]=new int[10],oX[]=new int[10], oY[]=new int[10],oType[]=new int[10]; public static void main(String[] args) { scoreBuf.append("SCORE: "); bloxGame=new Iceblox(); bloxGame.register(WANT_SYSTEM_KEYS); game=new Thread(bloxGame); game.start(); } public void prepareIntro() { if (!initiated) { // I have to put almost half the bitmap data in here due to a // stupid KVM bug that apparently makes the verification fail if // too much is crammed into the class constructor short extrabits[][]={ {16, 16, 2, 0, 0, 0, 0, 0, -32767, 1088, 2049, 4356, 8193, 17424, 1, 4160, 1, 16642, 5, 1032, 17, 4128, 65, -21845}, {16, 16, 2, 0, 0, 0, 0, 0, -32763, 1096, 2057, 4372, 8209, 17456, -16351, 14400, 1857, 16834, 37, 1048, 17, 4136, 73, -21841}, {16, 16, 2, 0, 0, 0, 0, 0, -31715, 1112, 3097, 5428, 8753, 17976, -15771, -1469, 8001, 17346, 357, 1592, 1041, 5176, 2141, -17745}, {16, 16, 2, 0, 0, 0, 0, 0, -31203, 1628, 3641, 5948, 8753, -14728, -3459, -1177, -189, 20418, 9061, 9848, 11313, 7224, 14429, -17745}, {16, 16, 2, 0, 0, 0, 0, 0, -29153, 3932, 7997, 14140, 26553, -14596, -3457, -1161, -29, -12350, 25573, 26232, 11889, 7288, 15485, -16705}, {16, 16, 2, 0, 0, 0, 0, 0, -29121, 8062, 16189, -132, -6147, -2306, -1153, -1, -25, -49, -3089, -2052, 32633, 15996, 15487, -16705}, {16, 16, 2, 0, 0, 0, 0, 0, -16769, 32639, -1, -4, -3, -2305, -1, -1, -1, -49, -3073, -2051, -3, 32766, 16383, -1}, {16, 16, 2, 0, 0, 0, 0, 0, -32767, 1992, 6321, 8744, 10889, 25604, 18605, 27172, 18605, 24644, 10889, 8744, 22705, 1984, 1, -21845}, {16, 16, 2, 0, 0, 0, 0, 0, -32763, 1992, 6321, 8748, 10889, 17412, -14163, 18980, 18605, 16454, 10893, 8744, 6321, 6120, 73, -21841}, {16, 16, 2, 0, 0, 0, 0, 0, -31715, 2008, 6321, 8748, 10889, 17416, -14163, -13785, 18605, 16454, 10893, 8744, 6321, 6136, 2141, -17745}, {16, 16, 2, 0, 0, 0, 0, 0, -31203, 2012, 6321, 8748, 10889, -15352, -14163, -13785, -14161, 16454, 10893, 8744, 6321, 8184, 14429, -17745}, {16, 16, 2, 0, 0, 0, 0, 0, -29153, 4060, 6325, 8748, 27273, -15356, -14161, -13785, -14161, -16314, 27277, 25128, 6321, 8184, 15485, -16705}, {16, 16, 2, 0, 0, 0, 0, 0, -29121, 8190, 6325, -7636, -5491, -15354, -14161, -13785, -14161, -16313, -5489, -7636, 22713, 16380, 15487, -16705}, {16, 16, 2, 0, 0, 0, 0, 0, -16769, 32767, -1857, -7636, -5491, -15353, -14161, -13785, -14161, -16313, -5489, -7635, -1859, 32766, 15743, -257}, {16, 16, 2, 0, 0, 0, 0, 0, -32767, 10410, 5461, 10926, 21589, 2730, 21845, 10915, 21877, 10914, 16725, 10890, 22359, 2794, 21845, -21845}, {16, 16, 2, 0, 0, 0, 0, 0, -2305, -3201, -7873, -8177, -8185, -14317, -29645, -28087, 5737, 3120, 0, -32767, -32767, -16381, -8185, -2017 }}; initiated=true; for (i=0;i<20;i++) pieces[i]=new Bitmap(bitdata[i]); for (i=0;i<16;i++) pieces[i+20]=new Bitmap(extrabits[i]); g.drawBitmap(0,144,maskBitmap); g.copyOffScreenRegion(0,144,160,16,0,144,Graphics.OVERWRITE, Graphics.ONSCREEN_WINDOW,Graphics.OFFSCREEN_WINDOW); g.drawRectangle(0,144,160,16,Graphics.ERASE,1); exitButton.paint(); } g.drawRectangle(0,0,160,144,Graphics.PLAIN,1); g.drawBitmap(16,4,logo); j=g.getWidth(credits); g.drawString(credits,80-j/2,42,Graphics.ERASE); j=g.getWidth(toStart); i=g.getHeight(toStart); g.drawString(toStart,80-j/2,142-i,Graphics.ERASE); g.drawBitmap(0,144,pieces[0]); g.drawBitmap(15,144,pieces[0]); g.drawBitmap(30,144,pieces[0]); gameMode=0; setupInstructions(); } public void setupInstructions() { gameMode++; if (gameMode>2) gameMode=1; counter=0; g.drawRectangle(0,57,160,72,Graphics.PLAIN,1); j=gameMode*6-6; for (i=0;i<3;i++) { g.drawString(infoStrings[j++],5,57+i*24,Graphics.ERASE); g.drawString(infoStrings[j++],5,66+i*24,Graphics.ERASE); } if (gameMode==1) { g.drawBitmap(140,59,pieces[10]); g.drawBitmap(140,83,pieces[20]); g.drawBitmap(110,83,pieces[10]); g.drawBitmap(108,107,pieces[10]); g.drawBitmap(140,107,pieces[20]); g.drawBitmap(124,107,pieces[22]); g.drawLine(130,89,139,89,Graphics.ERASE); g.drawLine(128,92,139,92,Graphics.ERASE); } else { g.drawBitmap(140,59,pieces[35]); g.drawBitmap(140,83,pieces[35]); g.drawBitmap(130,83,pieces[20]); g.drawBitmap(100,83,pieces[10]); g.drawLine(120,89,129,89,Graphics.ERASE); g.drawLine(118,92,129,92,Graphics.ERASE); g.drawBitmap(140,107,pieces[30]); g.drawBitmap(124,107,pieces[10]); } } public void prepareGame() { lives=3; newscore=0; drawScore(); level=1; for (i=0;i<3;i++) g.drawBitmap(i*15,144,pieces[0]); prepareLevel(); } public void drawScore() { scoreBuf.setLength(7); scoreBuf.append(newscore); g.drawRectangle(78,145,34,14,Graphics.ERASE,1); g.drawString(scoreBuf.toString(),50,147,Graphics.PLAIN); score=newscore; } public void prepareLevel() { m=0; while (m<5) { // Randomly place blocks for (i=0;i<11;i++) for (j=0;j<12;j++) { k=i*12+j; if (i>0 && i<10 && j>0 && j<11) map[k]=0; else map[k]=3; } map[13]=3; map[131]=0; for (j=1;j<4;j++) for (i=0;i>>2)%108); if (map[k]!=0) k=0; else { map[k]=j; k=131; } } } // Check whether all coins are reachable -- otherwise the level // cannot be solved and needs to be rebuilt map[13]=8; stack[0]=13; i=0;j=1;m=0; while (i100) setupInstructions(); break; case 10: prepareGame(); break; case 11: // Zooming in if (counter>17) gameMode=12; else g.copyOffScreenRegion(68-4*counter,68-4*counter, 24+8*counter,8+8*counter, 68-4*counter,68-4*counter, Graphics.OVERWRITE,Graphics.OFFSCREEN_WINDOW, Graphics.ONSCREEN_WINDOW); break; case 12: // Game if (flames>>2)%9; if (oX[0]<96 && map[k*12+22]==0) { addObject(5,160,16*k,k*12+23,3); flames++; } else if (oX[0]>95 && map[k*12+13]==0) { addObject(5,-16,16*k,k*12+12,4); flames++; } } numDraw=0; numMask=0; for (i=0;i<10;i++) switch(oType[i]) { case -1: // Penguin if ((oX[i]&15)==0 && (oY[i]&15)==0) oDir[i]=0; if (pNext>0 && oDir[i]==0) { oType[i]=pNext; if (pNext==7) g.playSound(Graphics.SOUND_ERROR); for (j=1;j<10;j++) if (oType[j]==5) oType[j]=0; flameMax=0; lastDir=oDir[0]; oDir[0]=0; counter=0; wantDir=0; } if (oDir[i]==0 && wantDir>0) { lastDir=wantDir; if (map[oPos[i]+offsets[wantDir]]==0) { oDir[i]=wantDir; oPos[i]+=offsets[wantDir]; wantDir=0; } else if (map[oPos[i]+offsets[wantDir]]<3) { if (map[oPos[i]+2*offsets[wantDir]]>0) // Crush { addObject(map[oPos[i]+offsets[wantDir]], oX[i]+16*offsX[wantDir],oY[i]+16*offsY[wantDir], oPos[i]+offsets[wantDir],13+7*map[oPos[i]+offsets[wantDir]]); map[oPos[i]+offsets[wantDir]]=4; g.copyOffScreenRegion(96,144,16,16,oX[i]+16*offsX[wantDir], oY[i]+16*offsY[wantDir],Graphics.OVERWRITE, Graphics.OFFSCREEN_WINDOW,Graphics.OFFSCREEN_WINDOW); g.playSound(Graphics.SOUND_CLICK); } else // Push { addObject(2+map[oPos[i]+offsets[wantDir]], oX[i]+16*offsX[wantDir],oY[i]+16*offsY[wantDir], oPos[i]+offsets[wantDir],wantDir); map[oPos[i]+offsets[wantDir]]=0; g.copyOffScreenRegion(96,144,16,16,oX[i]+16*offsX[wantDir], oY[i]+16*offsY[wantDir],Graphics.OVERWRITE, Graphics.OFFSCREEN_WINDOW,Graphics.OFFSCREEN_WINDOW); g.playSound(Graphics.SOUND_CLICK); } wantDir=0; } } toDraw[numDraw++]=oX[i]; toDraw[numDraw++]=oY[i]; if (oDir[i]>0) toDraw[numDraw++]=pAnim[oDir[i]*4+(counter&3)]; else toDraw[numDraw++]=pAnim[lastDir*4]; oX[i]+=4*offsX[oDir[i]]; oY[i]+=4*offsY[oDir[i]]; break; case 1: // Cracking ice case 2: // Cracking coin toDraw[numDraw++]=oX[i]; toDraw[numDraw++]=oY[i]; toDraw[numDraw++]=++oDir[i]; if (oDir[i]==26) { map[oPos[i]]=0; oType[i]=0; newscore+=5; } else if (oDir[i]==33) { map[oPos[i]]=0; oType[i]=0; coins++; newscore+=25; g.playSound(Graphics.SOUND_INFO); } break; case 3: // Sliding ice case 4: // Sliding coin oX[i]+=offsX[oDir[i]]*8; oY[i]+=offsY[oDir[i]]*8; if ((oX[i]&15)==0 && (oY[i]&15)==0) oPos[i]+=offsets[oDir[i]]; toDraw[numDraw++]=oX[i]; toDraw[numDraw++]=oY[i]; toDraw[numDraw++]=oType[i]*7-1; if (map[oPos[i]+offsets[oDir[i]]]>0) { map[oPos[i]]=oType[i]-2; g.copyOffScreenRegion(64+oType[i]*16,144,16,16,oX[i], oY[i],Graphics.OVERWRITE, Graphics.OFFSCREEN_WINDOW,Graphics.OFFSCREEN_WINDOW); oType[i]=0; } break; case 5: // Flame oX[i]+=offsX[oDir[i]]*flameSteps[oX[i]&15]; oY[i]+=offsY[oDir[i]]*flameSteps[oY[i]&15]; if ((oX[i]&15)==0 && (oY[i]&15)==0) { oPos[i]+=offsets[oDir[i]]; if (oDir[i]==0 || (counter&14)==0) oDir[i]=1+((random.nextInt()>>>2)&3); if (oX[i]oX[0]-10) { if (oY[0]>oY[i]) oDir[i]=2; else oDir[i]=1; } else if (oY[i]oY[0]-10) { if (oX[0]>oX[i]) oDir[i]=4; else oDir[i]=3; } if (map[oPos[i]+offsets[oDir[i]]]>0) oDir[i]=0; } if (oY[i]oY[0]-8 && oX[i]oX[0]-8) pNext=7; toMask[numMask++]=flameMask[counter%6]; toMask[numMask++]=144; toMask[numMask++]=16; toMask[numMask++]=oX[i]; toMask[numMask++]=oY[i]; toMask[numMask++]=Graphics.AND; toMask[numMask++]=0; // Eyes toMask[numMask++]=144; toMask[numMask++]=5; toMask[numMask++]=oX[i]; toMask[numMask++]=oY[i]+flameEyes[counter%6]; toMask[numMask++]=Graphics.OR; for (j=1;j<10;j++) if (oType[j]==3 || oType[j]==4) if (oX[j]45) { gameMode=13; newscore+=500; level++; counter=-1; } break; case 7: // Dying penguin if (counter<18) j=14+counter/3; else j=19; if (counter>40) { lives--; if (lives<0) { gameMode=13; counter=-1; } else prepareLife(); } else { toDraw[numDraw++]=oX[i]; toDraw[numDraw++]=oY[i]; toDraw[numDraw++]=j; } break; case 8: // Bonus points if ((counter&2)==0) { toMask[numMask++]=80; toMask[numMask++]=144; toMask[numMask++]=16; toMask[numMask++]=oX[i]; toMask[numMask++]=oY[i]; toMask[numMask++]=Graphics.XOR; } toMask[numMask++]=0; toMask[numMask++]=149; toMask[numMask++]=8; toMask[numMask++]=oX[i]; toMask[numMask++]=oY[i]+4; toMask[numMask++]=Graphics.XOR; oDir[i]++; if (oDir[i]>35) { oType[i]=0; flames--; } break; default: break; } if (coins==5) pNext=6; g.copyOffScreenRegion(0,0,160,144,0,0,Graphics.OVERWRITE, Graphics.OFFSCREEN_WINDOW, Graphics.ONSCREEN_WINDOW); i=0; while (iscore) drawScore(); break; case 13: // Blacking out, either at end of level or after last life if (counter<18) g.drawRectangle(68-4*counter,68-4*counter,24+8*counter, 8+8*counter,Graphics.PLAIN,1); else if (counter==18) { if (lives<0) g.drawString(gameOver,80-g.getWidth(gameOver)/2,64,Graphics.ERASE); else prepareLevel(); } else if (counter>80) prepareIntro(); break; default: // Just started prepareIntro(); break; } } } public void addObject(int t, int x, int y, int p, int d) { dsi=0; while (oType[dsi]!=0) dsi++; oType[dsi]=t; oX[dsi]=x; oY[dsi]=y; oPos[dsi]=p; oDir[dsi]=d; } public void keyDown(int k) { // Set the variable "wantDir" according to the pressed key // It will be read by the main game loop switch(k) { case KEY_HARD1: // Left wantDir=3; break; case KEY_HARD2: // Right wantDir=4; break; case PAGEUP: // Up wantDir=1; break; case PAGEDOWN: // Down wantDir=2; break; default: break; } if (gameMode<10) gameMode=10; } public void penDown(int x, int y) { if (exitButton.pressed(x,y)) System.exit(0); } }