• R/O
  • SSH

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision05cc135621c23da07c29cef03100ad8d6cad1c55 (tree)
l'heure2021-11-29 03:15:56
Auteursebastian_bugiu
Commitersebastian_bugiu

Message de Log

Simplifying everything. Uncompilable.

Change Summary

Modification

diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/HighScoreActivity.java
--- a/core/src/com/headwayent/spacerocket/HighScoreActivity.java Fri Nov 26 20:21:46 2021 +0200
+++ b/core/src/com/headwayent/spacerocket/HighScoreActivity.java Sun Nov 28 20:15:56 2021 +0200
@@ -53,7 +53,7 @@
5353 break;
5454 }
5555 String msg = "Congratulations! You have reached a new " +
56- "High Score: " + status.Score + " taking " + status.NumPowerupsTaken +
56+ "High Score: " + status.score + " taking " + status.numPowerupsTaken +
5757 " powerups! Difficulty setting: " + diff;
5858 gameEngine.uploadDataToFacebook(msg);
5959 gameEngine.sendTweet(msg);
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/Preferences.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/com/headwayent/spacerocket/Preferences.java Sun Nov 28 20:15:56 2021 +0200
@@ -0,0 +1,36 @@
1+package com.headwayent.spacerocket;
2+
3+import com.badlogic.gdx.Gdx;
4+
5+public class Preferences {
6+
7+ private static final Preferences preferences = new Preferences();
8+ private static final String PREFS_NAME = "spacerocket_prefs";
9+ private static final String SOUNDS = "sounds";
10+ private static final String ACCELEROMETER = "accelerometer";
11+ private final com.badlogic.gdx.Preferences prefs;
12+
13+ private Preferences() {
14+ prefs = Gdx.app.getPreferences(PREFS_NAME);
15+ }
16+
17+ public boolean isSoundEnabled() {
18+ return prefs.getBoolean(SOUNDS, true);
19+ }
20+
21+ public void setSoundsEnabled(boolean soundsEnabled) {
22+ prefs.putBoolean(SOUNDS, soundsEnabled).flush();
23+ }
24+
25+ public boolean isAccelerometerEnabled() {
26+ return prefs.getBoolean(ACCELEROMETER, false);
27+ }
28+
29+ public void setAccelerometerEnabled(boolean accelerometerEnabled) {
30+ prefs.putBoolean(ACCELEROMETER, accelerometerEnabled).flush();
31+ }
32+
33+ public static Preferences getInstance() {
34+ return preferences;
35+ }
36+}
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/SpaceRocket.java
--- a/core/src/com/headwayent/spacerocket/SpaceRocket.java Fri Nov 26 20:21:46 2021 +0200
+++ b/core/src/com/headwayent/spacerocket/SpaceRocket.java Sun Nov 28 20:15:56 2021 +0200
@@ -1,19 +1,31 @@
11 package com.headwayent.spacerocket;
22
3-import com.badlogic.gdx.ApplicationAdapter;
43 import com.badlogic.gdx.Game;
5-import com.badlogic.gdx.graphics.Texture;
4+import com.badlogic.gdx.graphics.g2d.BitmapFont;
65 import com.badlogic.gdx.graphics.g2d.SpriteBatch;
6+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
77 import com.badlogic.gdx.utils.ScreenUtils;
88
99 public class SpaceRocket extends Game {
10- SpriteBatch batch;
11- Texture img;
10+
11+ private static SpaceRocket game;
12+ private SpriteBatch batch;
13+ private TextureAtlas mainTextureAtlas;
14+ private BitmapFont font;
15+ private Mode mode;
16+
17+ public enum Mode {
18+ CLIENT, SERVER
19+ }
1220
1321 @Override
1422 public void create () {
23+ game = this;
24+ mode = Mode.CLIENT;
1525 batch = new SpriteBatch();
16- img = new Texture("badlogic.jpg");
26+ mainTextureAtlas = new TextureAtlas("spacerocket_textures");
27+ font = new BitmapFont();
28+ setScreen(new MainMenuActivity(this));
1729 }
1830
1931 @Override
@@ -21,7 +33,7 @@
2133 super.render();
2234 ScreenUtils.clear(1, 0, 0, 1);
2335 batch.begin();
24- batch.draw(img, 0, 0);
36+// batch.draw(img, 0, 0);
2537 batch.end();
2638 }
2739
@@ -44,6 +56,26 @@
4456 public void dispose () {
4557 super.dispose();
4658 batch.dispose();
47- img.dispose();
59+ mainTextureAtlas.dispose();
60+ }
61+
62+ public SpriteBatch getBatch() {
63+ return batch;
64+ }
65+
66+ public TextureAtlas getMainTextureAtlas() {
67+ return mainTextureAtlas;
68+ }
69+
70+ public BitmapFont getFont() {
71+ return font;
72+ }
73+
74+ public Mode getApplicationMode() {
75+ return mode;
76+ }
77+
78+ public static SpaceRocket getGame() {
79+ return game;
4880 }
4981 }
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/SpaceRocketMainView.java
--- a/core/src/com/headwayent/spacerocket/SpaceRocketMainView.java Fri Nov 26 20:21:46 2021 +0200
+++ b/core/src/com/headwayent/spacerocket/SpaceRocketMainView.java Sun Nov 28 20:15:56 2021 +0200
@@ -284,110 +284,105 @@
284284 arrowsUpPressed = false,
285285 arrowsDownPressed = false;
286286 GraphicsManager gfx = game.getSpaceCanvas().getGraphicsManager();
287- gfx.getControlTransparency().lock();
288- try {
289- for (int p = 0; p < pointerCount; ++p) {
290- int pointerId = event.getPointerId(p);
291- int xPos = (int) event.getX(pointerId);
292- int yPos = (int) event.getY(pointerId);
293-
294- if ((xPos > xLeftFire) && (xPos < xRightFire) &&
295- (yPos > yTopFire) && (yPos < yBottomFire)) {
296- if ((event.getAction() == MotionEvent.ACTION_DOWN) ||
297- (event.getAction() == MotionEvent.ACTION_MOVE)) {
298- game.getSpaceCanvas().recordKeyPressed(Canvas.FIRE);
299- if (!gfx.getFireSpriteTransparent().get()) {
300- gfx.getFireSprite().setImage(gfx.getFirePressedBitmap(),
301- gfx.getFirePressedBitmap().getWidth(),
302- gfx.getFirePressedBitmap().getHeight());
303- }
304- firePressed.set(true);// = true;
305- } else if ((event.getAction() == MotionEvent.ACTION_UP) ||
306- (event.getAction() == MotionEvent.ACTION_CANCEL)) {
307- game.getSpaceCanvas().recordKeyReleased(Canvas.FIRE);
287+ for (int p = 0; p < pointerCount; ++p) {
288+ int pointerId = event.getPointerId(p);
289+ int xPos = (int) event.getX(pointerId);
290+ int yPos = (int) event.getY(pointerId);
291+
292+ if ((xPos > xLeftFire) && (xPos < xRightFire) &&
293+ (yPos > yTopFire) && (yPos < yBottomFire)) {
294+ if ((event.getAction() == MotionEvent.ACTION_DOWN) ||
295+ (event.getAction() == MotionEvent.ACTION_MOVE)) {
296+ game.getSpaceCanvas().recordKeyPressed(Canvas.FIRE);
297+ if (!gfx.getFireSpriteTransparent().get()) {
298+ gfx.getFireSprite().setImage(gfx.getFirePressedBitmap(),
299+ gfx.getFirePressedBitmap().getWidth(),
300+ gfx.getFirePressedBitmap().getHeight());
308301 }
309- } else if ((xPos > xLeftArrows) && (xPos < xRightArrows) &&
310- (yPos > yTopArrows) && (yPos < yBottomArrows)) {
311- boolean upperDiagonal = isLeft(
312- xRightArrows, yBottomArrows,
313- xLeftArrows, yTopArrows,
314- xPos, yPos);
315- boolean lowerDiagonal = isLeft(
316- xRightArrows, yTopArrows,
317- xLeftArrows, yBottomArrows,
318- xPos, yPos);
319- if ((event.getAction() == MotionEvent.ACTION_DOWN) ||
320- (event.getAction() == MotionEvent.ACTION_MOVE)) {
321- if ((upperDiagonal) && (lowerDiagonal)) {
322- game.getSpaceCanvas().recordKeyPressed(Canvas.UP);
323- arrowsUpPressed = true;
324- } else if ((upperDiagonal) && (!lowerDiagonal)) {
325- game.getSpaceCanvas().recordKeyPressed(Canvas.RIGHT);
326- arrowsRightPressed = true;
327- } else if ((!upperDiagonal) && (!lowerDiagonal)) {
328- game.getSpaceCanvas().recordKeyPressed(Canvas.DOWN);
329- arrowsDownPressed = true;
330- } else if ((!upperDiagonal) && (lowerDiagonal)) {
331- game.getSpaceCanvas().recordKeyPressed(Canvas.LEFT);
332- arrowsLeftPressed = true;
333- }
334-
335- gfx.getArrowsSprite().setImage(gfx.getArrowsPressedBitmap(),
336- gfx.getArrowsPressedBitmap().getWidth(),
337- gfx.getArrowsPressedBitmap().getHeight());
338- arrowsPressed.set(true);// = true;
339- } else if ((event.getAction() == MotionEvent.ACTION_UP) ||
340- (event.getAction() == MotionEvent.ACTION_CANCEL)) {
341- if ((upperDiagonal) && (lowerDiagonal)) {
342- game.getSpaceCanvas().recordKeyReleased(Canvas.UP);
343- } else if ((upperDiagonal) && (!lowerDiagonal)) {
344- game.getSpaceCanvas().recordKeyReleased(Canvas.RIGHT);
345- } else if ((!upperDiagonal) && (!lowerDiagonal)) {
346- game.getSpaceCanvas().recordKeyReleased(Canvas.DOWN);
347- } else if ((!upperDiagonal) && (lowerDiagonal)) {
348- game.getSpaceCanvas().recordKeyReleased(Canvas.LEFT);
349- }
350- // GraphicsManager gfx = game.getSpaceCanvas().getGraphicsManager();
351- gfx.getArrowsSprite().setImage(gfx.getArrowsBitmap(),
352- gfx.getArrowsBitmap().getWidth(),
353- gfx.getArrowsBitmap().getHeight());
354- arrowsPressed.set(false);// = false;
302+ firePressed.set(true);// = true;
303+ } else if ((event.getAction() == MotionEvent.ACTION_UP) ||
304+ (event.getAction() == MotionEvent.ACTION_CANCEL)) {
305+ game.getSpaceCanvas().recordKeyReleased(Canvas.FIRE);
306+ }
307+ } else if ((xPos > xLeftArrows) && (xPos < xRightArrows) &&
308+ (yPos > yTopArrows) && (yPos < yBottomArrows)) {
309+ boolean upperDiagonal = isLeft(
310+ xRightArrows, yBottomArrows,
311+ xLeftArrows, yTopArrows,
312+ xPos, yPos);
313+ boolean lowerDiagonal = isLeft(
314+ xRightArrows, yTopArrows,
315+ xLeftArrows, yBottomArrows,
316+ xPos, yPos);
317+ if ((event.getAction() == MotionEvent.ACTION_DOWN) ||
318+ (event.getAction() == MotionEvent.ACTION_MOVE)) {
319+ if ((upperDiagonal) && (lowerDiagonal)) {
320+ game.getSpaceCanvas().recordKeyPressed(Canvas.UP);
321+ arrowsUpPressed = true;
322+ } else if ((upperDiagonal) && (!lowerDiagonal)) {
323+ game.getSpaceCanvas().recordKeyPressed(Canvas.RIGHT);
324+ arrowsRightPressed = true;
325+ } else if ((!upperDiagonal) && (!lowerDiagonal)) {
326+ game.getSpaceCanvas().recordKeyPressed(Canvas.DOWN);
327+ arrowsDownPressed = true;
328+ } else if ((!upperDiagonal) && (lowerDiagonal)) {
329+ game.getSpaceCanvas().recordKeyPressed(Canvas.LEFT);
330+ arrowsLeftPressed = true;
355331 }
356- }
357-
358- }
359- if (!firePressed.get()) {
360- game.getSpaceCanvas().recordKeyReleased(Canvas.FIRE);
361- }
362- if (!arrowsUpPressed) {
363- game.getSpaceCanvas().recordKeyReleased(Canvas.UP);
364- }
365- if (!arrowsRightPressed) {
366- game.getSpaceCanvas().recordKeyReleased(Canvas.RIGHT);
367- }
368- if (!arrowsDownPressed) {
369- game.getSpaceCanvas().recordKeyReleased(Canvas.DOWN);
370- }
371- if (!arrowsLeftPressed) {
372- game.getSpaceCanvas().recordKeyReleased(Canvas.LEFT);
373- }
374-
375- if (!firePressed.get()) {
376- if (!gfx.getFireSpriteTransparent().get()) {
377- gfx.getFireSprite().setImage(gfx.getFireBitmap(),
378- gfx.getFireBitmap().getWidth(),
379- gfx.getFireBitmap().getHeight());
332+
333+ gfx.getArrowsSprite().setImage(gfx.getArrowsPressedBitmap(),
334+ gfx.getArrowsPressedBitmap().getWidth(),
335+ gfx.getArrowsPressedBitmap().getHeight());
336+ arrowsPressed.set(true);// = true;
337+ } else if ((event.getAction() == MotionEvent.ACTION_UP) ||
338+ (event.getAction() == MotionEvent.ACTION_CANCEL)) {
339+ if ((upperDiagonal) && (lowerDiagonal)) {
340+ game.getSpaceCanvas().recordKeyReleased(Canvas.UP);
341+ } else if ((upperDiagonal) && (!lowerDiagonal)) {
342+ game.getSpaceCanvas().recordKeyReleased(Canvas.RIGHT);
343+ } else if ((!upperDiagonal) && (!lowerDiagonal)) {
344+ game.getSpaceCanvas().recordKeyReleased(Canvas.DOWN);
345+ } else if ((!upperDiagonal) && (lowerDiagonal)) {
346+ game.getSpaceCanvas().recordKeyReleased(Canvas.LEFT);
347+ }
348+ // GraphicsManager gfx = game.getSpaceCanvas().getGraphicsManager();
349+ gfx.getArrowsSprite().setImage(gfx.getArrowsBitmap(),
350+ gfx.getArrowsBitmap().getWidth(),
351+ gfx.getArrowsBitmap().getHeight());
352+ arrowsPressed.set(false);// = false;
380353 }
381354 }
382-
383- if (!arrowsPressed.get()) {
384- // GraphicsManager gfx = game.getSpaceCanvas().getGraphicsManager();
385- gfx.getArrowsSprite().setImage(gfx.getArrowsBitmap(),
386- gfx.getArrowsBitmap().getWidth(),
387- gfx.getArrowsBitmap().getHeight());
355+
356+ }
357+ if (!firePressed.get()) {
358+ game.getSpaceCanvas().recordKeyReleased(Canvas.FIRE);
359+ }
360+ if (!arrowsUpPressed) {
361+ game.getSpaceCanvas().recordKeyReleased(Canvas.UP);
362+ }
363+ if (!arrowsRightPressed) {
364+ game.getSpaceCanvas().recordKeyReleased(Canvas.RIGHT);
365+ }
366+ if (!arrowsDownPressed) {
367+ game.getSpaceCanvas().recordKeyReleased(Canvas.DOWN);
368+ }
369+ if (!arrowsLeftPressed) {
370+ game.getSpaceCanvas().recordKeyReleased(Canvas.LEFT);
371+ }
372+
373+ if (!firePressed.get()) {
374+ if (!gfx.getFireSpriteTransparent().get()) {
375+ gfx.getFireSprite().setImage(gfx.getFireBitmap(),
376+ gfx.getFireBitmap().getWidth(),
377+ gfx.getFireBitmap().getHeight());
388378 }
389- } finally {
390- gfx.getControlTransparency().unlock();
379+ }
380+
381+ if (!arrowsPressed.get()) {
382+ // GraphicsManager gfx = game.getSpaceCanvas().getGraphicsManager();
383+ gfx.getArrowsSprite().setImage(gfx.getArrowsBitmap(),
384+ gfx.getArrowsBitmap().getWidth(),
385+ gfx.getArrowsBitmap().getHeight());
391386 }
392387 return true;
393388 }
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/net/ClassRegistration.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/com/headwayent/spacerocket/net/ClassRegistration.java Sun Nov 28 20:15:56 2021 +0200
@@ -0,0 +1,38 @@
1+package com.headwayent.spacerocket.net;
2+
3+import com.badlogic.gdx.math.Matrix3;
4+import com.badlogic.gdx.math.Matrix4;
5+import com.badlogic.gdx.math.Vector3;
6+import com.esotericsoftware.kryo.Kryo;
7+
8+import java.util.ArrayList;
9+import java.util.HashMap;
10+import java.util.HashSet;
11+import java.util.LinkedList;
12+import java.util.TreeMap;
13+import java.util.TreeSet;
14+
15+public class ClassRegistration {
16+
17+ public static void register(Kryo kryo) {
18+
19+ kryo.register(byte[].class);
20+ kryo.register(short[].class);
21+ kryo.register(char[].class);
22+ kryo.register(int[].class);
23+ kryo.register(long[].class);
24+ kryo.register(float[].class);
25+ kryo.register(double[].class);
26+
27+ kryo.register(ArrayList.class);
28+ kryo.register(LinkedList.class);
29+ kryo.register(TreeSet.class);
30+ kryo.register(HashSet.class);
31+ kryo.register(TreeMap.class);
32+ kryo.register(HashMap.class);
33+
34+ kryo.register(Vector3.class);
35+ kryo.register(Matrix4.class);
36+ kryo.register(Matrix3.class);
37+ }
38+}
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/net/NetManager.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/com/headwayent/spacerocket/net/NetManager.java Sun Nov 28 20:15:56 2021 +0200
@@ -0,0 +1,29 @@
1+package com.headwayent.spacerocket.net;
2+
3+import com.esotericsoftware.kryo.Kryo;
4+import com.esotericsoftware.kryonet.Client;
5+import com.esotericsoftware.kryonet.rmi.ObjectSpace;
6+import com.headwayent.spacerocket.SpaceRocket;
7+
8+public class NetManager {
9+
10+ public static final int MAX_UDP_DATAGRAM_SIZE = 1400;
11+ public static final int WRITE_BUFFER_SIZE = 65536;
12+ public static final int OBJECT_BUFFER_SIZE = 65536;
13+ private static final NetManager netManager = new NetManager();
14+ private Kryo kryo;
15+ private Client client;
16+
17+ public NetManager() {
18+ if (SpaceRocket.getGame().getApplicationMode() == SpaceRocket.Mode.CLIENT) {
19+ client = new Client(WRITE_BUFFER_SIZE, OBJECT_BUFFER_SIZE);
20+ kryo = client.getKryo();
21+ ClassRegistration.register(kryo);
22+ }
23+ ObjectSpace.registerClasses(kryo);
24+ }
25+
26+ public static NetManager getInstance() {
27+ return netManager;
28+ }
29+}
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/old/ExtendedCanvas.java
--- a/core/src/com/headwayent/spacerocket/old/ExtendedCanvas.java Fri Nov 26 20:21:46 2021 +0200
+++ b/core/src/com/headwayent/spacerocket/old/ExtendedCanvas.java Sun Nov 28 20:15:56 2021 +0200
@@ -1,11 +1,14 @@
11 package com.headwayent.spacerocket.old;
22
3+import com.badlogic.gdx.ScreenAdapter;
4+import com.badlogic.gdx.graphics.g2d.GlyphLayout;
5+import com.badlogic.gdx.utils.ScreenUtils;
36 import com.headwayent.spacerocket.HighScoreActivity;
47 import com.headwayent.spacerocket.HighScoreInvertedComparator;
58 import com.headwayent.spacerocket.OptionsMenuManager;
9+import com.headwayent.spacerocket.SpaceRocket;
610 import com.headwayent.spacerocket.SpaceRocketActivity;
711 import com.headwayent.spacerocket.SpaceRocketMainView;
8-import com.headwayent.microedition.lcdui.game.GameCanvas;
912 import com.headwayent.microedition.media.MediaException;
1013 import com.headwayent.microedition.rms.InvalidRecordIDException;
1114 import com.headwayent.microedition.rms.RecordEnumeration;
@@ -24,7 +27,7 @@
2427 import android.graphics.Rect;
2528 import android.view.View;
2629
27-public class ExtendedCanvas extends GameCanvas {
30+public class ExtendedCanvas extends ScreenAdapter {
2831
2932 public static final float ACCELEROMETER_ERROR = 3.0f;
3033 public static final float FLOAT_EPSILON = 0.00001f;
@@ -47,7 +50,6 @@
4750 private static int OTHER_SHIP_LIVES_WIDTH;
4851 private static int HIGH_SCORE_WIDTH;
4952 private int DISP_WIDTH, DISP_HEIGHT;
50- private SpaceRocket gameEngine;
5153 private GraphicsManager gfxMgmt;
5254 private int InitialGameTicks = 950;
5355 private int OldGameTicks = InitialGameTicks;
@@ -55,11 +57,7 @@
5557 public static final int BLACK = 0xff000000;
5658 public static final int WHITE = 0xffffffff;
5759 private String timeString;
58- private Status status;// = new Status();
59- private RecordStore highScoreStore;
60- private RecordStore nameStore;
61- private RecordEnumeration highScoreEnum;
62-// private RecordEnumeration nameEnum;
60+ private Status status = new Status();
6361 private HighScoreComparator comparator;
6462
6563 private int keyCode;
@@ -83,13 +81,6 @@
8381 private boolean rollReleased, pitchReleased;
8482 private AtomicBoolean checkFirePressed = new AtomicBoolean();
8583
86- /* private boolean GameOver;
87- private int Score;
88- private int LivesRemaining;*/
89- public void setHighScoreEnumNull() {
90- setHighScoreEnum(null);
91- }
92-
9384 public void updateDisplayMetrics() {
9485 DISP_WIDTH = getWidth();
9586 DISP_HEIGHT = getHeight();
@@ -101,103 +92,25 @@
10192 GraphicsManager.setDISP_HEIGHT(DISP_HEIGHT);
10293 }
10394
104- public ExtendedCanvas(View view, SpaceRocket midlet) {
105- super(view);
106- // TODO Auto-generated constructor stub
107-
108- setGameEngine(midlet);
109-
110- synchronized(this) {
111- status = new Status();
112- status.LivesRemaining = NUM_LIVES;
113- status.GameTicks = InitialGameTicks;
114-
115- // initStatus();
116- updateDisplayMetrics();
117- FONT = new Paint();
118- FONT.setAntiAlias(true);
119- FontMetrics metrics = FONT.getFontMetrics();
120- FONT_HEIGHT = (int) (metrics.bottom - metrics.top);
121- Rect rect = new Rect();
122- String sc = "Score : 0000";
123- FONT.getTextBounds(sc, 0, sc.length(), rect);
124- SCORE_WIDTH = rect.width();
125- String hs = "HIGH_SCORE:";
126- FONT.getTextBounds(hs, 0, hs.length(), rect);
127- HIGH_SCORE_WIDTH = rect.width();
128- String tm = "Time: 10:00";
129- FONT.getTextBounds(tm, 0, tm.length(), rect);
130- TIME_WIDTH = rect.width();
131- String lv = "Lives : 00";
132- FONT.getTextBounds(lv, 0, lv.length(), rect);
133- LIVES_WIDTH = rect.width();
134- FONT.getTextBounds(messagePending, 0, messagePending.length(), rect);
135- MESSAGE_WIDTH = rect.width();
136- comparator = new HighScoreComparator();
137- try {
138- gfxMgmt = new GraphicsManager(CORNER_X, CORNER_Y, DISP_WIDTH, DISP_HEIGHT,
139- getGameEngine(), status, this);
140- } catch (RuntimeException e) {
141- e.printStackTrace();
142- throw e;
143- }
144-
145- try {
146- highScoreStore = RecordStore.openRecordStore(gameEngine.getContext(),
147- "highscores", true);
148- } catch (RecordStoreFullException e) {
149- // TODO Auto-generated catch block
150- e.printStackTrace();
151- } catch (RecordStoreNotFoundException e) {
152- // TODO Auto-generated catch block
153- e.printStackTrace();
154- } catch (RecordStoreException e) {
155- // TODO Auto-generated catch block
156- e.printStackTrace();
157- }
158- try {
159- highScoreEnum = highScoreStore.enumerateRecords(null,
160- comparator, false);
161- } catch (RecordStoreNotOpenException e) {
162- e.printStackTrace();
163- }
164- }
95+ public ExtendedCanvas() {
96+ status.livesRemaining = NUM_LIVES;
97+ status.gameTicks = InitialGameTicks;
98+
99+ updateDisplayMetrics();
100+ String sc = "Score : 0000";
101+ String hs = "HIGH_SCORE:";
102+ String tm = "Time: 10:00";
103+ String lv = "Lives : 00";
104+ comparator = new HighScoreComparator();
105+ try {
106+ gfxMgmt = new GraphicsManager(CORNER_X, CORNER_Y, DISP_WIDTH, DISP_HEIGHT,
107+ status, this);
108+ } catch (RuntimeException e) {
109+ e.printStackTrace();
110+ throw e;
111+ }
165112 }
166113
167- /**
168- * @return the fONT
169- */
170- private static synchronized Paint getFONT() {
171- return FONT;
172- }
173-
174- /**
175- * @return the gfxMgmt
176- */
177- private synchronized GraphicsManager getGfxMgmt() {
178- return gfxMgmt;
179- }
180-
181- private void initStatus() {
182- /* status = new Status();
183- status.LivesRemaining = NUM_LIVES;
184- status.GameTicks = InitialGameTicks;
185- */
186- // status = gfxMgmt.getStatus();
187- }
188-
189- public synchronized int getDispWidth() {
190- return DISP_WIDTH;
191- }
192-
193- public synchronized int getDispHeight() {
194- return DISP_HEIGHT;
195- }
196-
197- public GraphicsManager getGraphicsManager() {
198- return getGfxMgmt();
199- }
200-
201114 public synchronized Status getStatus() {
202115 return status;
203116 }
@@ -228,7 +141,7 @@
228141 initStatus();
229142 }
230143 getStatus().setGameOver(false);
231- getStatus().GameTicks = InitialGameTicks;
144+ getStatus().gameTicks = InitialGameTicks;
232145 // GameTicks = InitialGameTicks;
233146 OldGameTicks = InitialGameTicks;
234147 // d.setCurrent(this);
@@ -240,9 +153,9 @@
240153 initStatus();
241154 }
242155 getGfxMgmt().reset();
243- getStatus().Score = 0;
244- getStatus().LivesRemaining = NUM_LIVES;
245- getStatus().NumPowerupsTaken = 0;
156+ getStatus().score = 0;
157+ getStatus().livesRemaining = NUM_LIVES;
158+ getStatus().numPowerupsTaken = 0;
246159 resetTicks();
247160 }
248161
@@ -253,10 +166,10 @@
253166 initStatus();
254167 }
255168 if(score != 0) {
256- getStatus().Score = score;
169+ getStatus().score = score;
257170 }
258171 if(lives != 0) {
259- getStatus().LivesRemaining = lives;
172+ getStatus().livesRemaining = lives;
260173 }
261174 if((currentBoss != -1) && (bossHealth != 0)) {
262175 getGfxMgmt().getBossSprite()[currentBoss].setHealth(bossHealth);
@@ -267,22 +180,10 @@
267180 this.getGraphicsManager().getEngine().setSelectionMade();
268181 }
269182
270-// public Display getDisplay() {
271-// return d;
272-// }
273-
274183 public void flushKeys() {
275184 getKeyStates();
276185 }
277186
278- //TODO add action when game is hidden
279- protected void hideNotify() {
280- }
281-
282- public synchronized RecordEnumeration getHighScoreEnum() {
283- return highScoreEnum;
284- }
285-
286187 synchronized void setNotifyMessageReceived() {
287188 notifyMessageReceived = true;
288189 popNotify = true;
@@ -310,7 +211,43 @@
310211 public String getCoopName() {
311212 return coopName;
312213 }
313-
214+
215+ @Override
216+ public void render(float delta) {
217+ super.render(delta);
218+ ScreenUtils.clear(0, 0, 0, 1);
219+ SpaceRocket game = SpaceRocket.getGame();
220+ game.getFont().draw(game.getBatch(), "Score: " + getStatus().score,
221+ CORNER_X, CORNER_Y + 100);
222+ game.getFont().draw(game.getBatch(), "Lives: " + getStatus().livesRemaining, (DISP_WIDTH - LIVES_WIDTH),
223+ CORNER_Y + 100);
224+
225+// if (mp) {
226+// game.getFont().draw(game.getBatch(), "coopName + Score: " + getStatus().score,
227+// CORNER_X, CORNER_Y + 100);
228+// game.getFont().draw(game.getBatch(), "coopName + Lives: " + getStatus().livesRemaining, (DISP_WIDTH - LIVES_WIDTH),
229+// CORNER_Y + 100);
230+// }
231+
232+ if((popNotify)) {
233+ if(++elapsedFrames < 100) {
234+ game.getFont().draw(game.getBatch(), messagePending, (DISP_WIDTH - MESSAGE_WIDTH) >> 1,
235+ DISP_HEIGHT - 70);
236+ } else {
237+ elapsedFrames = 0;
238+ popNotify = false;
239+ // notifyMessageReceived = false;
240+ }
241+ }
242+
243+ if (getStatus().isGameOver()) {
244+ GlyphLayout layout = new GlyphLayout(game.getFont(), "Game Over!");
245+ game.getFont().draw(game.getBatch(), "Game Over!",
246+ (DISP_WIDTH - layout.width) / 2,
247+ (DISP_HEIGHT - layout.height) / 2);
248+ }
249+ }
250+
314251 public void paint(Canvas gfx) {
315252 gfx.drawARGB(0, 0, 0, 0);
316253 try {
@@ -322,93 +259,20 @@
322259 if (getStatus() == null) {
323260 initStatus();
324261 }
325- if (getStatus().FirstTime == true) {
262+ if (getStatus().firstTime) {
326263 FONT.setColor(WHITE);
327-
328- /* gfx.drawText("HIGH SCORE:", (DISP_WIDTH - HIGH_SCORE_WIDTH) >> 1,
329- DISP_HEIGHT - 100, FONT);
330- byte[] record = null;
331- String name = "";
332- String score = "";
333- String difficulty = "";
334- // int j = 0;
335- int height = 80;
336- while ((getHighScoreEnum() != null) && (getHighScoreEnum().hasNextElement())) {
337- try {
338- record = getHighScoreEnum().nextRecord();
339- } catch (InvalidRecordIDException e) {
340- // TODO Auto-generated catch block
341- e.printStackTrace();
342- } catch (RecordStoreException e) {
343- // TODO Auto-generated catch block
344- e.printStackTrace();
345- }
346- boolean found1 = false;
347- for (int i = 0; i < record.length; ++i) {
348- if (record[i] == ',') {
349- // name += record[i];
350- name = new String(record, 0, i);
351- for(int j = i + 1; j < record.length; ++j) {
352- if(record[j] == ',') {
353- score = new String(record, i + 2, j - i - 2);
354- difficulty = new String(record, j + 2, record.length - j - 2);
355- found1 = true;
356- break;
357- }
358- }
359- // j = i + 1;
360- break;
361- }
362- }
363- if(found1 == false) {
364- try {
365- getHighScoreEnum().reset();
366- while(getHighScoreEnum().hasNextElement()) {
367- getHighScoreStore().deleteRecord(getHighScoreEnum().nextRecordId());
368- }
369- getHighScoreEnum().rebuild();
370- } catch (InvalidRecordIDException f) {
371- // TODO Auto-generated catch block
372-
373- } catch (RecordStoreException f) {
374- // TODO Auto-generated catch block
375- f.printStackTrace();
376- }
377- }
378-
379-
380- /* for(int i = j; i < record.length; ++i) {
381- score += record[i];
382- }*/
383-
384- /* String ns = name + " " + score + " " + difficulty;
385- ns = ns.trim();
386- FONT.setTextAlign(Align.CENTER);
387- gfx.drawText(ns, //(int)((float)DISP_WIDTH - FONT.measureText(ns)) >> 1,
388- ((float)DISP_WIDTH * 0.5f),
389- DISP_HEIGHT - height, FONT);
390- FONT.setTextAlign(Align.LEFT);
391- height -= 15;
392- }
393- if (getHighScoreEnum() != null) {
394- getHighScoreEnum().reset();
395- }*/
396264 } else {
397265 FONT.setColor(WHITE);
398266 if(getGameEngine().isMP() == false) {
399- gfx.drawText("Score: " + getStatus().Score, CORNER_X,
267+ gfx.drawText("Score: " + getStatus().score, CORNER_X,
400268 CORNER_Y + 100, FONT);
401- /* gfx.drawString("Time: " + formatTime(), (DISP_WIDTH - TIME_WIDTH) >> 1,
402- DISP_HEIGHT - 50, Graphics.BOTTOM | Graphics.LEFT);*/
403- gfx.drawText("Lives: " + getStatus().LivesRemaining, (DISP_WIDTH - LIVES_WIDTH),
269+ gfx.drawText("Lives: " + getStatus().livesRemaining, (DISP_WIDTH - LIVES_WIDTH),
404270 CORNER_Y + 100, FONT);
405271 }
406272 if (getGameEngine().isMP() && (getGfxMgmt().getOtherSpaceRocket() != null)) {
407- gfx.drawText(getGameEngine().getName() + " Score: " + getStatus().Score, CORNER_X,
273+ gfx.drawText(getGameEngine().getName() + " Score: " + getStatus().score, CORNER_X,
408274 CORNER_Y + 100, FONT);
409- /* gfx.drawString("Time: " + formatTime(), (DISP_WIDTH - TIME_WIDTH) >> 1,
410- DISP_HEIGHT - 50, Graphics.BOTTOM | Graphics.LEFT);*/
411- gfx.drawText(getGameEngine().getName() + " Lives: " + getStatus().LivesRemaining, CORNER_X,
275+ gfx.drawText(getGameEngine().getName() + " Lives: " + getStatus().livesRemaining, CORNER_X,
412276 CORNER_Y + 80, FONT);
413277 gfx.drawText(coopName + " Score: " + getGfxMgmt().getOtherSpaceRocket().GetScore(),
414278 (DISP_WIDTH - OTHER_SHIP_SCORE_WIDTH), CORNER_Y + 100,
@@ -416,42 +280,6 @@
416280 gfx.drawText(coopName + " Lives: " + getGfxMgmt().getOtherSpaceRocket().GetNumLives(),
417281 (DISP_WIDTH - OTHER_SHIP_LIVES_WIDTH),
418282 CORNER_Y + 80, FONT);
419- /* gfx.drawString("pos1: " + gfxMgmt.getClientPrediction().getPos1().x + " " +
420- gfxMgmt.getClientPrediction().getPos1().y,
421- 10, 10, Graphics.TOP | Graphics.LEFT);
422- gfx.drawString("pos2: " + gfxMgmt.getClientPrediction().getPos2().x + " " +
423- gfxMgmt.getClientPrediction().getPos2().y,
424- 10, 30, Graphics.TOP | Graphics.LEFT);
425- gfx.drawString("pos3: " + gfxMgmt.getClientPrediction().getPos3().x + " " +
426- gfxMgmt.getClientPrediction().getPos3().y,
427- 10, 50, Graphics.TOP | Graphics.LEFT);
428- gfx.drawString("uppos: " + gfxMgmt.getClientPrediction().getUPPos().x + " " +
429- gfxMgmt.getClientPrediction().getUPPos().y,
430- 10, 70, Graphics.TOP | Graphics.LEFT);
431- gfx.drawString("diffpos: " + gfxMgmt.getClientPrediction().getDiffPos().x + " " +
432- gfxMgmt.getClientPrediction().getDiffPos().y,
433- 10, 90, Graphics.TOP | Graphics.LEFT);
434- gfx.drawString("SmoothNum: " + gfxMgmt.getClientPrediction().getCurrentSmoothNum(),
435- 10, 110, Graphics.TOP | Graphics.LEFT);
436- gfx.drawString("Pos: " + gfxMgmt.getOtherSpaceRocket().getXPos() + " " +
437- gfxMgmt.getOtherSpaceRocket().getYPos(),
438- 10, 130, Graphics.TOP | Graphics.LEFT);*/
439- /* System.out.println("Other ship score " +
440- gfxMgmt.getOtherSpaceRocket().GetScore());*/
441-
442- //Check if message received and alert player
443- synchronized(this) {
444- if((popNotify)) {
445- if(++elapsedFrames < 100) {
446- gfx.drawText(messagePending, (DISP_WIDTH - MESSAGE_WIDTH) >> 1,
447- DISP_HEIGHT - 70, FONT);
448- } else {
449- elapsedFrames = 0;
450- popNotify = false;
451- // notifyMessageReceived = false;
452- }
453- }
454- }
455283 }
456284 }
457285
@@ -469,7 +297,7 @@
469297 if (getStatus() == null) {
470298 initStatus();
471299 }
472- if (getStatus().FirstTime == false) {
300+ if (getStatus().firstTime == false) {
473301 // --status.GameTicks;
474302 }
475303
@@ -479,7 +307,7 @@
479307 // TODO Auto-generated catch block
480308 e1.printStackTrace();
481309 }
482- if (((getStatus().GameTicks == 0) || (getStatus().LivesRemaining <= 0)) && (getStatus().getGameOver() == false)) {
310+ if (((getStatus().gameTicks == 0) || (getStatus().livesRemaining <= 0)) && (getStatus().getGameOver() == false)) {
483311 if (!getGameEngine().isMP()) {
484312 // try {
485313 if(!gameOver) {
@@ -645,10 +473,10 @@
645473 initStatus();
646474 }
647475 if(gameLoaded) {
648- getStatus().FirstTime = false;
476+ getStatus().firstTime = false;
649477 getGfxMgmt().appendSpaceRockets();
650478 }
651- if ((getStatus().FirstTime == true) && (getGameEngine().isMP() == false)) {
479+ if ((getStatus().firstTime == true) && (getGameEngine().isMP() == false)) {
652480 int keyState = getKeyStates();
653481 if (showFireToast) {
654482
@@ -656,7 +484,7 @@
656484 }
657485 checkFirePressed.set(true);
658486 if ((keyState & FIRE_PRESSED) != 0) {
659- getStatus().FirstTime = false;
487+ getStatus().firstTime = false;
660488 if(!gameLoaded) {
661489 this.reset();
662490 }
@@ -669,11 +497,11 @@
669497 return;
670498 }
671499
672- if ((getStatus().FirstTime == true) && (getGameEngine().isMP()) &&
500+ if ((getStatus().firstTime == true) && (getGameEngine().isMP()) &&
673501 (getGfxMgmt().getSpaceRocketsSet())) {
674502 this.reset();
675503 getGfxMgmt().appendSpaceRockets();
676- getStatus().FirstTime = false;
504+ getStatus().firstTime = false;
677505 }
678506 if (!getStatus().getGameOver()) {
679507 int keyState = getKeyStates();
@@ -695,7 +523,7 @@
695523 getGfxMgmt().setFire();
696524 }
697525 if ((getGameEngine().isMP()) && (this.keyCode == KEY_POUND) && (pressed)) {
698- if (getStatus().LivesRemaining > 0) {
526+ if (getStatus().livesRemaining > 0) {
699527 getGfxMgmt().GiveLife();
700528 // gfxMgmt.getOtherSpaceRocket().IncrementLives(); NO need since we use full lives in mp
701529 getGfxMgmt().UpdateScore(true, false);
@@ -790,7 +618,7 @@
790618 // int lowestScore = Integer.parseInt(str);
791619 getHighScoreEnum().rebuild();
792620 getHighScoreEnum().reset();
793- if (lowestScore < getStatus().Score) {
621+ if (lowestScore < getStatus().score) {
794622 return true;
795623 }
796624 }
@@ -839,36 +667,10 @@
839667 }
840668
841669 /**
842- * @param highScoreEnum the highScoreEnum to set
843- */
844- private synchronized void setHighScoreEnum(RecordEnumeration highScoreEnum) {
845- this.highScoreEnum = highScoreEnum;
846- }
847-
848- /**
849- * @param gameEngine the gameEngine to set
850- */
851- private synchronized void setGameEngine(SpaceRocket gameEngine) {
852- this.gameEngine = gameEngine;
853- }
854-
855- /**
856- * @return the gameEngine
857- */
858- private synchronized SpaceRocket getGameEngine() {
859- return gameEngine;
860- }
861-
862- /**
863670 * @return the checkFirePressed
864671 */
865672 public AtomicBoolean getCheckFirePressed() {
866673 return checkFirePressed;
867674 }
868675
869- public synchronized void setView(View view) {
870- super.setView(view);
871-
872- }
873-
874676 }
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/old/FinalResults.java
--- a/core/src/com/headwayent/spacerocket/old/FinalResults.java Fri Nov 26 20:21:46 2021 +0200
+++ b/core/src/com/headwayent/spacerocket/old/FinalResults.java Sun Nov 28 20:15:56 2021 +0200
@@ -19,9 +19,9 @@
1919 public void setResultsString() { //Before restart!!!
2020 Status status = spaceCanvas.getStatus();
2121 results = gameThread.getEngine().getName() + " :\n" +
22- "Score : " + status.Score + "\n" +
23- "Total lives lost : " + status.TotalNumLivesLost + "\n" +
24- "Total powerups taken : " + status.NumPowerupsTaken + "\n\n" +
22+ "Score : " + status.score + "\n" +
23+ "Total lives lost : " + status.totalNumLivesLost + "\n" +
24+ "Total powerups taken : " + status.numPowerupsTaken + "\n\n" +
2525 spaceCanvas.getCoopName() + " :\n" +
2626 "Score : " + spaceCanvas.getGraphicsManager().getOtherSpaceRocket().GetScore();// + "\n" +
2727 // "Total lives lost : " + status.CoopTotalNumLivesLost + "\n" +
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/old/GraphicsManager.java
--- a/core/src/com/headwayent/spacerocket/old/GraphicsManager.java Fri Nov 26 20:21:46 2021 +0200
+++ b/core/src/com/headwayent/spacerocket/old/GraphicsManager.java Sun Nov 28 20:15:56 2021 +0200
@@ -1,5 +1,9 @@
11 package com.headwayent.spacerocket.old;
22
3+import com.badlogic.gdx.Gdx;
4+import com.badlogic.gdx.audio.Sound;
5+import com.badlogic.gdx.graphics.g2d.TextureAtlas;
6+import com.headwayent.spacerocket.SpaceRocket;
37 import com.headwayent.spacerocket.SpaceRocketMainView;
48 import com.headwayent.SpaceRocketFull.R;
59 import com.headwayent.microedition.lcdui.game.LayerManager;
@@ -14,7 +18,6 @@
1418 import java.util.Iterator;
1519 import java.util.Random;
1620 import java.util.concurrent.atomic.AtomicBoolean;
17-import java.util.concurrent.locks.ReentrantLock;
1821
1922 import android.content.res.Resources;
2023 import android.graphics.Bitmap;
@@ -57,13 +60,12 @@
5760 private static final int SCREEN_HEIGHT_MULTIPLIER = 4;
5861 private static final int STAR_NUM = 500;
5962 private static final int PLANET_NUM = 8;
60- public static int CANVAS_X;
61- public static int CANVAS_Y;
62- private static int DISP_WIDTH;
63- private static int DISP_HEIGHT;
64- private int XDir = 0, YDir = 0;
65- private int shoot = 0;
66- private SpaceRocket gameEngine;
63+ public int CANVAS_X;
64+ public int CANVAS_Y;
65+ private int DISP_WIDTH;
66+ private int DISP_HEIGHT;
67+ private int XDir, YDir;
68+ private int shoot;
6769 private SpaceRocketSprite spaceRocket;
6870 private SpaceRocketSprite otherSpaceRocket;
6971 private EnemySprite[] enemy;
@@ -71,9 +73,7 @@
7173 private RocketSprite[] srrocketRightSprite;
7274 private RocketSprite[] otherRocketLeftSprite;
7375 private RocketSprite[] otherRocketRightSprite;
74-// private RocketSprite[] otherRocketSprite;
7576 private RocketSprite[] enemyrocketSprite;
76-// private RocketSprite[] srrocketSprite;
7777 private RocketSprite[] tripleRocketSpriteCenter;
7878 private RocketSprite[] tripleRocketSpriteLeft;
7979 private RocketSprite[] tripleRocketSpriteRight;
@@ -99,56 +99,17 @@
9999 private Sprite backgroundLayer;
100100 private AnimatedBackground animatedBackground;
101101 private boolean[] bossSpriteLaunched;
102- private Bitmap[] planetBitmap;
103- private Bitmap[] miniBossBitmap;
104- private Bitmap[] enemyBitmap;
105- private Bitmap[] enemyrocketBitmap;
106- private Bitmap[] srrocketBitmap;
107- private Bitmap[] srrocketLeftBitmap;
108- private Bitmap[] srrocketRightBitmap;
109- private Bitmap smokeBitmap;
110- private Bitmap earthBitmap;
111- private Bitmap atmosphereBitmap;
112- private Bitmap doubleDamageRocketBitmap;
113- private Bitmap centerRocketBitmap;
114- private Bitmap leftRocketBitmap;
115- private Bitmap rightRocketBitmap;
116- private Bitmap spaceRocketBitmap;
117- private Bitmap otherSpaceRocketBitmap;
118- private Bitmap explosionBitmap;
119- private Bitmap tiledBitmap;
120- private Bitmap boss1Bitmap;
121- private Bitmap boss2Bitmap;
122- private Bitmap boss3Bitmap;
123- private Bitmap boss4Bitmap;
124- private Bitmap[] PowerupBitmap;
125- private Bitmap starBitmap;
126- private Bitmap flamesBitmap;
127- private Bitmap shieldBitmap;
128- private Bitmap giveLifeBitmap;
129- private Bitmap arrowsBitmap;
130- private Bitmap arrowsPressedBitmap;
131- private Bitmap fireBitmap;
132- private Bitmap firePressedBitmap;
133- private Bitmap fireTransparentBitmap;
134- private Bitmap backgroundBitmap;
135- private Bitmap animatedBackgroundBitmap;
136102 private TiledLayer tiledLayer;
137103 private int numCol, numRows;
138- private InputStream explosionWAV;
139- private InputStream launchWAV;
140- private Player explodeSnd;
141- private Player launchSnd;
104+ private Sound explodeSnd;
105+ private Sound launchSnd;
142106 private Random rand;
143- //private Status status;
144107 private ConnectionThread connectionThread;
145108 private boolean giveLife;
146109 private boolean spaceRocketsSet;
147- private int ScoreQueue;
148- private int CurrentUpdateFrame = 0;
149- private int CurrentPowerup = 0;
150- private int CurrentBoss = -1;
151- //private Display display;
110+ private int scoreQueue;
111+ private int currentPowerup = 0;
112+ private int currentBoss = -1;
152113 private ClientPrediction clientPrediction;
153114 private Position pos = new Position();
154115 private int spaceRocketGiveLifeCount, otherSpaceRocketGiveLifeCount;
@@ -157,7 +118,6 @@
157118 private boolean showEarth;
158119 private int advanceEarth;
159120 private AtomicBoolean fireSpriteTransparent = new AtomicBoolean();
160- private ReentrantLock controlTransparency = new ReentrantLock();
161121 private ExtendedCanvas spaceCanvas;
162122
163123 /**
@@ -194,8 +154,8 @@
194154 /* boolean b = scoreIncreased;
195155 scoreIncreased = false;
196156 return b;*/
197- if (ScoreQueue != 0) {
198- --ScoreQueue;
157+ if (scoreQueue != 0) {
158+ --scoreQueue;
199159 return true;
200160 }
201161 return false;
@@ -236,31 +196,14 @@
236196 return bossSprite[Num];
237197 }
238198
239- public SpaceRocket getEngine() {
240- return gameEngine;
241- }
242-
243- public GraphicsManager(int x, int y, int width, int height, SpaceRocket ge, Status status,
199+ public GraphicsManager(int x, int y, int width, int height, Status status,
244200 ExtendedCanvas spaceCanvas) {
245- // TODO Auto-generated constructor stub
246-
247-
248201 CANVAS_X = x;
249202 CANVAS_Y = y;
250- setDISP_WIDTH(width);
251- setDISP_HEIGHT(height);
252- ScoreQueue = 0;
253-
254- if (ge != null) {
255- gameEngine = ge;
256- }
203+ DISP_WIDTH = width;
204+ DISP_HEIGHT = height;
205+
257206 this.spaceCanvas = spaceCanvas;
258- if (status != null) {
259- // this.status = status;
260- }
261- if (spaceCanvas != null) {
262- // this.spaceCanvas = spaceCanvas;
263- }
264207 rand = new Random(System.currentTimeMillis());
265208
266209 if (bossSpriteLaunched == null) {
@@ -269,643 +212,359 @@
269212 bossSpriteLaunched[i] = false;
270213 }
271214 }
272- if ((explodeSnd == null) && (launchSnd == null)) {
273- gameEngine.setSoundSupported(true);
274- Manager.setSoundNum(2);
275- try {
276- explodeSnd = Manager.createPlayer(R.raw.explode, "audio/X-wav");
277- launchSnd = Manager.createPlayer(R.raw.launch, "audio/X-wav");
278- } catch (MediaException e) {
279- gameEngine.setSoundSupported(false);
280- } catch (Exception e) {
281- gameEngine.setSoundSupported(false);
282- // gameEngine.errorMsg(e);
283- }
284- }
285- Resources res = gameEngine.getContext().getResources();
286- if(smokeBitmap == null) {
287- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
288- // smokeBitmap = new Bitmap("/smoke2_sm.png", gameEngine);
289- smokeBitmap = BitmapFactory.decodeResource(res, R.raw.smoke2_sm);
290- } else {
215+ explodeSnd = Gdx.audio.newSound(Gdx.files.internal("explode.wav"));
216+ launchSnd = Gdx.audio.newSound(Gdx.files.internal("launch.wav"));
217+ SpaceRocket game = SpaceRocket.getGame();
218+ TextureAtlas mainTextureAtlas = game.getMainTextureAtlas();
219+ mainTextureAtlas.createSprite()
291220 // smokeBitmap = new Bitmap("/smoke2.png", gameEngine);
292- smokeBitmap = BitmapFactory.decodeResource(res, R.raw.smoke2);
293- }
294- }
295- if (earthBitmap == null) {
296221 // earthBitmap = new Bitmap("/earth.png", gameEngine);
297- earthBitmap = BitmapFactory.decodeResource(res, R.raw.earth);
298- }
299- if (atmosphereBitmap == null) {
300222 // atmosphereBitmap = new Bitmap("/atmosphere.png", gameEngine);
301- atmosphereBitmap = BitmapFactory.decodeResource(res, R.raw.atmosphere);
302- }
303- if (planetBitmap == null) {
304- planetBitmap = new Bitmap[4];
305- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
306- /* planetBitmap[0] = new Bitmap("/planet0_sm.png", gameEngine);
307- planetBitmap[1] = new Bitmap("/planet1_sm.png", gameEngine);
308- planetBitmap[2] = new Bitmap("/planet0_sm.png", gameEngine);
309- planetBitmap[3] = new Bitmap("/planet1_sm.png", gameEngine);*/
310- planetBitmap[0] = BitmapFactory.decodeResource(res, R.raw.planet0);
311- planetBitmap[1] = BitmapFactory.decodeResource(res, R.raw.planet1);
312- planetBitmap[2] = BitmapFactory.decodeResource(res, R.raw.planet0);
313- planetBitmap[3] = BitmapFactory.decodeResource(res, R.raw.planet1);
314- } else {
315223 /* planetBitmap[0] = new Bitmap("/planet0.png", gameEngine);
316224 planetBitmap[1] = new Bitmap("/planet1.png", gameEngine);
317225 planetBitmap[2] = new Bitmap("/planet0.png", gameEngine);
318226 planetBitmap[3] = new Bitmap("/planet1.png", gameEngine);*/
319- planetBitmap[0] = BitmapFactory.decodeResource(res, R.raw.planet0);
320- planetBitmap[1] = BitmapFactory.decodeResource(res, R.raw.planet1);
321- planetBitmap[2] = BitmapFactory.decodeResource(res, R.raw.planet0);
322- planetBitmap[3] = BitmapFactory.decodeResource(res, R.raw.planet1);
323- }
324- }
325- if (miniBossBitmap == null) {
326- miniBossBitmap = new Bitmap[4];
327- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
328- /* miniBossBitmap[0] = new Bitmap("/miniboss0_sm.png", gameEngine);
329- miniBossBitmap[1] = new Bitmap("/miniboss1_sm.png", gameEngine);
330- miniBossBitmap[2] = new Bitmap("/miniboss2_sm.png", gameEngine);
331- miniBossBitmap[3] = new Bitmap("/miniboss3_sm.png", gameEngine);*/
332- miniBossBitmap[0] = BitmapFactory.decodeResource(res, R.raw.miniboss0_sm);
333- miniBossBitmap[1] = BitmapFactory.decodeResource(res, R.raw.miniboss1_sm);
334- miniBossBitmap[2] = BitmapFactory.decodeResource(res, R.raw.miniboss2_sm);
335- miniBossBitmap[3] = BitmapFactory.decodeResource(res, R.raw.miniboss3_sm);
336- } else {
337227 /* miniBossBitmap[0] = new Bitmap("/miniboss0.png", gameEngine);
338228 miniBossBitmap[1] = new Bitmap("/miniboss1.png", gameEngine);
339229 miniBossBitmap[2] = new Bitmap("/miniboss2.png", gameEngine);
340230 miniBossBitmap[3] = new Bitmap("/miniboss3.png", gameEngine);*/
341- miniBossBitmap[0] = BitmapFactory.decodeResource(res, R.raw.miniboss0);
342- miniBossBitmap[1] = BitmapFactory.decodeResource(res, R.raw.miniboss1);
343- miniBossBitmap[2] = BitmapFactory.decodeResource(res, R.raw.miniboss2);
344- miniBossBitmap[3] = BitmapFactory.decodeResource(res, R.raw.miniboss3);
345- }
346- }
347- if (giveLifeBitmap == null) {
348- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
349- // giveLifeBitmap = new Bitmap("/circle_sm.png", gameEngine);
350- giveLifeBitmap = BitmapFactory.decodeResource(res, R.raw.circle_sm);
351- } else {
352231 // giveLifeBitmap = new Bitmap("/circle.png", gameEngine);
353- giveLifeBitmap = BitmapFactory.decodeResource(res, R.raw.circle);
354- }
355- }
356- if (starBitmap == null) {
357232 // starBitmap = new Bitmap("/star1.png", gameEngine);
358- starBitmap = BitmapFactory.decodeResource(res, R.raw.star1);
359- }
360- if (flamesBitmap == null) {
361- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
362- // flamesBitmap = new Bitmap("/flames_sm.png", gameEngine);
363- flamesBitmap = BitmapFactory.decodeResource(res, R.raw.flames_sm);
364- } else {
365233 // flamesBitmap = new Bitmap("/flames.png", gameEngine);
366- flamesBitmap = BitmapFactory.decodeResource(res, R.raw.flames);
367- }
368- }
369- if (boss1Bitmap == null) {
370- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
371- // boss1Bitmap = new Bitmap("/boss1ff_sm.png", gameEngine);
372- boss1Bitmap = BitmapFactory.decodeResource(res, R.raw.boss1ff_sm);
373- } else {
374234 // boss1Bitmap = new Bitmap("/boss1ff.png", gameEngine);
375- boss1Bitmap = BitmapFactory.decodeResource(res, R.raw.boss1ff);
376- }
377- }
378- if (boss2Bitmap == null) {
379- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
380- // boss2Bitmap = new Bitmap("/bossnou_sm.png", gameEngine);
381- boss2Bitmap = BitmapFactory.decodeResource(res, R.raw.bossnou_sm);
382- } else {
383235 // boss2Bitmap = new Bitmap("/bossnou.png", gameEngine);
384- boss2Bitmap = BitmapFactory.decodeResource(res, R.raw.bossnou);
385- }
386- }
387- /* if(boss2Bitmap == null) {
388- boss2Bitmap = new Bitmap("/boss1ff.png", gameEngine);
389- }*/
390- if (boss3Bitmap == null) {
391- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
392- // boss3Bitmap = new Bitmap("/boss00_sm.png", gameEngine);
393- boss3Bitmap = BitmapFactory.decodeResource(res, R.raw.boss00_sm);
394- } else {
395236 // boss3Bitmap = new Bitmap("/boss00.png", gameEngine);
396- boss3Bitmap = BitmapFactory.decodeResource(res, R.raw.boss00);
397- }
398- }
399- if (boss4Bitmap == null) {
400- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
401- // boss4Bitmap = new Bitmap("/boss01_sm.png", gameEngine);
402- boss4Bitmap = BitmapFactory.decodeResource(res, R.raw.boss01_sm);
403- } else {
404237 // boss4Bitmap = new Bitmap("/boss01.png", gameEngine);
405- boss4Bitmap = BitmapFactory.decodeResource(res, R.raw.boss01);
406- }
407- }
408- if (PowerupBitmap == null) {
409- PowerupBitmap = new Bitmap[4];
410- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
411- /* PowerupBitmap[0] = new Bitmap("/1upd_sm.png", gameEngine);
412- PowerupBitmap[1] = new Bitmap("/strikethrough3_sm.png", gameEngine);
413- PowerupBitmap[2] = new Bitmap("/multi2_sm.png", gameEngine);
414- PowerupBitmap[3] = new Bitmap("/shield1_sm.png", gameEngine);*/
415- PowerupBitmap[0] = BitmapFactory.decodeResource(res, R.raw.oneupd_sm);
416- PowerupBitmap[1] = BitmapFactory.decodeResource(res, R.raw.strikethrough3_sm);
417- PowerupBitmap[2] = BitmapFactory.decodeResource(res, R.raw.multi2_sm);
418- PowerupBitmap[3] = BitmapFactory.decodeResource(res, R.raw.shield1_sm);
419- } else {
420238 /* PowerupBitmap[0] = new Bitmap("/1upd.png", gameEngine);
421239 PowerupBitmap[1] = new Bitmap("/strikethrough3.png", gameEngine);
422240 PowerupBitmap[2] = new Bitmap("/multi2.png", gameEngine);
423241 PowerupBitmap[3] = new Bitmap("/shield1.png", gameEngine);*/
424- PowerupBitmap[0] = BitmapFactory.decodeResource(res, R.raw.oneupd);
425- PowerupBitmap[1] = BitmapFactory.decodeResource(res, R.raw.strikethrough3);
426- PowerupBitmap[2] = BitmapFactory.decodeResource(res, R.raw.multi2);
427- PowerupBitmap[3] = BitmapFactory.decodeResource(res, R.raw.shield1);
428- }
429- }
430- if (shieldBitmap == null) {
431- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
432- // shieldBitmap = new Bitmap("/shield2_sm.png", gameEngine);
433- shieldBitmap = BitmapFactory.decodeResource(res, R.raw.shield2_sm);
434- } else {
435242 // shieldBitmap = new Bitmap("/shield2.png", gameEngine);
436- shieldBitmap = BitmapFactory.decodeResource(res, R.raw.shield2);
437- }
438- }
439- if (centerRocketBitmap == null) {
440- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
441- // centerRocketBitmap = new Bitmap("/multishoot_sm.png", gameEngine);
442- centerRocketBitmap = BitmapFactory.decodeResource(res, R.raw.multishoot_sm);
443- } else {
444243 // centerRocketBitmap = new Bitmap("/multishoot.png", gameEngine);
445- centerRocketBitmap = BitmapFactory.decodeResource(res, R.raw.multishoot);
446- }
447- }
448- if (leftRocketBitmap == null) {
449- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
450- // leftRocketBitmap = new Bitmap("/multishootleft_sm.png", gameEngine);
451- leftRocketBitmap = BitmapFactory.decodeResource(res, R.raw.multishootleft_sm);
452- } else {
453244 // leftRocketBitmap = new Bitmap("/multishootleft.png", gameEngine);
454- leftRocketBitmap = BitmapFactory.decodeResource(res, R.raw.multishootleft);
455- }
456- }
457- if (rightRocketBitmap == null) {
458- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
459- // rightRocketBitmap = new Bitmap("/multishootright_sm.png", gameEngine);
460- rightRocketBitmap = BitmapFactory.decodeResource(res,
461- R.raw.multishootright_sm);
462- } else {
463245 // rightRocketBitmap = new Bitmap("/multishootright.png", gameEngine);
464- rightRocketBitmap = BitmapFactory.decodeResource(res, R.raw.multishootright);
465- }
466- }
467- if (doubleDamageRocketBitmap == null) {
468- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
469- // doubleDamageRocketBitmap = new Bitmap("/strikethrough2_sm.png", gameEngine);
470- doubleDamageRocketBitmap = BitmapFactory.decodeResource(res,
471- R.raw.strikethrough2_sm);
472- } else {
473246 // doubleDamageRocketBitmap = new Bitmap("/strikethrough2.png", gameEngine);
474- doubleDamageRocketBitmap = BitmapFactory.decodeResource(res,
475- R.raw.strikethrough2);
476- }
477- }
478- BitmapFactory.Options opt = new Options();
479- if (tiledBitmap == null) {
480247 // tiledBitmap = new Bitmap("/tiledback3.png", gameEngine);
481-
482- tiledBitmap = BitmapFactory.decodeResource(res, R.raw.tiledback3);
483-
484- }
485248 //createTiledLayer();
486249 createAnimatedBackground();
487- if ((explosion == null) && (explosionBitmap == null)) {
488- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
489- // explosionBitmap = new Bitmap("/explosion_sm.png", gameEngine);
490- explosionBitmap = BitmapFactory.decodeResource(res, R.raw.explosion_sm);
491- } else {
492- // explosionBitmap = new Bitmap("/explosion.png", gameEngine);
493- explosionBitmap = BitmapFactory.decodeResource(res, R.raw.explosion);
494- }
495- explosion = new ExplosionSprite[16];
496- for (int i = 0; i < explosion.length; ++i) {
497- // int w = explosionBitmap.getBitmap().getWidth();
498- // int h = explosionBitmap.getBitmap().getHeight();
499- explosion[i] = new ExplosionSprite(explosionBitmap); //, 34, 33);
500- // explosion[i].setVisible(false);
501- append(explosion[i]);
250+ // explosionBitmap = new Bitmap("/explosion.png", gameEngine);
251+ explosion = new ExplosionSprite[16];
252+ for (int i = 0; i < explosion.length; ++i) {
253+ // int w = explosionBitmap.getBitmap().getWidth();
254+ // int h = explosionBitmap.getBitmap().getHeight();
255+ explosion[i] = new ExplosionSprite(explosionBitmap); //, 34, 33);
256+ // explosion[i].setVisible(false);
257+ append(explosion[i]);
258+ }
259+ /* enemyBitmap[0] = new Bitmap("/enemy03.png", gameEngine);
260+ enemyBitmap[1] = new Bitmap("/enemy00.png", gameEngine);
261+ enemyBitmap[2] = new Bitmap("/enemy01.png", gameEngine);
262+ enemyBitmap[3] = new Bitmap("/enemy02.png", gameEngine);*/
263+ /* enemyrocketBitmap[0] = new Bitmap("/enemyshot0.png", gameEngine);
264+ enemyrocketBitmap[1] = new Bitmap("/enemyshot1.png", gameEngine);
265+ enemyrocketBitmap[2] = new Bitmap("/enemyshot2.png", gameEngine);
266+ enemyrocketBitmap[3] = new Bitmap("/enemyshot3.png", gameEngine);*/
267+ // srrocketBitmap[0] = new Bitmap("/playershoot.png", gameEngine);
268+ // srrocketLeftBitmap[0] = new Bitmap("/shootleft.png", gameEngine);
269+ // srrocketRightBitmap[0] = new Bitmap("/shootright.png", gameEngine);
270+ arrowsBitmap = BitmapFactory.decodeResource(res, R.raw.touch_arrows);
271+ arrowsPressedBitmap =
272+ BitmapFactory.decodeResource(res, R.raw.touch_arrows_pressed);
273+ fireBitmap = BitmapFactory.decodeResource(res, R.raw.touch_fire);
274+ firePressedBitmap =
275+ BitmapFactory.decodeResource(res, R.raw.touch_fire_pressed);
276+ fireTransparentBitmap =
277+ BitmapFactory.decodeResource(res, R.raw.touch_fire_trans);
278+ arrowsSprite = new SynchronizedSprite(arrowsBitmap, arrowsBitmap.getWidth(),
279+ arrowsBitmap.getHeight());
280+ arrowsSprite.setVisible(false);
281+ append(arrowsSprite);
282+ fireSprite = new SynchronizedSprite(fireBitmap, fireBitmap.getWidth(),
283+ fireBitmap.getHeight());
284+ fireSprite.setVisible(false);
285+ append(fireSprite);
286+ giveLifeSprite = new Sprite[2];
287+ for (int i = 0; i < giveLifeSprite.length; ++i) {
288+ giveLifeSprite[i] = new Sprite(giveLifeBitmap,
289+ giveLifeBitmap.getWidth() / 8, giveLifeBitmap.getHeight());
290+ giveLifeSprite[i].setVisible(false);
291+ append(giveLifeSprite[i]);
292+ }
293+ shieldSprite = new ExtendedSprite[2];
294+ for (int i = 0; i < shieldSprite.length; ++i) {
295+ shieldSprite[i] = new ExtendedSprite(shieldBitmap,
296+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 10,
297+ null, null, null, "shieldSprite" + i);
298+ shieldSprite[i].setVisible(false);
299+ append(shieldSprite[i]);
300+ }
301+ flamesSprite = new ExtendedSprite[2];
302+ for (int i = 0; i < flamesSprite.length; ++i) {
303+ flamesSprite[i] = new ExtendedSprite(flamesBitmap,
304+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 4,
305+ null, null, null, "flamesSprite" + i);
306+ flamesSprite[i].setVisible(false);
307+ append(flamesSprite[i]);
308+ }
309+ if(smokeSprite == null) {
310+ smokeSprite = new SmokeSprite[16];
311+ for(int i = 0; i < smokeSprite.length; ++i) {
312+ smokeSprite[i] = new SmokeSprite(smokeBitmap,
313+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 12,
314+ "smokeSprite" + i);
315+ append(smokeSprite[i]);
502316 }
503317 }
504- if (enemy == null && enemyrocketSprite == null) {
505- enemyBitmap = new Bitmap[4];
506- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
507- /* enemyBitmap[0] = new Bitmap("/enemy03_sm.png", gameEngine);
508- enemyBitmap[1] = new Bitmap("/enemy00_sm.png", gameEngine);
509- enemyBitmap[2] = new Bitmap("/enemy01_sm.png", gameEngine);
510- enemyBitmap[3] = new Bitmap("/enemy02_sm.png", gameEngine);*/
511- enemyBitmap[0] = BitmapFactory.decodeResource(res, R.raw.enemy03_sm);
512- enemyBitmap[1] = BitmapFactory.decodeResource(res, R.raw.enemy00_sm);
513- enemyBitmap[2] = BitmapFactory.decodeResource(res, R.raw.enemy01_sm);
514- enemyBitmap[3] = BitmapFactory.decodeResource(res, R.raw.enemy02_sm);
515- } else {
516- /* enemyBitmap[0] = new Bitmap("/enemy03.png", gameEngine);
517- enemyBitmap[1] = new Bitmap("/enemy00.png", gameEngine);
518- enemyBitmap[2] = new Bitmap("/enemy01.png", gameEngine);
519- enemyBitmap[3] = new Bitmap("/enemy02.png", gameEngine);*/
520- enemyBitmap[0] = BitmapFactory.decodeResource(res, R.raw.enemy03);
521- enemyBitmap[1] = BitmapFactory.decodeResource(res, R.raw.enemy00);
522- enemyBitmap[2] = BitmapFactory.decodeResource(res, R.raw.enemy01);
523- enemyBitmap[3] = BitmapFactory.decodeResource(res, R.raw.enemy02);
524- }
525- enemyrocketBitmap = new Bitmap[4];
526- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
527- /* enemyrocketBitmap[0] = new Bitmap("/enemyshot0_sm.png", gameEngine);
528- enemyrocketBitmap[1] = new Bitmap("/enemyshot1_sm.png", gameEngine);
529- enemyrocketBitmap[2] = new Bitmap("/enemyshot2_sm.png", gameEngine);
530- enemyrocketBitmap[3] = new Bitmap("/enemyshot3_sm.png", gameEngine);*/
531- enemyrocketBitmap[0] = BitmapFactory.decodeResource(res, R.raw.enemyshot0_sm);
532- enemyrocketBitmap[1] = BitmapFactory.decodeResource(res, R.raw.enemyshot1_sm);
533- enemyrocketBitmap[2] = BitmapFactory.decodeResource(res, R.raw.enemyshot2_sm);
534- enemyrocketBitmap[3] = BitmapFactory.decodeResource(res, R.raw.enemyshot3_sm);
535- } else {
536- /* enemyrocketBitmap[0] = new Bitmap("/enemyshot0.png", gameEngine);
537- enemyrocketBitmap[1] = new Bitmap("/enemyshot1.png", gameEngine);
538- enemyrocketBitmap[2] = new Bitmap("/enemyshot2.png", gameEngine);
539- enemyrocketBitmap[3] = new Bitmap("/enemyshot3.png", gameEngine);*/
540- enemyrocketBitmap[0] = BitmapFactory.decodeResource(res, R.raw.enemyshot0);
541- enemyrocketBitmap[1] = BitmapFactory.decodeResource(res, R.raw.enemyshot1);
542- enemyrocketBitmap[2] = BitmapFactory.decodeResource(res, R.raw.enemyshot2);
543- enemyrocketBitmap[3] = BitmapFactory.decodeResource(res, R.raw.enemyshot3);
544- }
545- srrocketBitmap = new Bitmap[1];
546- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
547- // srrocketBitmap[0] = new Bitmap("/playershoot_sm.png", gameEngine);
548- srrocketBitmap[0] = BitmapFactory.decodeResource(res, R.raw.playershoot_sm);
549- } else {
550- // srrocketBitmap[0] = new Bitmap("/playershoot.png", gameEngine);
551- srrocketBitmap[0] = BitmapFactory.decodeResource(res, R.raw.playershoot);
552- }
553- srrocketLeftBitmap = new Bitmap[1];
554- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
555- // srrocketLeftBitmap[0] = new Bitmap("/shootleft_sm.png", gameEngine);
556- srrocketLeftBitmap[0] = BitmapFactory.decodeResource(res, R.raw.shootleft_sm);
557- } else {
558- // srrocketLeftBitmap[0] = new Bitmap("/shootleft.png", gameEngine);
559- srrocketLeftBitmap[0] = BitmapFactory.decodeResource(res, R.raw.shootleft);
560- }
561- srrocketRightBitmap = new Bitmap[1];
562- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
563- // srrocketRightBitmap[0] = new Bitmap("/shootright_sm.png", gameEngine);
564- srrocketRightBitmap[0] = BitmapFactory.decodeResource(
565- res, R.raw.shootright_sm);
566- } else {
567- // srrocketRightBitmap[0] = new Bitmap("/shootright.png", gameEngine);
568- srrocketRightBitmap[0] = BitmapFactory.decodeResource(res, R.raw.shootright);
569- }
570- synchronized (this) {
571- arrowsBitmap = BitmapFactory.decodeResource(res, R.raw.touch_arrows);
572- arrowsPressedBitmap =
573- BitmapFactory.decodeResource(res, R.raw.touch_arrows_pressed);
574- fireBitmap = BitmapFactory.decodeResource(res, R.raw.touch_fire);
575- firePressedBitmap =
576- BitmapFactory.decodeResource(res, R.raw.touch_fire_pressed);
577- fireTransparentBitmap =
578- BitmapFactory.decodeResource(res, R.raw.touch_fire_trans);
579- arrowsSprite = new SynchronizedSprite(arrowsBitmap, arrowsBitmap.getWidth(),
580- arrowsBitmap.getHeight());
581- arrowsSprite.setVisible(false);
582- append(arrowsSprite);
583- fireSprite = new SynchronizedSprite(fireBitmap, fireBitmap.getWidth(),
584- fireBitmap.getHeight());
585- fireSprite.setVisible(false);
586- append(fireSprite);
587- }
588- giveLifeSprite = new Sprite[2];
589- for (int i = 0; i < giveLifeSprite.length; ++i) {
590- giveLifeSprite[i] = new Sprite(giveLifeBitmap,
591- giveLifeBitmap.getWidth() / 8, giveLifeBitmap.getHeight());
592- giveLifeSprite[i].setVisible(false);
593- append(giveLifeSprite[i]);
594- }
595- shieldSprite = new ExtendedSprite[2];
596- for (int i = 0; i < shieldSprite.length; ++i) {
597- shieldSprite[i] = new ExtendedSprite(shieldBitmap,
598- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 10,
599- null, null, null, "shieldSprite" + i);
600- shieldSprite[i].setVisible(false);
601- append(shieldSprite[i]);
602- }
603- flamesSprite = new ExtendedSprite[2];
604- for (int i = 0; i < flamesSprite.length; ++i) {
605- flamesSprite[i] = new ExtendedSprite(flamesBitmap,
606- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 4,
607- null, null, null, "flamesSprite" + i);
608- flamesSprite[i].setVisible(false);
609- append(flamesSprite[i]);
610- }
611- /*
612- srrocketSprite = new RocketSprite[16];
613- for (int i = 0; i < srrocketSprite.length; ++i) {
614- srrocketSprite[i] = new RocketSprite(srrocketBitmap[0].getBitmap(),
615- CANVAS_X, DISP_WIDTH, CANVAS_Y, DISP_HEIGHT, true, 8);
616- srrocketSprite[i].setLastFrameStick(true);
617- append(srrocketSprite[i]);
618- }*/
619- if(smokeSprite == null) {
620- smokeSprite = new SmokeSprite[16];
621- for(int i = 0; i < smokeSprite.length; ++i) {
622- smokeSprite[i] = new SmokeSprite(smokeBitmap,
623- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 12,
624- "smokeSprite" + i);
625- append(smokeSprite[i]);
318+ if (powerupSprite == null) {
319+ powerupSprite = new PowerupSprite[4];
320+ int numFrames = 0;
321+ for (int i = 0; i < powerupSprite.length; ++i) {
322+ if ((i % 3 == 0) && (i > 0)) {
323+ numFrames = 1;
324+ } else {
325+ numFrames = 1;
626326 }
627- }
628- if (powerupSprite == null) {
629- powerupSprite = new PowerupSprite[4];
630- int numFrames = 0;
631- for (int i = 0; i < powerupSprite.length; ++i) {
632- if ((i % 3 == 0) && (i > 0)) {
633- numFrames = 1;
634- } else {
635- numFrames = 1;
636- }
637- powerupSprite[i] = new PowerupSprite(PowerupBitmap[i],
638- CANVAS_X, getDISP_WIDTH(),
639- CANVAS_Y, getDISP_HEIGHT(), numFrames, 10, i + 1,
640- "powerupSprite" + i);
327+ powerupSprite[i] = new PowerupSprite(powerupBitmap[i],
328+ CANVAS_X, getDISP_WIDTH(),
329+ CANVAS_Y, getDISP_HEIGHT(), numFrames, 10, i + 1,
330+ "powerupSprite" + i);
641331
642- append(powerupSprite[i]);
643- }
644- }
645- srrocketLeftSprite = new RocketSprite[16];
646- for (int i = 0; i < srrocketLeftSprite.length; ++i) {
647- srrocketLeftSprite[i] = new RocketSprite(srrocketLeftBitmap[0],
648- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 8,
649- powerupSprite, gameEngine, explosion,
650- "srrocketLeftSprite" + i);
651- srrocketLeftSprite[i].setLastFrameStick(true);
652- append(srrocketLeftSprite[i]);
653- }
654- srrocketRightSprite = new RocketSprite[16];
655- for (int i = 0; i < srrocketRightSprite.length; ++i) {
656- srrocketRightSprite[i] = new RocketSprite(srrocketRightBitmap[0],
657- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 8,
658- powerupSprite, gameEngine, explosion,
659- "srrocketRightSprite" + i);
660- srrocketRightSprite[i].setLastFrameStick(true);
661- append(srrocketRightSprite[i]);
662- }
663- tripleRocketSpriteCenter = new RocketSprite[16];
664- otherTripleRocketSpriteCenter = new RocketSprite[16];
665- for (int i = 0; i < tripleRocketSpriteCenter.length; ++i) {
666- tripleRocketSpriteCenter[i] = new RocketSprite(centerRocketBitmap,
667- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
668- powerupSprite, gameEngine, explosion,
669- "tripleRocketSpriteCenter" + i);
670- append(tripleRocketSpriteCenter[i]);
671- otherTripleRocketSpriteCenter[i] = new RocketSprite(
672- centerRocketBitmap,
673- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
674- powerupSprite, gameEngine, explosion,
675- "otherTripleRocketSpriteCenter" + i);
676- append(otherTripleRocketSpriteCenter[i]);
677-
678- }
679- tripleRocketSpriteLeft = new RocketSprite[16];
680- otherTripleRocketSpriteLeft = new RocketSprite[16];
681- for (int i = 0; i < tripleRocketSpriteLeft.length; ++i) {
682- tripleRocketSpriteLeft[i] = new RocketSprite(leftRocketBitmap,
683- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
684- powerupSprite, gameEngine, explosion,
685- "tripleRocketSpriteLeft" + i);
686- append(tripleRocketSpriteLeft[i]);
687- otherTripleRocketSpriteLeft[i] = new RocketSprite(leftRocketBitmap,
688- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
689- powerupSprite, gameEngine, explosion,
690- "otherTripleRocketSpriteLeft" + i);
691- append(otherTripleRocketSpriteLeft[i]);
692- }
693- tripleRocketSpriteRight = new RocketSprite[16];
694- otherTripleRocketSpriteRight = new RocketSprite[16];
695- for (int i = 0; i < tripleRocketSpriteRight.length; ++i) {
696- tripleRocketSpriteRight[i] = new RocketSprite(rightRocketBitmap,
697- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
698- powerupSprite, gameEngine, explosion,
699- "tripleRocketSpriteRight" + i);
700- append(tripleRocketSpriteRight[i]);
701- otherTripleRocketSpriteRight[i] = new RocketSprite(rightRocketBitmap,
702- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
703- powerupSprite, gameEngine, explosion,
704- "otherTripleRocketSpriteRight" + i);
705- append(otherTripleRocketSpriteRight[i]);
332+ append(powerupSprite[i]);
706333 }
707- doubleDamageRocketSprite = new RocketSprite[16];
708- otherDoubleDamageRocketSprite = new RocketSprite[16];
709- for (int i = 0; i < doubleDamageRocketSprite.length; ++i) {
710- doubleDamageRocketSprite[i] = new RocketSprite(doubleDamageRocketBitmap,
711- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 4,
712- powerupSprite, gameEngine, explosion,
713- "doubleDamageRocketSprite" + i);
714- doubleDamageRocketSprite[i].setDoubleDamage(true);
715- append(doubleDamageRocketSprite[i]);
716- otherDoubleDamageRocketSprite[i] = new RocketSprite(doubleDamageRocketBitmap,
717- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 4,
718- powerupSprite, gameEngine, explosion,
719- "otherDoubleDamageRocketSprite" + i);
720- otherDoubleDamageRocketSprite[i].setDoubleDamage(true);
721- append(otherDoubleDamageRocketSprite[i]);
334+ }
335+ srrocketLeftSprite = new RocketSprite[16];
336+ for (int i = 0; i < srrocketLeftSprite.length; ++i) {
337+ srrocketLeftSprite[i] = new RocketSprite(srrocketLeftBitmap[0],
338+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 8,
339+ powerupSprite, gameEngine, explosion,
340+ "srrocketLeftSprite" + i);
341+ srrocketLeftSprite[i].setLastFrameStick(true);
342+ append(srrocketLeftSprite[i]);
343+ }
344+ srrocketRightSprite = new RocketSprite[16];
345+ for (int i = 0; i < srrocketRightSprite.length; ++i) {
346+ srrocketRightSprite[i] = new RocketSprite(srrocketRightBitmap[0],
347+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 8,
348+ powerupSprite, gameEngine, explosion,
349+ "srrocketRightSprite" + i);
350+ srrocketRightSprite[i].setLastFrameStick(true);
351+ append(srrocketRightSprite[i]);
352+ }
353+ tripleRocketSpriteCenter = new RocketSprite[16];
354+ otherTripleRocketSpriteCenter = new RocketSprite[16];
355+ for (int i = 0; i < tripleRocketSpriteCenter.length; ++i) {
356+ tripleRocketSpriteCenter[i] = new RocketSprite(centerRocketBitmap,
357+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
358+ powerupSprite, gameEngine, explosion,
359+ "tripleRocketSpriteCenter" + i);
360+ append(tripleRocketSpriteCenter[i]);
361+ otherTripleRocketSpriteCenter[i] = new RocketSprite(
362+ centerRocketBitmap,
363+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
364+ powerupSprite, gameEngine, explosion,
365+ "otherTripleRocketSpriteCenter" + i);
366+ append(otherTripleRocketSpriteCenter[i]);
367+
368+ }
369+ tripleRocketSpriteLeft = new RocketSprite[16];
370+ otherTripleRocketSpriteLeft = new RocketSprite[16];
371+ for (int i = 0; i < tripleRocketSpriteLeft.length; ++i) {
372+ tripleRocketSpriteLeft[i] = new RocketSprite(leftRocketBitmap,
373+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
374+ powerupSprite, gameEngine, explosion,
375+ "tripleRocketSpriteLeft" + i);
376+ append(tripleRocketSpriteLeft[i]);
377+ otherTripleRocketSpriteLeft[i] = new RocketSprite(leftRocketBitmap,
378+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
379+ powerupSprite, gameEngine, explosion,
380+ "otherTripleRocketSpriteLeft" + i);
381+ append(otherTripleRocketSpriteLeft[i]);
382+ }
383+ tripleRocketSpriteRight = new RocketSprite[16];
384+ otherTripleRocketSpriteRight = new RocketSprite[16];
385+ for (int i = 0; i < tripleRocketSpriteRight.length; ++i) {
386+ tripleRocketSpriteRight[i] = new RocketSprite(rightRocketBitmap,
387+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
388+ powerupSprite, gameEngine, explosion,
389+ "tripleRocketSpriteRight" + i);
390+ append(tripleRocketSpriteRight[i]);
391+ otherTripleRocketSpriteRight[i] = new RocketSprite(rightRocketBitmap,
392+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 1,
393+ powerupSprite, gameEngine, explosion,
394+ "otherTripleRocketSpriteRight" + i);
395+ append(otherTripleRocketSpriteRight[i]);
396+ }
397+ doubleDamageRocketSprite = new RocketSprite[16];
398+ otherDoubleDamageRocketSprite = new RocketSprite[16];
399+ for (int i = 0; i < doubleDamageRocketSprite.length; ++i) {
400+ doubleDamageRocketSprite[i] = new RocketSprite(doubleDamageRocketBitmap,
401+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 4,
402+ powerupSprite, gameEngine, explosion,
403+ "doubleDamageRocketSprite" + i);
404+ doubleDamageRocketSprite[i].setDoubleDamage(true);
405+ append(doubleDamageRocketSprite[i]);
406+ otherDoubleDamageRocketSprite[i] = new RocketSprite(doubleDamageRocketBitmap,
407+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 4,
408+ powerupSprite, gameEngine, explosion,
409+ "otherDoubleDamageRocketSprite" + i);
410+ otherDoubleDamageRocketSprite[i].setDoubleDamage(true);
411+ append(otherDoubleDamageRocketSprite[i]);
412+ }
413+ enemyrocketSprite = new RocketSprite[16];
414+ for (int i = 0; i < enemyrocketSprite.length; ++i) {
415+ int numFrames = 0;
416+ int r = rand.nextInt(4);
417+ switch (r) {
418+ case 0:
419+ numFrames = 4;
420+ break;
421+ case 1:
422+ numFrames = 1;
423+ break;
424+ case 2:
425+ numFrames = 1;
426+ break;
427+ case 3:
428+ numFrames = 1;
429+ break;
430+ default:
431+ numFrames = 1;
432+ break;
722433 }
723- enemyrocketSprite = new RocketSprite[16];
724- for (int i = 0; i < enemyrocketSprite.length; ++i) {
725- int numFrames = 0;
726- int r = rand.nextInt(4);
727- switch (r) {
728- case 0:
729- numFrames = 4;
730- break;
731- case 1:
732- numFrames = 1;
733- break;
734- case 2:
735- numFrames = 1;
736- break;
737- case 3:
738- numFrames = 1;
739- break;
740- default:
741- numFrames = 1;
742- break;
743- }
744- enemyrocketSprite[i] =
745- new RocketSprite(enemyrocketBitmap[r],
746- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), false, numFrames,
747- powerupSprite, gameEngine, explosion,
748- "enemyrocketSprite" + i);
749- append(enemyrocketSprite[i]);
750- }
751-
752- if (bossSprite == null) {
753- bossSprite = new BossSprite[4];
754- /* for(int i = 0; i < bossSprite.length; ++i) {
755- bossSprite[i] = new BossSprite(boss1Bitmap.getBitmap(), CANVAS_X, DISP_WIDTH,
756- CANVAS_Y, DISP_HEIGHT, explosion, enemyrocketSprite, BOSS_NUM_FRAMES,
757- this, 10);
758- append(bossSprite[i]);
759- }*/
760- bossSprite[0] = new BossSprite(boss1Bitmap, CANVAS_X, getDISP_WIDTH(),
761- CANVAS_Y, getDISP_HEIGHT(), explosion, enemyrocketSprite,
762- powerupSprite, BOSS1_NUM_FRAMES,
763- this, BOSS1_HEALTH, status, "boss0");
764- append(bossSprite[0]);
765- bossSprite[1] = new BossSprite(boss2Bitmap, CANVAS_X, getDISP_WIDTH(),
766- CANVAS_Y, getDISP_HEIGHT(), explosion, enemyrocketSprite,
767- powerupSprite, BOSS2_NUM_FRAMES,
768- this, BOSS2_HEALTH, status, "boss1");
769- append(bossSprite[1]);
770- bossSprite[2] = new BossSprite(boss3Bitmap, CANVAS_X, getDISP_WIDTH(),
771- CANVAS_Y, getDISP_HEIGHT(), explosion, enemyrocketSprite,
772- powerupSprite, BOSS3_NUM_FRAMES,
773- this, BOSS3_HEALTH, status, "boss2");
774- append(bossSprite[2]);
775- bossSprite[3] = new BossSprite(boss4Bitmap, CANVAS_X, getDISP_WIDTH(),
776- CANVAS_Y, getDISP_HEIGHT(), explosion, enemyrocketSprite,
777- powerupSprite, BOSS4_NUM_FRAMES,
778- this, BOSS4_HEALTH, status, "boss3");
779- append(bossSprite[3]);
780- }
434+ enemyrocketSprite[i] =
435+ new RocketSprite(enemyrocketBitmap[r],
436+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), false, numFrames,
437+ powerupSprite, gameEngine, explosion,
438+ "enemyrocketSprite" + i);
439+ append(enemyrocketSprite[i]);
440+ }
441+
442+ if (bossSprite == null) {
443+ bossSprite = new BossSprite[4];
444+ /* for(int i = 0; i < bossSprite.length; ++i) {
445+ bossSprite[i] = new BossSprite(boss1Bitmap.getBitmap(), CANVAS_X, DISP_WIDTH,
446+ CANVAS_Y, DISP_HEIGHT, explosion, enemyrocketSprite, BOSS_NUM_FRAMES,
447+ this, 10);
448+ append(bossSprite[i]);
449+ }*/
450+ bossSprite[0] = new BossSprite(boss1Bitmap, CANVAS_X, getDISP_WIDTH(),
451+ CANVAS_Y, getDISP_HEIGHT(), explosion, enemyrocketSprite,
452+ powerupSprite, BOSS1_NUM_FRAMES,
453+ this, BOSS1_HEALTH, status, "boss0");
454+ append(bossSprite[0]);
455+ bossSprite[1] = new BossSprite(boss2Bitmap, CANVAS_X, getDISP_WIDTH(),
456+ CANVAS_Y, getDISP_HEIGHT(), explosion, enemyrocketSprite,
457+ powerupSprite, BOSS2_NUM_FRAMES,
458+ this, BOSS2_HEALTH, status, "boss1");
459+ append(bossSprite[1]);
460+ bossSprite[2] = new BossSprite(boss3Bitmap, CANVAS_X, getDISP_WIDTH(),
461+ CANVAS_Y, getDISP_HEIGHT(), explosion, enemyrocketSprite,
462+ powerupSprite, BOSS3_NUM_FRAMES,
463+ this, BOSS3_HEALTH, status, "boss2");
464+ append(bossSprite[2]);
465+ bossSprite[3] = new BossSprite(boss4Bitmap, CANVAS_X, getDISP_WIDTH(),
466+ CANVAS_Y, getDISP_HEIGHT(), explosion, enemyrocketSprite,
467+ powerupSprite, BOSS4_NUM_FRAMES,
468+ this, BOSS4_HEALTH, status, "boss3");
469+ append(bossSprite[3]);
470+ }
781471
782472
783473
784- enemy = new EnemySprite[8];
785- for (int i = 0; i < enemy.length; ++i) {
786- // int r = rand.nextInt(4);
787- int r = rand.nextInt(4);
788- if (r == 0) {
789- enemy[i] = new EnemySprite(enemyBitmap[0],
790- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), explosion,
791- enemyrocketSprite, powerupSprite, gameEngine, 3, status,
792- "enemy" + i);
793- } else {
794- enemy[i] = new EnemySprite(enemyBitmap[r],
795- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), explosion,
796- enemyrocketSprite, powerupSprite, gameEngine, 1, status,
797- "enemy" + i);
798- }
799- append(enemy[i]);
800- }
801- // enemy[0].setBounds(CANVAS_X, DISP_WIDTH, CANVAS_Y, DISP_HEIGHT);
802- if (spaceRocketBitmap == null) {
803- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
804- // spaceRocketBitmap = new Bitmap("/player_sm.png", gameEngine);
805- spaceRocketBitmap = BitmapFactory.decodeResource(res, R.raw.player_sm);
806- } else {
807- // spaceRocketBitmap = new Bitmap("/player.png", gameEngine);
808- spaceRocketBitmap = BitmapFactory.decodeResource(res, R.raw.player);
809- }
810- }
811- if (otherSpaceRocketBitmap == null) {
812- if ((getDISP_WIDTH() < MIN_WIDTH) || (getDISP_HEIGHT() < MIN_HEIGHT)) {
813- // otherSpaceRocketBitmap = new Bitmap("/Image2_sm.png", gameEngine);
814- otherSpaceRocketBitmap = BitmapFactory.decodeResource(res,
815- R.raw.image2_sm);
816- } else {
817- // otherSpaceRocketBitmap = new Bitmap("/Image2.png", gameEngine);
818- otherSpaceRocketBitmap = BitmapFactory.decodeResource(res,
819- R.raw.image2);
820- }
821- }
822- /*
823- if (otherRocketSprite == null) {
824- otherRocketSprite = new RocketSprite[16];
825- for (int i = 0; i < otherRocketSprite.length; ++i) {
826- otherRocketSprite[i] = new RocketSprite(
827- srrocketBitmap[0].getBitmap(),
828- CANVAS_X, DISP_WIDTH, CANVAS_Y, DISP_HEIGHT, true, 8);
829- otherRocketSprite[i].setLastFrameStick(true);
830- append(otherRocketSprite[i]);
474+ enemy = new EnemySprite[8];
475+ for (int i = 0; i < enemy.length; ++i) {
476+ // int r = rand.nextInt(4);
477+ int r = rand.nextInt(4);
478+ if (r == 0) {
479+ enemy[i] = new EnemySprite(enemyBitmap[0],
480+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), explosion,
481+ enemyrocketSprite, powerupSprite, gameEngine, 3, status,
482+ "enemy" + i);
483+ } else {
484+ enemy[i] = new EnemySprite(enemyBitmap[r],
485+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), explosion,
486+ enemyrocketSprite, powerupSprite, gameEngine, 1, status,
487+ "enemy" + i);
831488 }
832- }*/
833- if (otherRocketLeftSprite == null) {
834- otherRocketLeftSprite = new RocketSprite[16];
835- for (int i = 0; i < otherRocketLeftSprite.length; ++i) {
836- otherRocketLeftSprite[i] = new RocketSprite(
837- srrocketLeftBitmap[0],
838- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 8,
839- powerupSprite, gameEngine, explosion,
840- "otherRocketLeftSprite" + i);
841- otherRocketLeftSprite[i].setLastFrameStick(true);
842- append(otherRocketLeftSprite[i]);
843- }
844- }
845- if (otherRocketRightSprite == null) {
846- otherRocketRightSprite = new RocketSprite[16];
847- for (int i = 0; i < otherRocketRightSprite.length; ++i) {
848- otherRocketRightSprite[i] = new RocketSprite(
849- srrocketRightBitmap[0],
850- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 8,
851- powerupSprite, gameEngine, explosion,
852- "otherRocketRightSprite" + i);
853- otherRocketRightSprite[i].setLastFrameStick(true);
854- append(otherRocketRightSprite[i]);
855- }
489+ append(enemy[i]);
490+ }
491+ // spaceRocketBitmap = new Bitmap("/player.png", gameEngine);
492+ // otherSpaceRocketBitmap = new Bitmap("/Image2.png", gameEngine);
493+ if (otherRocketLeftSprite == null) {
494+ otherRocketLeftSprite = new RocketSprite[16];
495+ for (int i = 0; i < otherRocketLeftSprite.length; ++i) {
496+ otherRocketLeftSprite[i] = new RocketSprite(
497+ srrocketLeftBitmap[0],
498+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 8,
499+ powerupSprite, gameEngine, explosion,
500+ "otherRocketLeftSprite" + i);
501+ otherRocketLeftSprite[i].setLastFrameStick(true);
502+ append(otherRocketLeftSprite[i]);
856503 }
857- if (miniBossSprite == null) {
858- miniBossSprite = new ExtendedSprite[4];
859- for (int i = 0; i < miniBossSprite.length; ++i) {
860- miniBossSprite[i] = new ExtendedSprite(miniBossBitmap[i],
861- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 3,
862- null, null, null, "miniBossSprite" + i);
863- miniBossSprite[i].setVisible(false);
864- bossSprite[i].setMiniBossSprite(miniBossSprite[i]);
865- append(miniBossSprite[i]);
866- }
867-
504+ }
505+ if (otherRocketRightSprite == null) {
506+ otherRocketRightSprite = new RocketSprite[16];
507+ for (int i = 0; i < otherRocketRightSprite.length; ++i) {
508+ otherRocketRightSprite[i] = new RocketSprite(
509+ srrocketRightBitmap[0],
510+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), true, 8,
511+ powerupSprite, gameEngine, explosion,
512+ "otherRocketRightSprite" + i);
513+ otherRocketRightSprite[i].setLastFrameStick(true);
514+ append(otherRocketRightSprite[i]);
868515 }
869- if (planetSprite == null) {
870- planetSprite = new ExtendedSprite[4];
871- for (int i = 0; i < planetSprite.length; ++i) {
872- //Allow out of bounds
873- planetSprite[i] = new ExtendedSprite(planetBitmap[i],
874- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(),
875- 1, null, null, null, "planetSprite" + i, true);
876- // append(planetSprite[i]);
877- }
878- }
879- if (earthSprite == null) {
880- earthSprite = new ExtendedSprite(earthBitmap,
881- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 1,
882- null, null, null, "earth", true);
883- append(earthSprite);
884- }
885- if (atmosphereSprite == null) {
886- atmosphereSprite = new ExtendedSprite(atmosphereBitmap,
887- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 1,
888- null, null, null, "atmosphere", true);
889- append(atmosphereSprite);
516+ }
517+ if (miniBossSprite == null) {
518+ miniBossSprite = new ExtendedSprite[4];
519+ for (int i = 0; i < miniBossSprite.length; ++i) {
520+ miniBossSprite[i] = new ExtendedSprite(miniBossBitmap[i],
521+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 3,
522+ null, null, null, "miniBossSprite" + i);
523+ miniBossSprite[i].setVisible(false);
524+ bossSprite[i].setMiniBossSprite(miniBossSprite[i]);
525+ append(miniBossSprite[i]);
890526 }
891527
528+ }
529+ if (planetSprite == null) {
530+ planetSprite = new ExtendedSprite[4];
531+ for (int i = 0; i < planetSprite.length; ++i) {
532+ //Allow out of bounds
533+ planetSprite[i] = new ExtendedSprite(planetBitmap[i],
534+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(),
535+ 1, null, null, null, "planetSprite" + i, true);
536+ // append(planetSprite[i]);
537+ }
538+ }
539+ if (earthSprite == null) {
540+ earthSprite = new ExtendedSprite(earthBitmap,
541+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 1,
542+ null, null, null, "earth", true);
543+ append(earthSprite);
544+ }
545+ if (atmosphereSprite == null) {
546+ atmosphereSprite = new ExtendedSprite(atmosphereBitmap,
547+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 1,
548+ null, null, null, "atmosphere", true);
549+ append(atmosphereSprite);
550+ }
892551
893- if (starSprite == null) {
894- starSprite = new ExtendedSprite[32];
895- for (int i = 0; i < starSprite.length; ++i) {
896- starSprite[i] = new ExtendedSprite(starBitmap,
897- CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 1,
898- null, null, null, "starSprite" + i);
899- append(starSprite[i]);
900- }
552+
553+ if (starSprite == null) {
554+ starSprite = new ExtendedSprite[32];
555+ for (int i = 0; i < starSprite.length; ++i) {
556+ starSprite[i] = new ExtendedSprite(starBitmap,
557+ CANVAS_X, getDISP_WIDTH(), CANVAS_Y, getDISP_HEIGHT(), 1,
558+ null, null, null, "starSprite" + i);
559+ append(starSprite[i]);
901560 }
561+ }
902562
903-
904- for(int i = 0; i < powerupSprite.length; ++i) {
905- powerupSprite[i].setSmokeSprite(smokeSprite);
906- }
907- appendTiledLayer();
563+
564+ for(int i = 0; i < powerupSprite.length; ++i) {
565+ powerupSprite[i].setSmokeSprite(smokeSprite);
908566 }
567+ appendTiledLayer();
909568 }
910569
911570
@@ -1234,12 +893,6 @@
1234893 enemyrocketSprite[i].reset();
1235894 }
1236895 }
1237- /*
1238- if (otherRocketSprite != null) {
1239- for (int i = 0; i < otherRocketSprite.length; ++i) {
1240- otherRocketSprite[i].reset();
1241- }
1242- }*/
1243896 if (otherRocketLeftSprite != null) {
1244897 for (int i = 0; i < otherRocketLeftSprite.length; ++i) {
1245898 otherRocketLeftSprite[i].reset();
@@ -1250,12 +903,6 @@
1250903 otherRocketRightSprite[i].reset();
1251904 }
1252905 }
1253- /*
1254- if (srrocketSprite != null) {
1255- for (int i = 0; i < srrocketSprite.length; ++i) {
1256- srrocketSprite[i].reset();
1257- }
1258- }*/
1259906 if (srrocketLeftSprite != null) {
1260907 for (int i = 0; i < srrocketLeftSprite.length; ++i) {
1261908 srrocketLeftSprite[i].reset();
@@ -1296,7 +943,7 @@
1296943 bossSprite[i].reset();
1297944 }
1298945 }
1299- CurrentBoss = -1;
946+ currentBoss = -1;
1300947 lastKilledBoss = -1;
1301948 if (powerupSprite != null) {
1302949 for (int i = 0; i < powerupSprite.length; ++i) {
@@ -1350,10 +997,10 @@
1350997 paint(g, CANVAS_X, CANVAS_Y);
1351998 }
1352999
1353- synchronized public void UpdateScore(boolean isMP, boolean explode) {
1354- if (spaceCanvas.getStatus().LivesRemaining > 0) {
1355- --spaceCanvas.getStatus().LivesRemaining;
1356- ++spaceCanvas.getStatus().TotalNumLivesLost;
1000+ synchronized public void updateScore(boolean isMP, boolean explode) {
1001+ if (spaceCanvas.getStatus().livesRemaining > 0) {
1002+ --spaceCanvas.getStatus().livesRemaining;
1003+ ++spaceCanvas.getStatus().totalNumLivesLost;
13571004
13581005 if (explode) {
13591006 Position p = spaceRocket.getSPPos();
@@ -1364,7 +1011,7 @@
13641011 }
13651012 }
13661013 }
1367- if (spaceCanvas.getStatus().LivesRemaining == 0) {
1014+ if (spaceCanvas.getStatus().livesRemaining == 0) {
13681015
13691016 spaceRocket.setVisible(false);
13701017 }
@@ -1375,49 +1022,38 @@
13751022 }
13761023
13771024 synchronized public int getCurrentBoss() {
1378- return CurrentBoss;
1025+ return currentBoss;
13791026 }
13801027
1381- void advance() throws MediaException {
1028+ void advance() {
13821029 boolean isMP = gameEngine.isMP();
13831030 try {
1384- controlTransparency.lock();
1385- try {
1386- Status status = spaceCanvas.getStatus();
1387- if ((spaceCanvas.getStatus().FirstTime == false) && (spaceCanvas.getStatus().LivesRemaining != 0)) {
1388- spaceRocket.advance(XDir, YDir, shoot);
1389- if (spaceRocket.collidesWith(fireSprite, false)) {
1390- fireSprite.setImage(fireTransparentBitmap,
1391- fireTransparentBitmap.getWidth(),
1392- fireTransparentBitmap.getHeight());
1393- fireSpriteTransparent.set(true);// = true;
1394- } else if (fireSpriteTransparent.get()) {
1395- fireSpriteTransparent.set(false);// = false;
1396- SpaceRocketMainView view = (SpaceRocketMainView) gameEngine.getView();
1397- if (view.getFirePressed().get()) {
1398- fireSprite.setImage(firePressedBitmap,
1399- firePressedBitmap.getWidth(),
1400- firePressedBitmap.getHeight());
1401- } else {
1402- fireSprite.setImage(fireBitmap,
1403- fireBitmap.getWidth(),
1404- fireBitmap.getHeight());
1405- }
1406- }
1407- } else if (fireSpriteTransparent.get()) {
1408- fireSpriteTransparent.set(false);// = false;
1409- fireSprite.setImage(fireBitmap,
1410- fireBitmap.getWidth(),
1411- fireBitmap.getHeight());
1412- }
1413- } finally {
1414- controlTransparency.unlock();
1415- }
1416- /* if((CreateSPSpaceRocket == true) && (gameEngine.isMP() == false)) {
1417-
1418- }*/
1419- if (gameEngine.isSoundSupported()) {
1420- explodeSnd.prefetch();
1031+ Status status = spaceCanvas.getStatus();
1032+ if (!spaceCanvas.getStatus().firstTime && spaceCanvas.getStatus().livesRemaining != 0) {
1033+ spaceRocket.advance(XDir, YDir, shoot);
1034+ if (spaceRocket.collidesWith(fireSprite, false)) {
1035+ fireSprite.setImage(fireTransparentBitmap,
1036+ fireTransparentBitmap.getWidth(),
1037+ fireTransparentBitmap.getHeight());
1038+ fireSpriteTransparent.set(true);// = true;
1039+ } else if (fireSpriteTransparent.get()) {
1040+ fireSpriteTransparent.set(false);// = false;
1041+ SpaceRocketMainView view = (SpaceRocketMainView) gameEngine.getView();
1042+ if (view.getFirePressed().get()) {
1043+ fireSprite.setImage(firePressedBitmap,
1044+ firePressedBitmap.getWidth(),
1045+ firePressedBitmap.getHeight());
1046+ } else {
1047+ fireSprite.setImage(fireBitmap,
1048+ fireBitmap.getWidth(),
1049+ fireBitmap.getHeight());
1050+ }
1051+ }
1052+ } else if (fireSpriteTransparent.get()) {
1053+ fireSpriteTransparent.set(false);// = false;
1054+ fireSprite.setImage(fireBitmap,
1055+ fireBitmap.getWidth(),
1056+ fireBitmap.getHeight());
14211057 }
14221058 for(int i = 0; i < smokeSprite.length; ++i) {
14231059 if(smokeSprite[i].isVisible()) {
@@ -1467,12 +1103,6 @@
14671103 }
14681104 }
14691105 if ((shouldLaunchPlanet) && (rand.nextInt(30) == 0)) {
1470- /* for(int i = 0; i < planetSprite.length; ++i) {
1471- if(planetSprite[i].isVisible() == false) {
1472- planetSprite[i].launch(3, 1);
1473- break;
1474- }
1475- }*/
14761106 planetSprite[rand.nextInt(4)].launch(3, 1);
14771107 }
14781108 for (int i = 0; i < planetSprite.length; ++i) {
@@ -1481,17 +1111,17 @@
14811111 advancePlanet = 0;
14821112 }
14831113 }
1484- if ((isMP) && (spaceRocket != null) && (spaceCanvas.getStatus().LivesRemaining == 0)) {
1114+ if ((isMP) && (spaceRocket != null) && (spaceCanvas.getStatus().livesRemaining == 0)) {
14851115 spaceRocket.setVisible(false);
14861116 }
14871117 if ((isMP) && (connectionThread != null) &&
14881118 (connectionThread.getLiveGivenByOtherPlayer())) {
1489- if (spaceCanvas.getStatus().LivesRemaining == 0) {
1119+ if (spaceCanvas.getStatus().livesRemaining == 0) {
14901120 spaceRocket.reset();
14911121 spaceRocket.setVisible(true);
14921122 }
1493- if (spaceCanvas.getStatus().LivesRemaining < 15) {
1494- ++spaceCanvas.getStatus().LivesRemaining;
1123+ if (spaceCanvas.getStatus().livesRemaining < 15) {
1124+ ++spaceCanvas.getStatus().livesRemaining;
14951125 }
14961126 giveLifeSprite[0].setVisible(true);
14971127 }
@@ -1499,24 +1129,6 @@
14991129 boolean alreadyChecked = false;
15001130 if (bossSprite[i].isVisible()) {
15011131 bossSprite[i].advance();
1502- /* for (int j = 0; j < srrocketSprite.length; ++j) {
1503- if ((srrocketSprite[j].isVisible())) {
1504- if (bossSprite[i].collisionCheck(srrocketSprite[j])) {
1505- alreadyChecked = true;
1506- ++status.Score;
1507- if (isMP) {
1508- synchronized (this) {
1509- // scoreIncreased = true;
1510- ++ScoreQueue;
1511- }
1512- }
1513- }
1514- }
1515- if ((isMP) && (otherRocketSprite[j].isVisible())) {
1516- if (bossSprite[i].collisionCheck(otherRocketSprite[j])) {
1517- }
1518- }
1519- }*/
15201132 alreadyChecked = checkBossCollision(srrocketLeftSprite, true, i);
15211133 if (!alreadyChecked) {
15221134 alreadyChecked = checkBossCollision(srrocketRightSprite, true, i);
@@ -1551,68 +1163,8 @@
15511163 if (!alreadyChecked) {
15521164 checkBossCollision(otherDoubleDamageRocketSprite, false, i);
15531165 }
1554- /* for (int j = 0; j < tripleRocketSpriteCenter.length; ++j) {
1555- if (tripleRocketSpriteCenter[j].isVisible()) {
1556- if ((!alreadyChecked) &&
1557- (bossSprite[i].collisionCheck(tripleRocketSpriteCenter[j]))) {
1558- alreadyChecked = true;
1559- ++status.Score;
1560- if (isMP) {
1561- synchronized (this) {
1562- // scoreIncreased = true;
1563- ++ScoreQueue;
1564- }
1565- }
1566- }
1567- }
1568- }
1569- for (int j = 0; j < tripleRocketSpriteLeft.length; ++j) {
1570- if (tripleRocketSpriteLeft[j].isVisible()) {
1571- if ((!alreadyChecked) &&
1572- (bossSprite[i].collisionCheck(tripleRocketSpriteLeft[j]))) {
1573- alreadyChecked = true;
1574- ++status.Score;
1575- if (isMP) {
1576- synchronized (this) {
1577- // scoreIncreased = true;
1578- ++ScoreQueue;
1579- }
1580- }
1581- }
1582- }
1583- }
1584- for (int j = 0; j < tripleRocketSpriteRight.length; ++j) {
1585- if (tripleRocketSpriteRight[j].isVisible()) {
1586- if ((!alreadyChecked) &&
1587- (bossSprite[i].collisionCheck(tripleRocketSpriteRight[j]))) {
1588- alreadyChecked = true;
1589- ++status.Score;
1590- if (isMP) {
1591- synchronized (this) {
1592- // scoreIncreased = true;
1593- ++ScoreQueue;
1594- }
1595- }
1596- }
1597- }
1598- }
1599- for (int j = 0; j < doubleDamageRocketSprite.length; ++j) {
1600- if (doubleDamageRocketSprite[j].isVisible()) {
1601- if ((!alreadyChecked) &&
1602- (bossSprite[i].collisionCheck(doubleDamageRocketSprite[j]))) {
1603- alreadyChecked = true;
1604- ++status.Score;
1605- if (isMP) {
1606- synchronized (this) {
1607- // scoreIncreased = true;
1608- ++ScoreQueue;
1609- }
1610- }
1611- }
1612- }
1613- }*/
16141166 if (spaceRocket.collisionCheck(bossSprite[i])) {
1615- UpdateScore(isMP, true);
1167+ updateScore(isMP, true);
16161168 }
16171169 }
16181170 }
@@ -1626,25 +1178,23 @@
16261178 System.out.println("killedBoss out of range: " + killedBoss);
16271179 }
16281180 }
1629- if ((!isMP) && (spaceCanvas.getStatus().Score == BOSS1_SCORE) && (!bossSprite[0].getLaunched()) &&
1181+ if ((!isMP) && (spaceCanvas.getStatus().score == BOSS1_SCORE) && (!bossSprite[0].getLaunched()) &&
16301182 (!bossSpriteLaunched[0])) {
16311183 bossSprite[0].launch();
16321184 bossSpriteLaunched[0] = true;
16331185 if (gameEngine.getSoundOn()) {
16341186 gameEngine.getVibrator().vibrate(500);
16351187 }
1636- // display.flashBacklight(500);
16371188 }
1638- if ((!isMP) && (spaceCanvas.getStatus().Score >= BOSS2_SCORE) && (!bossSprite[1].getLaunched()) &&
1189+ if ((!isMP) && (spaceCanvas.getStatus().score >= BOSS2_SCORE) && (!bossSprite[1].getLaunched()) &&
16391190 (!bossSpriteLaunched[1]) && (bossSprite[0].getBossDestroyedSP())) {
16401191 bossSprite[1].launch();
16411192 bossSpriteLaunched[1] = true;
16421193 if (gameEngine.getSoundOn()) {
16431194 gameEngine.getVibrator().vibrate(500);
16441195 }
1645- // display.flashBacklight(500);
16461196 }
1647- if ((!isMP) && (spaceCanvas.getStatus().Score >= BOSS3_SCORE) && (!bossSprite[2].getLaunched()) &&
1197+ if ((!isMP) && (spaceCanvas.getStatus().score >= BOSS3_SCORE) && (!bossSprite[2].getLaunched()) &&
16481198 (!bossSpriteLaunched[2]) && (bossSprite[0].getBossDestroyedSP()) &&
16491199 (bossSprite[1].getBossDestroyedSP())) {
16501200 bossSprite[2].launch();
@@ -1652,9 +1202,8 @@
16521202 if (gameEngine.getSoundOn()) {
16531203 gameEngine.getVibrator().vibrate(500);
16541204 }
1655- // display.flashBacklight(500);
16561205 }
1657- if ((!isMP) && (spaceCanvas.getStatus().Score >= BOSS4_SCORE) && (!bossSprite[3].getLaunched()) &&
1206+ if ((!isMP) && (spaceCanvas.getStatus().score >= BOSS4_SCORE) && (!bossSprite[3].getLaunched()) &&
16581207 (!bossSpriteLaunched[3]) && (bossSprite[0].getBossDestroyedSP()) &&
16591208 (bossSprite[1].getBossDestroyedSP()) && (bossSprite[2].getBossDestroyedSP())) {
16601209 bossSprite[3].launch();
@@ -1679,12 +1228,6 @@
16791228 }
16801229
16811230 if ((!isMP) && (rand.nextInt(POWERUP_RATE) == 0)) {
1682- /* for(int i = 0; i < powerupSprite.length; ++i) {
1683- if(powerupSprite[i].isVisible() == false) {
1684- powerupSprite[i].launch(false);
1685- break;
1686- }
1687- }*/
16881231 int i = rand.nextInt(4);
16891232 if (powerupSprite[i].isVisible() == false) {
16901233 powerupSprite[i].launch();
@@ -1696,19 +1239,19 @@
16961239 int type = powerupSprite[i].collisionCheck(spaceRocket);
16971240 if (type != 0) {
16981241 spaceRocket.setPowerupType(type);
1699- ++spaceCanvas.getStatus().NumPowerupsTaken;
1242+ ++spaceCanvas.getStatus().numPowerupsTaken;
17001243 switch (type) {
17011244 case 1: //IncreaseLives
1702- if (spaceCanvas.getStatus().LivesRemaining < MAX_NUM_LIVES) {
1703- ++spaceCanvas.getStatus().LivesRemaining;
1245+ if (spaceCanvas.getStatus().livesRemaining < MAX_NUM_LIVES) {
1246+ ++spaceCanvas.getStatus().livesRemaining;
17041247 }
17051248 break;
17061249 case 2: //More damage to boss
17071250 if (isMP) {
1708- if ((CurrentBoss >= 0) && (CurrentBoss < BOSS_COUNT)) {
1709- bossSprite[CurrentBoss].DoubleDamage();
1251+ if ((currentBoss >= 0) && (currentBoss < BOSS_COUNT)) {
1252+ bossSprite[currentBoss].DoubleDamage();
17101253 } else {
1711- System.out.println("CurrentBoss: " + CurrentBoss);
1254+ System.out.println("CurrentBoss: " + currentBoss);
17121255 }
17131256 spaceRocket.EnableDoubleDamage();
17141257 spaceRocket.changeFrame(SpaceRocketSprite.DOUBLE_DAMAGE_FRAME);
@@ -1740,22 +1283,22 @@
17401283 }
17411284 if ((isMP) && (connectionThread != null)) {
17421285 if (connectionThread.getPowerupTakenByOtherShip()) {
1743- if ((CurrentPowerup <= 3) && (CurrentPowerup >= 0)) {
1744- powerupSprite[CurrentPowerup].reset();
1745- ++spaceCanvas.getStatus().CoopNumPowerupsTaken;
1286+ if ((currentPowerup <= 3) && (currentPowerup >= 0)) {
1287+ powerupSprite[currentPowerup].reset();
1288+ ++spaceCanvas.getStatus().coopNumPowerupsTaken;
17461289 }
17471290
1748- switch (CurrentPowerup) {
1291+ switch (currentPowerup) {
17491292 case 0:
17501293 // otherSpaceRocket.IncrementLives();
17511294 break;
17521295 case 1:
17531296 otherSpaceRocket.EnableDoubleDamage();
17541297 otherSpaceRocket.changeFrame(SpaceRocketSprite.DOUBLE_DAMAGE_FRAME);
1755- if ((CurrentBoss >= 0) && (CurrentBoss < BOSS_COUNT)) {
1756- bossSprite[CurrentBoss].DoubleDamage();
1298+ if ((currentBoss >= 0) && (currentBoss < BOSS_COUNT)) {
1299+ bossSprite[currentBoss].DoubleDamage();
17571300 } else {
1758- System.out.println("CurrentBoss: " + CurrentBoss);
1301+ System.out.println("CurrentBoss: " + currentBoss);
17591302 }
17601303 break;
17611304 case 2:
@@ -1770,28 +1313,15 @@
17701313 }
17711314 }
17721315 if (connectionThread.getPowerupLaunched()) {
1773- CurrentPowerup = connectionThread.getPowerupNum();
1774- if ((CurrentPowerup > 3) || (CurrentPowerup < 0)) {
1775- System.out.println("CurrentPowerup error: " + CurrentPowerup);
1316+ currentPowerup = connectionThread.getPowerupNum();
1317+ if ((currentPowerup > 3) || (currentPowerup < 0)) {
1318+ System.out.println("CurrentPowerup error: " + currentPowerup);
17761319 } else {
1777- powerupSprite[CurrentPowerup].launch(
1320+ powerupSprite[currentPowerup].launch(
17781321 connectionThread.getPowerupXPos(),
17791322 connectionThread.getPowerupYPos());
17801323 }
17811324 }
1782- /* if(connectionThread.getPowerupTakenByOtherShip()) {
1783- powerupSprite[CurrentPowerup].reset();
1784- }*/
1785-
1786- /* if((isMP) && (otherSpaceRocket != null)) {
1787- ++CurrentUpdateFrame;
1788- if(CurrentUpdateFrame >= UPDATE_POSITION) {
1789- CurrentUpdateFrame = 0;
1790- otherSpaceRocket.move(false);
1791- } else {
1792- otherSpaceRocket.move(true);
1793- }
1794- }*/
17951325 if ((isMP) && (otherSpaceRocket != null)) {
17961326 if (connectionThread.getOtherSRPosSet()) {
17971327
@@ -1822,8 +1352,6 @@
18221352 }
18231353 }
18241354
1825-
1826-
18271355 if (connectionThread.getshouldLaunchRocketOtherShip()) {
18281356 otherSpaceRocket.launchRocket();
18291357 }
@@ -1833,20 +1361,11 @@
18331361 } else {
18341362 if ((otherSpaceRocket.isVisible() == false) &&
18351363 (otherSpaceRocket.GetNumLives() > 0)) {
1836- // int lifenum = otherSpaceRocket.GetNumLives();
1837- // int xpos = otherSpaceRocket.getX();
1838- // int ypos = otherSpaceRocket.getY();
18391364 otherSpaceRocket.reset();
18401365 otherSpaceRocket.setVisible(true);
18411366 }
18421367 }
18431368 }
1844- // if(otherSpaceRocket.GetNumLives() <= 0) {
1845- // spaceCanvas.setGameOver();
1846- // }
1847- /* if(connectionThread.getShouldResetOtherShip()) {
1848- otherSpaceRocket.reset();
1849- }*/
18501369
18511370 if (animatedBackground != null) {
18521371 animatedBackground.advance();
@@ -1926,7 +1445,7 @@
19261445 if ((connectionThread != null) && (connectionThread.getBossLaunched())) {
19271446 int BossNum = connectionThread.GetBossNum();
19281447 if ((BossNum >= 0) && (BossNum < BOSS_COUNT)) {
1929- if (CurrentBoss != BossNum) {
1448+ if (currentBoss != BossNum) {
19301449 bossSprite[BossNum].launch(connectionThread.getBossXPos(),
19311450 connectionThread.getBossXSpeed(),
19321451 connectionThread.getBossYSpeed());
@@ -1934,10 +1453,9 @@
19341453 if (gameEngine.getSoundOn()) {
19351454 gameEngine.getVibrator().vibrate(500);
19361455 }
1937- //display.flashBacklight(500);
19381456 System.out.println("Boss: " + BossNum + " has been launched");
19391457 synchronized (this) {
1940- CurrentBoss = BossNum;
1458+ currentBoss = BossNum;
19411459 }
19421460 }
19431461 } else {
@@ -1946,36 +1464,12 @@
19461464 }
19471465 }
19481466
1949- /* connectionThread.getEnemyStats(currentEnemyStats);
1950- if((currentEnemyStats.positionX != previousEnemyStats.positionX) ||
1951- (currentEnemyStats.positionY != previousEnemyStats.positionY) ||
1952- (currentEnemyStats.speedX != previousEnemyStats.speedX) ||
1953- (currentEnemyStats.speedY != previousEnemyStats.speedY)) {
1954- previousEnemyStats.positionX = currentEnemyStats.positionX;
1955- previousEnemyStats.positionY = currentEnemyStats.positionY;
1956- previousEnemyStats.speedX = currentEnemyStats.speedX;
1957- previousEnemyStats.speedY = currentEnemyStats.speedY;
1958-
1959- for(int i = 0; i < enemy.length; ++i) {
1960- if(enemy[i].isVisible() == false) {
1961- enemy[i].launch(currentEnemyStats);
1962- break;
1963- }
1964- }
1965- }*/
1966- /* for(int i = 0; i < enemy.length; ++i) {
1967- if(enemy[i].isVisible()) {
1968- System.out.println("Enemy: " + i + " " +
1969- enemy[i].getX() + " " + enemy[i].getY());
1970- }
1971- }*/
1972-
19731467 for (int i = 0; i < enemy.length; ++i) {
19741468 if (enemy[i].isVisible()) {
19751469 enemy[i].advance();
1976- if (spaceCanvas.getStatus().FirstTime == false) {
1470+ if (spaceCanvas.getStatus().firstTime == false) {
19771471 if (spaceRocket.collisionCheck(enemy[i])) {
1978- UpdateScore(isMP, true);
1472+ updateScore(isMP, true);
19791473 if (i < (enemy.length - 1)) {
19801474 ++i;
19811475 } else {
@@ -1988,26 +1482,6 @@
19881482 }
19891483 }
19901484
1991- /* for(int i = 0; i < enemy.length; ++i) {
1992- if(enemy[i].isVisible()) {
1993- enemy[i].advance();
1994- if(spaceRocket.collisionCheck(enemy[i])) {
1995- --status.LivesRemaining;
1996- }
1997- if(rand.nextInt(40) == 0) {
1998- enemy[i].launchMissile();
1999- }
2000- for(int j = 0; j < srrocketSprite.length; ++j) {
2001- if(srrocketSprite[j].isVisible()) {
2002- if(enemy[i].collisionCheck(srrocketSprite[j])) {
2003- ++status.Score;
2004- }
2005-
2006- }
2007- }
2008- }
2009- }*/
2010-
20111485 for (int i = 0; i < enemy.length; ++i) {
20121486 if (enemy[i].isVisible()) {
20131487 if (rand.nextInt(20) == 0) {
@@ -2016,8 +1490,8 @@
20161490 for (int j = 0; j < srrocketLeftSprite.length; ++j) {
20171491 if ((srrocketLeftSprite[j].isVisible()) && (enemy[i].isVisible())) {
20181492 if (enemy[i].collisionCheck(srrocketLeftSprite[j])) {
2019- spaceCanvas.getStatus().GameTicks += 100;
2020- ++spaceCanvas.getStatus().Score;
1493+ spaceCanvas.getStatus().gameTicks += 100;
1494+ ++spaceCanvas.getStatus().score;
20211495
20221496 if (i < (enemy.length - 1)) {
20231497 ++i;
@@ -2040,8 +1514,8 @@
20401514 for (int j = 0; j < srrocketRightSprite.length; ++j) {
20411515 if ((srrocketRightSprite[j].isVisible()) && (enemy[i].isVisible())) {
20421516 if (enemy[i].collisionCheck(srrocketRightSprite[j])) {
2043- spaceCanvas.getStatus().GameTicks += 100;
2044- ++spaceCanvas.getStatus().Score;
1517+ spaceCanvas.getStatus().gameTicks += 100;
1518+ ++spaceCanvas.getStatus().score;
20451519
20461520 if (i < (enemy.length - 1)) {
20471521 ++i;
@@ -2071,79 +1545,9 @@
20711545 updateRocketScore(otherTripleRocketSpriteRight, false, i);
20721546 updateRocketScore(otherDoubleDamageRocketSprite, false, i);
20731547 }
2074-
2075- /* for (int k = 0; k < tripleRocketSpriteCenter.length; ++k) {
2076- if (tripleRocketSpriteCenter[k].isVisible() && (enemy[i].isVisible())) {
2077- if (enemy[i].collisionCheck(tripleRocketSpriteCenter[k])) {
2078- status.GameTicks += 100;
2079- ++status.Score;
2080-
2081- if (i < (enemy.length - 1)) {
2082- ++i;
2083- } else {
2084- break;
2085- }
2086- }
2087- }
2088- }
2089- for (int k = 0; k < tripleRocketSpriteLeft.length; ++k) {
2090- if (tripleRocketSpriteLeft[k].isVisible() && (enemy[i].isVisible())) {
2091- if (enemy[i].collisionCheck(tripleRocketSpriteLeft[k])) {
2092- status.GameTicks += 100;
2093- ++status.Score;
2094-
2095- if (i < (enemy.length - 1)) {
2096- ++i;
2097- } else {
2098- break;
2099- }
2100- }
2101- }
2102- }
2103- for (int k = 0; k < tripleRocketSpriteRight.length; ++k) {
2104- if (tripleRocketSpriteRight[k].isVisible() && (enemy[i].isVisible())) {
2105- if (enemy[i].collisionCheck(tripleRocketSpriteRight[k])) {
2106- status.GameTicks += 100;
2107- ++status.Score;
2108-
2109- if (i < (enemy.length - 1)) {
2110- ++i;
2111- } else {
2112- break;
2113- }
2114- }
2115- }
2116- }
2117- for (int k = 0; k < doubleDamageRocketSprite.length; ++k) {
2118- if (doubleDamageRocketSprite[k].isVisible() && (enemy[i].isVisible())) {
2119- if (enemy[i].collisionCheck(doubleDamageRocketSprite[k])) {
2120- status.GameTicks += 100;
2121- ++status.Score;
2122-
2123- if (i < (enemy.length - 1)) {
2124- ++i;
2125- } else {
2126- break;
2127- }
2128- }
2129- }
2130- }*/
21311548 }
21321549 }
21331550
2134- /* if (gameEngine.isMP()) {
2135- for (int i = 0; i < enemy.length; ++i) {
2136- if (enemy[i].isVisible()) {
2137- for (int j = 0; j < otherRocketSprite.length; ++j) {
2138- if ((otherRocketSprite[j].isVisible()) && (enemy[i].isVisible())) {
2139- if (enemy[i].collisionCheck(otherRocketSprite[j])) {
2140- }
2141- ++i;
2142- }
2143- }
2144- }
2145- }
2146- }*/
21471551 updateRocketPosition(srrocketLeftSprite);
21481552 updateRocketPosition(srrocketRightSprite);
21491553 updateRocketPosition(tripleRocketSpriteCenter);
@@ -2158,117 +1562,6 @@
21581562 updateRocketPosition(otherTripleRocketSpriteRight);
21591563 updateRocketPosition(otherDoubleDamageRocketSprite);
21601564 }
2161- /* for (int i = 0; i < srrocketSprite.length; ++i) {
2162- for (int j = 0; j < enemyrocketSprite.length; ++j) {
2163- if ((srrocketSprite[i].isVisible()) && (enemyrocketSprite[j].isVisible())) {
2164- if (srrocketSprite[i].checkCollision(enemyrocketSprite[j])) {
2165- for (int k = 0; k < explosion.length; ++k) {
2166- if (explosion[k].isVisible() == false) {
2167- explosion[k].explode(srrocketSprite[i].getX(),
2168- srrocketSprite[i].getY());
2169- break;
2170- }
2171- }
2172- if (i < srrocketSprite.length - 1) {
2173- ++i;
2174- } else {
2175- break;
2176- }
2177- }
2178- }
2179- }
2180- }
2181- for (int i = 0; i < tripleRocketSpriteCenter.length; ++i) {
2182- for (int j = 0; j < enemyrocketSprite.length; ++j) {
2183- if ((tripleRocketSpriteCenter[i].isVisible()) &&
2184- (enemyrocketSprite[j].isVisible())) {
2185- if (tripleRocketSpriteCenter[i].checkCollision(enemyrocketSprite[j])) {
2186- for (int k = 0; k < explosion.length; ++k) {
2187- if (explosion[k].isVisible() == false) {
2188- explosion[k].explode(tripleRocketSpriteCenter[i].getX(),
2189- tripleRocketSpriteCenter[i].getY());
2190- break;
2191- }
2192- }
2193- if (i < tripleRocketSpriteCenter.length - 1) {
2194- ++i;
2195- } else {
2196- break;
2197- }
2198- }
2199- }
2200- }
2201- }
2202- for (int i = 0; i < tripleRocketSpriteLeft.length; ++i) {
2203- for (int j = 0; j < enemyrocketSprite.length; ++j) {
2204- if ((tripleRocketSpriteLeft[i].isVisible()) &&
2205- (enemyrocketSprite[j].isVisible())) {
2206- if (tripleRocketSpriteLeft[i].checkCollision(enemyrocketSprite[j])) {
2207- for (int k = 0; k < explosion.length; ++k) {
2208- if (explosion[k].isVisible() == false) {
2209- explosion[k].explode(tripleRocketSpriteLeft[i].getX(),
2210- tripleRocketSpriteLeft[i].getY());
2211- break;
2212- }
2213- }
2214- if (i < tripleRocketSpriteLeft.length - 1) {
2215- ++i;
2216- } else {
2217- break;
2218- }
2219- }
2220- }
2221- }
2222- }
2223- for (int i = 0; i < tripleRocketSpriteRight.length; ++i) {
2224- for (int j = 0; j < enemyrocketSprite.length; ++j) {
2225- if ((tripleRocketSpriteRight[i].isVisible()) &&
2226- (enemyrocketSprite[j].isVisible())) {
2227- if (tripleRocketSpriteRight[i].checkCollision(enemyrocketSprite[j])) {
2228- for (int k = 0; k < explosion.length; ++k) {
2229- if (explosion[k].isVisible() == false) {
2230- explosion[k].explode(tripleRocketSpriteRight[i].getX(),
2231- tripleRocketSpriteRight[i].getY());
2232- break;
2233- }
2234- }
2235- if (i < tripleRocketSpriteRight.length - 1) {
2236- ++i;
2237- } else {
2238- break;
2239- }
2240- }
2241- }
2242- }
2243- }
2244- for (int i = 0; i < doubleDamageRocketSprite.length; ++i) {
2245- for (int j = 0; j < enemyrocketSprite.length; ++j) {
2246- if ((doubleDamageRocketSprite[i].isVisible()) &&
2247- (enemyrocketSprite[j].isVisible())) {
2248- if (doubleDamageRocketSprite[i].checkCollision(enemyrocketSprite[j])) {
2249- for (int k = 0; k < explosion.length; ++k) {
2250- if (explosion[k].isVisible() == false) {
2251- explosion[k].explode(doubleDamageRocketSprite[i].getX(),
2252- doubleDamageRocketSprite[i].getY());
2253- break;
2254- }
2255- }
2256- if (i < doubleDamageRocketSprite.length - 1) {
2257- ++i;
2258- } else {
2259- break;
2260- }
2261- }
2262- }
2263- }
2264- }*/
2265- /* for(int i = 0; i < enemy.length; ++i) {
2266- for(int j = 0; j < srrocketSprite.length; ++j) {
2267- if(enemy[i].collisionCheck(srrocketSprite[j])) {
2268- System.out.println("Lovit");
2269- }
2270- }
2271- }*/
22721565 for (int i = 0; i < srrocketLeftSprite.length; ++i) {
22731566 if (srrocketLeftSprite[i].isVisible()) {
22741567 srrocketLeftSprite[i].advance();
@@ -2319,14 +1612,14 @@
23191612 for (int i = 0; i < enemyrocketSprite.length; ++i) {
23201613 if (enemyrocketSprite[i].isVisible()) {
23211614 enemyrocketSprite[i].advance();
2322- if (spaceCanvas.getStatus().FirstTime == false) {
1615+ if (spaceCanvas.getStatus().firstTime == false) {
23231616 if (spaceRocket.collisionCheck(enemyrocketSprite[i])) {
23241617 // synchronized (this) {
23251618 /* --status.LivesRemaining;
23261619
23271620 ++status.TotalNumLivesLost;
23281621 spaceRocket.LifeLost();*/
2329- UpdateScore(isMP, true);
1622+ updateScore(isMP, true);
23301623 // }
23311624 }
23321625 }
@@ -2408,14 +1701,6 @@
24081701 }
24091702 }
24101703
2411- /* if((isMP) && (otherSpaceRocket != null)) {
2412- if(otherSpaceRocket.GetScore() <= 0) {
2413- otherSpaceRocket.setVisible(false);
2414- } else {
2415- otherSpaceRocket.setVisible(true);
2416- }
2417- }*/
2418-
24191704 for (int i = 0; i < explosion.length; ++i) {
24201705 if (explosion[i].isVisible()) {
24211706 explosion[i].advance();
@@ -2460,8 +1745,8 @@
24601745 if (rocket[k].isVisible() && (enemy[i].isVisible())) {
24611746 if (enemy[i].collisionCheck(rocket[k])) {
24621747 if (updateScore) {
2463- spaceCanvas.getStatus().GameTicks += 100;
2464- ++spaceCanvas.getStatus().Score;
1748+ spaceCanvas.getStatus().gameTicks += 100;
1749+ ++spaceCanvas.getStatus().score;
24651750 }
24661751
24671752 if (i < (enemy.length - 1)) {
@@ -2481,7 +1766,7 @@
24811766 if (bossSprite[i].collisionCheck(rocket[j])) {
24821767 // alreadyChecked = true;
24831768 if (updateScore) {
2484- ++spaceCanvas.getStatus().Score;
1769+ ++spaceCanvas.getStatus().score;
24851770 }
24861771 return true;
24871772 }
@@ -2497,112 +1782,47 @@
24971782 if (isMP) {
24981783 synchronized (this) {
24991784 // scoreIncreased = true;
2500- ++ScoreQueue;
1785+ ++scoreQueue;
25011786 }
25021787 }
25031788 }
25041789
2505- /**
2506- * @return the arrowsSprite
2507- */
25081790 public synchronized Sprite getArrowsSprite() {
25091791 return arrowsSprite;
25101792 }
25111793
2512- /**
2513- * @return the fireSprite
2514- */
25151794 public synchronized Sprite getFireSprite() {
25161795 return fireSprite;
25171796 }
25181797
2519- /**
2520- * @return the arrowsBitmap
2521- */
25221798 public synchronized Bitmap getArrowsBitmap() {
25231799 return arrowsBitmap;
25241800 }
25251801
2526- /**
2527- * @return the arrowsPressedBitmap
2528- */
25291802 public synchronized Bitmap getArrowsPressedBitmap() {
25301803 return arrowsPressedBitmap;
25311804 }
25321805
2533- /**
2534- * @return the fireBitmap
2535- */
25361806 public synchronized Bitmap getFireBitmap() {
25371807 return fireBitmap;
25381808 }
25391809
2540- /**
2541- * @return the firePressedBitmap
2542- */
25431810 public synchronized Bitmap getFirePressedBitmap() {
25441811 return firePressedBitmap;
25451812 }
25461813
2547- /**
2548- * @return the fireTransparentBitmap
2549- */
25501814 public synchronized Bitmap getFireTransparentBitmap() {
25511815 return fireTransparentBitmap;
25521816 }
25531817
2554- /**
2555- * @return the controlTransparency
2556- */
2557- public ReentrantLock getControlTransparency() {
2558- return controlTransparency;
2559- }
2560-
2561- /**
2562- * @return the fireSpriteTransparent
2563- */
25641818 public AtomicBoolean getFireSpriteTransparent() {
25651819 return fireSpriteTransparent;
25661820 }
25671821
2568- /**
2569- * @param dISP_WIDTH the dISP_WIDTH to set
2570- */
2571- public static synchronized void setDISP_WIDTH(int dISP_WIDTH) {
2572- DISP_WIDTH = dISP_WIDTH;
2573- }
2574-
2575- /**
2576- * @return the dISP_WIDTH
2577- */
2578- public static synchronized int getDISP_WIDTH() {
2579- return DISP_WIDTH;
2580- }
2581-
2582- /**
2583- * @param dISP_HEIGHT the dISP_HEIGHT to set
2584- */
2585- public static synchronized void setDISP_HEIGHT(int dISP_HEIGHT) {
2586- DISP_HEIGHT = dISP_HEIGHT;
2587- }
2588-
2589- /**
2590- * @return the dISP_HEIGHT
2591- */
2592- public static synchronized int getDISP_HEIGHT() {
2593- return DISP_HEIGHT;
2594- }
2595-
2596- /**
2597- * @return the animatedBackground
2598- */
25991822 public AnimatedBackground getAnimatedBackground() {
26001823 return animatedBackground;
26011824 }
26021825
2603- /**
2604- * @param animatedBackground the animatedBackground to set
2605- */
26061826 public void setAnimatedBackground(AnimatedBackground animatedBackground) {
26071827 this.animatedBackground = animatedBackground;
26081828 }
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/old/SendThread.java
--- a/core/src/com/headwayent/spacerocket/old/SendThread.java Fri Nov 26 20:21:46 2021 +0200
+++ b/core/src/com/headwayent/spacerocket/old/SendThread.java Sun Nov 28 20:15:56 2021 +0200
@@ -251,11 +251,11 @@
251251 data.putFloat(xPosPerc);
252252 data.putFloat(yPosPerc);
253253 Status status = spaceCanvas.getStatus();
254- int score = status.Score;
254+ int score = status.score;
255255 /* if(score > 0) {
256256 System.out.println("Error: Score increased to " + score);
257257 }*/
258- int lives = status.LivesRemaining;
258+ int lives = status.livesRemaining;
259259 /* data[5] = (byte)(score >> 8);
260260 data[6] = (byte)(score);
261261 data[7] = (byte)(lives);*/
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/old/SpaceRocketMain.java
--- a/core/src/com/headwayent/spacerocket/old/SpaceRocketMain.java Fri Nov 26 20:21:46 2021 +0200
+++ b/core/src/com/headwayent/spacerocket/old/SpaceRocketMain.java Sun Nov 28 20:15:56 2021 +0200
@@ -12,7 +12,6 @@
1212 import com.headwayent.spacerocket.OrientationManager;
1313 import com.headwayent.spacerocket.ReceiveMessageActivity;
1414 import com.headwayent.spacerocket.SendMessageActivity;
15-import com.headwayent.spacerocket.SessionStore;
1615 import com.headwayent.spacerocket.SpaceRocketActivity;
1716 import com.headwayent.spacerocket.Twitter.TwitterUtils;
1817 import com.headwayent.microedition.midlet.MIDlet;
@@ -548,25 +547,6 @@
548547 return accelerometerOn;
549548 }
550549
551- /* public Command getBeginCommand() {
552- return BeginCommand;
553- }*/
554- public boolean getIsPIMSupported() {
555- return isPIMSupported;
556- }
557-
558- public boolean getIsSMSSupported() {
559- return isSMSSupported;
560- }
561-
562- /* public String getPMIVersion() {
563- return PMIVersion;
564- }
565-
566- public String getSMSVersion() {
567- return SMSVersion;
568- }*/
569-
570550 synchronized public void setSelectionMade() {
571551 selectionMade = true;
572552 }
@@ -587,210 +567,30 @@
587567 return spaceCanvas;
588568 }
589569
590- /* public DatagramConnection getSocketConnection() {
591- return socketconn;
592- }
593-
594- public InputStream getInputStream() {
595- return in;
596- }
597-
598- public OutputStream getOutputStream() {
599- return out;
600- }
601-
602- public ConnectionThread getConnectionThread() {
603- return connectionThread;
604- }*/
605570 public String getName() {
606571 return Name;
607572 }
608573
609- /* public String getEncryptedName() {
610- return encryptedName;
611- }*/
612-
613574 public String getPassword() {
614575 return Password;
615576 }
616577
617- /* public String getEncryptedPassword() {
618- return encryptedPassword;
619- }*/
620-
621578 public String[] getUserID() {
622579 return UserID;
623580 }
624581
625-/* public String[] getEncryptedUserID() {
626- return encryptedUserID;
627- }*/
628-
629- public RecordStore getNameRecordStore() {
630- return rsName;
631- }
632-
633- public RecordStore getPasswordRecordStore() {
634- return rsPassword;
635- }
636-
637- public RecordStore getUserIDRecordStore() {
638- return rsUserID;
639- }
640-
641- public RecordStore getIPRecordStore() {
642- return rsIP;
643- }
644-
645- public RecordEnumeration getNameEnum() {
646- return recName;
647- }
648-
649- public RecordEnumeration getPasswordEnum() {
650- return recPassword;
651- }
652-
653- public RecordEnumeration getUserIDEnum() {
654- return recUserID;
655- }
656-
657- public RecordEnumeration getIPEnum() {
658- return recIP;
659- }
660-
661582 public String getCurrentIP() {
662583 return currentIP;
663584 }
664585
665- /* public Encryptor getEncryptor() {
666- return encryptor;
667- }*/
668-
669- public Context getContext() {
670- return context;
671- }
672-
673- public synchronized View getView() {
674- return view;
675- }
676-
677- public synchronized void setView(View view) {
678- this.view = view;
679- if (spaceCanvas != null) {
680- spaceCanvas.setView(view);
681- }
682- }
683-
684- public SurfaceHolder getSurfaceHolder() {
685- surfaceHolderLock.lock();
686- try {
687- return surfaceHolder;
688- } finally {
689- surfaceHolderLock.unlock();
690- }
691- }
692-
693- public void setSurfaceHolder(SurfaceHolder surfaceHolder) {
694- surfaceHolderLock.lock();
695- try {
696- this.surfaceHolder = surfaceHolder;
697- } finally {
698- surfaceHolderLock.unlock();
699- }
700- }
701-
702- public void sendTweet(String message) {
703- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(
704- getCurrentActivity());
705- if (TwitterUtils.isAuthenticated(preferences)) {
706- try {
707-
708- if (message.length() <=
709- com.headwayent.SpaceRocket.Twitter.Constants.TWITTER_MAX_CHARACTERS) {
710- TwitterUtils.sendTweet(preferences, message);
711- }
712- } catch (Exception e) {
713- // TODO Auto-generated catch block
714- e.printStackTrace();
715- }
716- }
717- }
718-
719- public void uploadDataToFacebook(String message) {
720- if (facebook.isSessionValid()) {
721- Status status = getSpaceCanvas().getStatus();
722- Bundle params = new Bundle();
723- params.putString("title", "SpaceRocket");
724- params.putString("message", message);
725- // params.putString("picture",
726- // "http://spacerocket-game.chickenkiller.com/ic_launcher.png");
727- getmAsyncRunner().request("me/feed", params, "POST",
728- new WallPostRequestListener(), null);
729- }
730- }
731-
732- public SpaceRocketMain(Context context, SurfaceHolder holder, View view) {
733-
734- // TODO Auto-generated constructor stub
735- synchronized (this) {
736- this.context = context;
737- this.surfaceHolder = holder;
738- this.view = view;
739- }
740-
741-// encryptor = new Encryptor("whjmd8d8brv3cxf8gc76fq2wg");
742- try {
743- highScore = RecordStore.openRecordStore(context , "highscores", true);
744- } catch (RecordStoreFullException e) {
745- // TODO Auto-generated catch block
746- e.printStackTrace();
747- } catch (RecordStoreNotFoundException e) {
748- // TODO Auto-generated catch block
749- e.printStackTrace();
750- } catch (RecordStoreException e) {
751- // TODO Auto-generated catch block
752- e.printStackTrace();
753- }
754- RecordStore rsShipOptions = null;
755- try {
756- rsName = RecordStore.openRecordStore(context , "name", true);
757- rsPassword = RecordStore.openRecordStore(context , "password", true);
758- rsUserID = RecordStore.openRecordStore(context , "UserID", true);
759- rsIP = RecordStore.openRecordStore(context , "httpip", true);
586+ public SpaceRocketMain() {
587+ highScore = RecordStore.openRecordStore(context , "highscores", true);
588+ rsName = RecordStore.openRecordStore(context , "name", true);
589+ rsPassword = RecordStore.openRecordStore(context , "password", true);
590+ rsUserID = RecordStore.openRecordStore(context , "UserID", true);
591+ rsIP = RecordStore.openRecordStore(context , "httpip", true);
760592
761- /* byte [] b = rsName.getRecord(0);
762- int namesize = rsName.getRecordSize(1);
763- int passwordsize = rsPassword.getRecordSize(1);
764- NameByte = new byte[namesize];
765- PasswordByte = new byte[passwordsize];
766- if(namesize != 0) {
767- NameByte = rsName.getRecord(0);
768- Name = NameByte.toString();
769- }
770- if(passwordsize != 0) {
771- PasswordByte = rsPassword.getRecord(0);
772- Password = PasswordByte.toString();
773- }*/
774- } catch (RecordStoreFullException e) {
775- // TODO Auto-generated catch block
776- e.printStackTrace();
777- } catch (RecordStoreNotFoundException e) {
778- // TODO Auto-generated catch block
779- // e.printStackTrace();
780- // this.setShipOptionsIndex(0);
781- } catch (RecordStoreException e) {
782- // TODO Auto-generated catch block
783- e.printStackTrace();
784- }
785- try {
786- rsShipOptions = RecordStore.openRecordStore(context , "shipoptions", false);
787- } catch (RecordStoreFullException e1) {
788- // TODO Auto-generated catch block
789- e1.printStackTrace();
790- } catch (RecordStoreException e1) {
791- // TODO Auto-generated catch block
792- e1.printStackTrace();
793- } catch (RecordStoreNotFoundException e1) {
593+ rsShipOptions = RecordStore.openRecordStore(context , "shipoptions", false);
794594 // TODO Auto-generated catch block
795595 this.setSoundOn(true);
796596 this.setAccelerometerOn(true);
@@ -798,49 +598,6 @@
798598 //If no options selected then save screen orientation based on current
799599 //screen orientation. Don't do it in the constructor. Do it when set
800600 this.setOrientationIndex(-1);
801- }
802- boolean noFb = false;
803- try {
804- rsFB = RecordStore.openRecordStore(context, "fb", false);
805- } catch (RecordStoreFullException e1) {
806- // TODO Auto-generated catch block
807- e1.printStackTrace();
808- } catch (RecordStoreException e1) {
809- // TODO Auto-generated catch block
810- e1.printStackTrace();
811- } catch (RecordStoreNotFoundException e1) {
812- // TODO Auto-generated catch block
813- e1.printStackTrace();
814- noFb = true;
815- }
816- if (!noFb) {
817- try {
818- recFB = rsFB.enumerateRecords(null, null, false);
819- if (recFB.hasNextElement()) {
820- try {
821- byte[] b = recFB.nextRecord();
822- if (b[0] == 1) {
823- boolean restored = SessionStore.restore(facebook, context);
824- if (!restored) {
825- facebook.authorize((SpaceRocketActivity)context,
826- new String[] { "publish_stream" },
827- new LoginButton.LoginDialogListener());
828- setWaitingForFacebookAuth();
829- }
830- }
831- } catch (InvalidRecordIDException e) {
832- // TODO Auto-generated catch block
833- e.printStackTrace();
834- } catch (RecordStoreException e) {
835- // TODO Auto-generated catch block
836- e.printStackTrace();
837- }
838- }
839- } catch (RecordStoreNotOpenException e) {
840- // TODO Auto-generated catch block
841- e.printStackTrace();
842- }
843- }
844601 comparator = new HighScoreComparator();
845602 try {
846603 recEnum = highScore.enumerateRecords(null,
@@ -884,95 +641,6 @@
884641 checkIP();
885642 }
886643
887- public void checkIP() {
888- try {
889- if(recIP.hasNextElement()) {
890-
891- currentIP = new String(recIP.nextRecord());
892- } else {
893- currentIP = HttpSend.IP;
894- }
895- } catch (InvalidRecordIDException e) {
896- // TODO Auto-generated catch block
897- e.printStackTrace();
898- } catch (RecordStoreNotOpenException e) {
899- // TODO Auto-generated catch block
900- e.printStackTrace();
901- } catch (RecordStoreException e) {
902- // TODO Auto-generated catch block
903- e.printStackTrace();
904- }
905- }
906-
907- public void updateUserID() {
908- if (recUserID.hasNextElement()) {
909- try {
910- UserID = new String[recUserID.numRecords()];
911- // encryptedUserID = new String[recUserID.numRecords()];
912- int i = 0;
913- while (recUserID.hasNextElement()) {
914- UserID[i++] = new String(recUserID.nextRecord());
915- // UserID[i++] = encryptor.decryptString(encryptedUserID[i].getBytes());
916- }
917- } catch (InvalidRecordIDException e) {
918- // TODO Auto-generated catch block
919- e.printStackTrace();
920- } catch (RecordStoreNotOpenException e) {
921- // TODO Auto-generated catch block
922- e.printStackTrace();
923- } catch (RecordStoreException e) {
924- // TODO Auto-generated catch block
925- e.printStackTrace();
926- }/* catch(CryptoException e) {
927- e.printStackTrace();
928- }*/
929- recUserID.reset();
930- }
931- }
932-
933- public void updateUsernameAndPassword() {
934- if (recName.hasNextElement()) {
935- try {
936- Name = new String(recName.nextRecord()).trim();
937- // Name = encryptor.decryptString(encryptedName.getBytes());
938- } catch(NullPointerException e) {
939- Name = "";
940- } catch (InvalidRecordIDException e) {
941- // TODO Auto-generated catch block
942- e.printStackTrace();
943- } catch (RecordStoreNotOpenException e) {
944- // TODO Auto-generated catch block
945- e.printStackTrace();
946- } catch (RecordStoreException e) {
947- // TODO Auto-generated catch block
948- e.printStackTrace();
949- }/* catch(CryptoException e) {
950- e.printStackTrace();
951- }*/
952- recName.reset();
953- }
954- if (recPassword.hasNextElement()) {
955- try {
956- Password = new String(recPassword.nextRecord()).trim();
957- // Password = encryptor.decryptString(encryptedPassword.getBytes());
958- } catch(NullPointerException e) {
959- Password = "";
960- } catch (InvalidRecordIDException e) {
961- // TODO Auto-generated catch block
962- e.printStackTrace();
963- } catch (RecordStoreNotOpenException e) {
964- // TODO Auto-generated catch block
965- e.printStackTrace();
966- } catch (RecordStoreException e) {
967- // TODO Auto-generated catch block
968- e.printStackTrace();
969- }/* catch(CryptoException e) {
970- e.printStackTrace();
971- }*/
972- recPassword.reset();
973- }
974- }
975-
976644 public boolean getInMessageMenu() {
977645 return inMessageMenu.get();
978646 }
@@ -1014,20 +682,6 @@
1014682 return shouldStart;
1015683 }
1016684
1017- public void setSaveCommand() {
1018- // spaceCanvas.removeCommand(OkCommand);
1019- // spaceCanvas.addCommand(ExitCommand);
1020- // spaceCanvas.addCommand(NewCommand);
1021- // setNewCommand();
1022-
1023- OptionsMenuManager.removeCommand(SpaceRocketActivity.MENU_NAME,
1024- OkCommand.getName());
1025- OptionsMenuManager.addCommand(SpaceRocketActivity.MENU_NAME,
1026- 0, ExitCommand.getId(), ExitCommand.getOrder(), ExitCommand.getName());
1027- OptionsMenuManager.addCommand(SpaceRocketActivity.MENU_NAME,
1028- 0, NewCommand.getId(), NewCommand.getOrder(), NewCommand.getName());
1029- }
1030-
1031685 @Override
1032686 public void destroyApp(boolean unconditional)
1033687 throws MIDletStateChangeException {
@@ -1051,49 +705,6 @@
1051705
1052706 }
1053707
1054- /* if((gameThread != null) && (connectionThread != null) && (isMP())) {
1055- gameThread.interrupt();
1056- connectionThread.interrupt();
1057- gameThread.getSendThread().interrupt();
1058- }*/
1059- if (this.isMP()) {
1060- closeConnection();
1061- }
1062- if (spaceCanvas.getHighScoreEnum() != null) {
1063- spaceCanvas.getHighScoreEnum().destroy();
1064- spaceCanvas.setHighScoreEnumNull();
1065- }
1066- /* if((connectionThread != null) && (isMP())) {
1067- connectionThread.requestStop();
1068- }*/
1069- connectionThread = null;
1070- gameThread = null;
1071- spaceCanvas = null;
1072- if (!isMP()) {
1073- try {
1074- highScore.closeRecordStore();
1075- } catch (RecordStoreNotOpenException e) {
1076- // TODO Auto-generated catch block
1077- e.printStackTrace();
1078- } catch (RecordStoreException e) {
1079- // TODO Auto-generated catch block
1080- e.printStackTrace();
1081- }
1082- }
1083- try {
1084- rsName.closeRecordStore();
1085- rsPassword.closeRecordStore();
1086- rsUserID.closeRecordStore();
1087- // rsIP.closeRecordStore();
1088- } catch (RecordStoreNotOpenException e) {
1089- // TODO Auto-generated catch block
1090- e.printStackTrace();
1091- } catch (RecordStoreException e) {
1092- // TODO Auto-generated catch block
1093- e.printStackTrace();
1094- }
1095-
1096- System.gc();
1097708 } catch (Exception e) {
1098709 System.out.println("Exception in destroyApp" + e.toString());
1099710 }
@@ -1166,23 +777,6 @@
1166777 setShouldOpenMenu(true);
1167778 }
1168779 }
1169- /* new Thread(new Runnable() {
1170-
1171- @Override
1172- public void run() {
1173- // TODO Auto-generated method stub
1174- synchronized (this) {
1175- try {
1176- wait(3000);
1177- } catch (InterruptedException e) {
1178- // TODO Auto-generated catch block
1179- e.printStackTrace();
1180- }
1181- }
1182- ((SpaceRocketActivity)getContext()).openOptionsMenu();
1183- }
1184-
1185- }).start();*/
1186780 }
1187781
1188782 }
@@ -1308,26 +902,6 @@
1308902 (!spaceCanvas.getStatus().getGameOver())) {
1309903 saveSession();
1310904 }
1311- synchronized (this) {
1312-
1313-
1314- if (recName != null) {
1315- recName.destroy();
1316- }
1317- if (recPassword != null) {
1318- recPassword.destroy();
1319- }
1320- if (recUserID != null) {
1321- recUserID.destroy();
1322- }
1323- if (recIP != null) {
1324- recIP.destroy();
1325- }
1326- if (http != null) {
1327- // http.destroyConnection();
1328- }
1329- }
1330-
1331905 try {
1332906 destroyApp(false);
1333907 } catch (MIDletStateChangeException ex) {
@@ -1370,8 +944,8 @@
1370944 xPos = Float.floatToIntBits(xPosF);
1371945 yPos = Float.floatToIntBits(yPosF);
1372946 Status status = spaceCanvas.getStatus();
1373- score = status.Score;
1374- lives = status.LivesRemaining;
947+ score = status.score;
948+ lives = status.livesRemaining;
1375949 BossSprite [] boss = gfxMgmt.getBossSprite();
1376950 for(int i = 0; i < boss.length; ++i) {
1377951 if((boss[i].getLaunched()) && (!boss[i].getBossDestroyedSP())) {
@@ -1412,18 +986,8 @@
1412986 if (exitingLock.tryLock()) {
1413987 try {
1414988 Exit();
1415- /* spaceCanvas = new ExtendedCanvas(this);
1416- spaceCanvas.addCommand(SPCommand);
1417- spaceCanvas.addCommand(MPCommand);
1418- spaceCanvas.addCommand(ExitCommand);
1419- spaceCanvas.setCommandListener(this);
1420- gameThread = new GameThread(spaceCanvas, this);
1421- spaceCanvas.start();
1422- gameThread.start();*/
1423989 spaceCanvas = null;
1424990 gameThread = null;
1425- // pimList = null;
1426- // smsSender = null;
1427991 System.gc();
1428992 try {
1429993 startApp();
@@ -1433,8 +997,6 @@
1433997 exitingLock.unlock();
1434998 }
1435999 }
1436- // setMP(false);
1437- // spaceCanvas.reset();
14381000 }
14391001
14401002 public void commandAction(int id) {
@@ -1649,12 +1211,7 @@
16491211 private void resumeSession() {
16501212 try {
16511213 RecordStore rs = RecordStore.openRecordStore(context, "save", false);
1652- /* spaceCanvas.removeCommand(MPCommand);
1653- spaceCanvas.removeCommand(SPCommand);
1654- spaceCanvas.removeCommand(ContinueCommand);
1655- spaceCanvas.addCommand(ExitCommand);
1656- spaceCanvas.addCommand(PauseCommand);*/
1657-
1214+
16581215 OptionsMenuManager.removeCommand(SpaceRocketActivity.MENU_NAME,
16591216 MPCommand.getName());
16601217 OptionsMenuManager.removeCommand(SpaceRocketActivity.MENU_NAME,
@@ -1728,7 +1285,7 @@
17281285 String name = new String(b);
17291286 // Status status = spaceCanvas.getStatus();
17301287 // int score = spaceCanvas.getStatus().Score;
1731- String str = String.valueOf(spaceCanvas.getStatus().Score);
1288+ String str = String.valueOf(spaceCanvas.getStatus().score);
17321289 int difficulty = difficultySelection.getDifficulty();
17331290 String temp = name + ", " + str;
17341291 String HighScoreString = "";
@@ -1998,27 +1555,4 @@
19981555 public boolean isReady() {
19991556 return ready.get();
20001557 }
2001-
2002- /**
2003- * @return the facebook
2004- */
2005- public Facebook getFacebook() {
2006- return facebook;
2007- }
2008-
2009- /**
2010- * @return the mAsyncRunner
2011- */
2012- public AsyncFacebookRunner getmAsyncRunner() {
2013- return mAsyncRunner;
2014- }
2015-
2016- public void setFacebookNameCreated(boolean b) {
2017- facebookNameCreated.set(b);
2018- }
2019-
2020- public boolean isFaceBookNameCreated() {
2021- return facebookNameCreated.get();
2022- }
2023-
20241558 }
diff -r 2b50b86952e8 -r 05cc135621c2 core/src/com/headwayent/spacerocket/old/Status.java
--- a/core/src/com/headwayent/spacerocket/old/Status.java Fri Nov 26 20:21:46 2021 +0200
+++ b/core/src/com/headwayent/spacerocket/old/Status.java Sun Nov 28 20:15:56 2021 +0200
@@ -3,26 +3,85 @@
33
44 public class Status {
55
6- public int Score;
7- public int LivesRemaining;
8- private boolean GameOver = false;
9- public int GameTicks;
10- public boolean FirstTime = true;
11- public int NumPowerupsTaken;
12- public int CoopNumPowerupsTaken;
13- public int TotalNumLivesLost;
14- public int CoopTotalNumLivesLost;
6+ public int score;
7+ public int livesRemaining;
8+ private boolean gameOver;
9+ public int gameTicks;
10+ public boolean firstTime = true;
11+ public int numPowerupsTaken;
12+ public int coopNumPowerupsTaken;
13+ public int totalNumLivesLost;
14+ public int coopTotalNumLivesLost;
1515
16- synchronized public void setGameOver(boolean gameOver) {
17- GameOver = gameOver;
18- /* try {
19- throw(new Exception());
20- } catch(Exception e) {
21- e.printStackTrace();
22- }*/
16+ public int getScore() {
17+ return score;
2318 }
2419
25- synchronized public boolean getGameOver() {
26- return GameOver;
20+ public void setScore(int score) {
21+ this.score = score;
22+ }
23+
24+ public int getLivesRemaining() {
25+ return livesRemaining;
26+ }
27+
28+ public void setLivesRemaining(int livesRemaining) {
29+ this.livesRemaining = livesRemaining;
30+ }
31+
32+ public boolean isGameOver() {
33+ return gameOver;
34+ }
35+
36+ public void setGameOver(boolean gameOver) {
37+ this.gameOver = gameOver;
38+ }
39+
40+ public int getGameTicks() {
41+ return gameTicks;
42+ }
43+
44+ public void setGameTicks(int gameTicks) {
45+ this.gameTicks = gameTicks;
46+ }
47+
48+ public boolean isFirstTime() {
49+ return firstTime;
50+ }
51+
52+ public void setFirstTime(boolean firstTime) {
53+ this.firstTime = firstTime;
54+ }
55+
56+ public int getNumPowerupsTaken() {
57+ return numPowerupsTaken;
58+ }
59+
60+ public void setNumPowerupsTaken(int numPowerupsTaken) {
61+ this.numPowerupsTaken = numPowerupsTaken;
62+ }
63+
64+ public int getCoopNumPowerupsTaken() {
65+ return coopNumPowerupsTaken;
66+ }
67+
68+ public void setCoopNumPowerupsTaken(int coopNumPowerupsTaken) {
69+ this.coopNumPowerupsTaken = coopNumPowerupsTaken;
70+ }
71+
72+ public int getTotalNumLivesLost() {
73+ return totalNumLivesLost;
74+ }
75+
76+ public void setTotalNumLivesLost(int totalNumLivesLost) {
77+ this.totalNumLivesLost = totalNumLivesLost;
78+ }
79+
80+ public int getCoopTotalNumLivesLost() {
81+ return coopTotalNumLivesLost;
82+ }
83+
84+ public void setCoopTotalNumLivesLost(int coopTotalNumLivesLost) {
85+ this.coopTotalNumLivesLost = coopTotalNumLivesLost;
2786 }
2887 }