Skip to content

Commit

Permalink
ready for v1.0, time for google play
Browse files Browse the repository at this point in the history
  • Loading branch information
tsapree committed Jul 1, 2013
1 parent bafdf6c commit 053a465
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pro.oneredpixel.deflektorclassic"
android:versionCode="4"
android:versionName="0.2alpha" >
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
Expand Down
43 changes: 43 additions & 0 deletions src/pro/oneredpixel/deflektorclassic/Deflektor.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class Deflektor implements ApplicationListener {
boolean controlsTapThenDrag = true; //êîñíóòüñÿ çåðêàëà äëÿ âûáîðà, ïîòîì îòïóñòèòü è ïðîâåñòè ïî ýêðàíó äëÿ ïîâîðîòà
int controlsSensitivity = 4;
int unlockedLevel = 60;
int scores[]; //0..32767 - î÷êè çà óðîâåíü, &32768, &65536, &131072 - îïöèè, çâåçäû çà ïðîõîæäåíèå
int appGfxId = APPGFX_AMIGA;
boolean difficultyClassic = true; //ïîâûøåííàÿ, êëàññè÷åñêàÿ ñëîæíîñòü

Expand Down Expand Up @@ -221,6 +222,19 @@ void loadSettings() {
soundEnabled = prefs.getBoolean("Sound", true);
unlockedLevel = prefs.getInteger("UnlockedLevel", 1);
if (unlockedLevel>61 || unlockedLevel<1) unlockedLevel=1;

scores=new int[countOfLevels];
String packedScores=prefs.getString("Scores"," ");
int sum=0;
for (int i=0;i<packedScores.length()/3-1;i++) {
scores[i]=unserialize(packedScores,i);
sum+=scores[i];
sum&=0xFFFF;
};
if ((sum!=unserialize(packedScores,packedScores.length()/3-1)) || (sum==-1)) {
for (int i=0;i<countOfLevels;i++) scores[i]=0;
}

appGfxId = prefs.getInteger("GfxType",APPGFX_AMIGA);
if ((appGfxId>APPGFX_MODERN) || (appGfxId<APPGFX_ZX)) appGfxId=APPGFX_AMIGA;
difficultyClassic = prefs.getBoolean("DifficultyClassic", false);
Expand All @@ -232,11 +246,40 @@ void saveSettings() {
Preferences prefs = Gdx.app.getPreferences("DeflektorPreferences");
prefs.putBoolean("Sound", soundEnabled);
prefs.putInteger("UnlockedLevel", unlockedLevel);

String packedScores="";
int sum=0;
for (int i=0;i<countOfLevels;i++) {
packedScores+=serialize(scores[i]);
sum+=scores[i];
sum&=0xFFFF;
}
packedScores+=serialize(sum);
prefs.putString("Scores", packedScores);

prefs.putInteger("GfxType", appGfxId);
prefs.putBoolean("DifficultyClassic", difficultyClassic);
prefs.putInteger("Sensitivity",controlsSensitivity);
prefs.flush();
}
// 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
final String serkey="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_%";

int unserialize(String s, int n) {
int rez=0;
int r;
if (((n*3+2)>=s.length()) || (n<0)) return -1;
for (int i=0;i<3;i++) {
r=serkey.indexOf(s.charAt(i+n*3));
if (r<0) return -1;
rez=rez*64+r;
};
return rez;
}

String serialize(int i) {
return ""+serkey.charAt((i>>12)&0x3F)+serkey.charAt((i>>6)&0x3F)+serkey.charAt(i&0x3F);
}


@Override
Expand Down
3 changes: 2 additions & 1 deletion src/pro/oneredpixel/deflektorclassic/GameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public void render(SpriteBatch batch) {
};
if (topScore<countScore) {
topScore=countScore;
app.scores[app.playingLevel-1]=topScore;
if (!playedNewRecord) app.playSound(Deflektor.SND_NEWRECORD);
playedNewRecord=true;
}
Expand Down Expand Up @@ -1336,7 +1337,7 @@ public void initGame() {
energy=0;
overheat=0;

topScore=500;
topScore=app.scores[app.playingLevel-1];
countScore=0;
countKilledGremlins=0;
countBurnedCells=0;
Expand Down

0 comments on commit 053a465

Please sign in to comment.