Skip to content

Commit

Permalink
spike adjustment
Browse files Browse the repository at this point in the history
moving exes and spinners from tick-based to time based
fixed movement bug where column reset to 0 and stuck
fixed displaying the stars between levels
  • Loading branch information
awlzac committed Mar 18, 2015
1 parent 122c6d0 commit 6a27044
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 115 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions app/manifest-merger-release-report.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- Merging decision tree log ---
manifest
ADDED from AndroidManifest.xml:1:1
xmlns:android
ADDED from AndroidManifest.xml:1:11
package
ADDED from AndroidManifest.xml:2:5
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
android:versionName
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
android:versionCode
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
android:installLocation
ADDED from AndroidManifest.xml:3:5
application
ADDED from AndroidManifest.xml:5:5
MERGED from com.android.support:appcompat-v7:21.0.2:16:5
MERGED from com.android.support:support-v4:21.0.2:16:5
android:label
ADDED from AndroidManifest.xml:6:9
android:allowBackup
ADDED from AndroidManifest.xml:5:18
android:icon
ADDED from AndroidManifest.xml:7:9
android:theme
ADDED from AndroidManifest.xml:9:9
android:hardwareAccelerated
ADDED from AndroidManifest.xml:8:9
activity#com.bulsy.wbtempest.MainActivity
ADDED from AndroidManifest.xml:10:9
android:screenOrientation
ADDED from AndroidManifest.xml:13:13
android:label
ADDED from AndroidManifest.xml:12:13
android:configChanges
ADDED from AndroidManifest.xml:14:13
android:name
ADDED from AndroidManifest.xml:11:13
intent-filter#android.intent.action.MAIN+android.intent.category.LAUNCHER
ADDED from AndroidManifest.xml:15:13
action#android.intent.action.MAIN
ADDED from AndroidManifest.xml:16:17
android:name
ADDED from AndroidManifest.xml:16:25
category#android.intent.category.LAUNCHER
ADDED from AndroidManifest.xml:17:17
android:name
ADDED from AndroidManifest.xml:17:27
uses-permission#android.permission.WRITE_EXTERNAL_STORAGE
ADDED from AndroidManifest.xml:21:5
android:name
ADDED from AndroidManifest.xml:21:22
uses-sdk
INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
MERGED from com.android.support:appcompat-v7:21.0.2:15:5
MERGED from com.android.support:support-v4:21.0.2:15:5
android:targetSdkVersion
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
android:minSdkVersion
INJECTED from AndroidManifest.xml:0:0
INJECTED from AndroidManifest.xml:0:0
12 changes: 7 additions & 5 deletions app/src/main/java/com/bulsy/wbtempest/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
*/
public class Board {
static final int BOARD_DEPTH = 400;
static final int FIRST_SPIKE_LEVEL = 4; // level at which we first see spikes
static final int MAX_COLS = 40; // max conceivable number of columns
private static final int BASE_EX_FIRE_BPS = 35; // bps chance per tick that we fire an ex at player
private static final int NUMSCREENS = 6;
public static final int NUMSCREENS = 6; // number of different screen layouts

private int levnum;
private int exesct;
Expand Down Expand Up @@ -52,11 +53,11 @@ public void init(View v, int levnum) {
int x, y, oldx=0, oldy=0;
exesct = 5 + levnum*2;
exesCanMove = (levnum != 1);
if (levnum < 4)
if (levnum < FIRST_SPIKE_LEVEL)
spikespct = (float)0;
else if (levnum < 6)
else if (levnum < FIRST_SPIKE_LEVEL +1)
spikespct = (float) 0.5;
else if (levnum < 9)
else if (levnum < FIRST_SPIKE_LEVEL*2)
spikespct = (float) 0.75;
else spikespct = (float) 1;
float rad_dist;
Expand Down Expand Up @@ -189,7 +190,8 @@ else if (levnum < 9)
oldx = x;
oldy = y;
}
for (; x <= cx*7/4; x+= cx*2/3/(ncols/2), y-=(cy*2.5)/(ncols)){
int diffx = x - cx; // we may have a remainder, and on some screen sizes this may screw up rendering
for (; x <= cx*7/4 + diffx; x+= cx*2/3/(ncols/2), y-=(cy*2.5)/(ncols)){
Column col = new Column(oldx, oldy, x, y);
columns.add(col);
oldx = x;
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/java/com/bulsy/wbtempest/Crawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class Crawler {
private static final int CHEIGHT_HP = (int) (CHEIGHT * 0.6); // slightly more than half
private static final int MAX_MISSILES = 6;
private MainActivity act;
private double vpos;
private double pos;
private double vpos=0;
private double pos=0;
private boolean visible;
private ArrayList<Missile> missiles;
private Board board;
Expand Down Expand Up @@ -87,6 +87,8 @@ public List<int[]> getCoords() {
int colnum = getColumn();
int pose = (int)pos % C_POSES / 2; // each pose here is doubled for more manageable movement

if (colnum >= board.getColumns().size())
pose = board.getColumns().size() * C_POSES - 1;
Column column = board.getColumns().get(colnum);
int[] pt1 = column.getFrontPoint1();
int[] pt2 = column.getFrontPoint2();
Expand Down Expand Up @@ -166,7 +168,9 @@ public boolean isVisible() {
return visible;
}

public void accel(double factor) {vpos = -factor * SPEED;}
public void accel(double factor) {
vpos = -factor * SPEED;
}

public void accelRight(){
vpos = SPEED;
Expand Down
56 changes: 36 additions & 20 deletions app/src/main/java/com/bulsy/wbtempest/Ex.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ public class Ex {
// possible states of an ex
private static enum State {STRAIGHT, JUMPRIGHT1, JUMPLEFT1, JUMPRIGHT2, JUMPLEFT2, LANDRIGHT1, LANDRIGHT2, LANDLEFT1, LANDLEFT2};

private static int INIT_JUMPINTERVAL = 25; // ticks
private static int JUMPINTERVAL_FLYING = 2; // ticks, while ex is still flying in the center
private static long INIT_JUMPINTERVAL = (long)(PlayScreen.ONESEC_NANOS*2/3);
private static float BOARD_TOP_SPEEDUP_FACTOR = 0.7f;
private static long JUMPINTERVAL_FLYING = (long)(PlayScreen.ONESEC_NANOS/15); //while ex is still flying in the center
private static double INIT_SPEED = 65;
private int col;
private boolean isPod = false;
private double z = Board.BOARD_DEPTH;
private boolean visible;
private int jumptimer = 0;
private State prefdir = State.JUMPRIGHT1; // initial predisp to jump right
private State s = prefdir;
private boolean spawning = true;
private int jumpInterval;
private long jumpInterval;
private long nextJumpTime;
private long currJumpStarted;
private Board board;
private static List<Ex> usedExes = new LinkedList<Ex>(); // recycle exes

Expand All @@ -57,9 +59,7 @@ void init(int col, boolean isPod, Board board) {
this.isPod = isPod;
visible = true;
this.board = board;
jumpInterval = INIT_JUMPINTERVAL - board.getLevelNumber()/2;
if (jumpInterval < 10)
jumpInterval = 10;
jumpInterval = INIT_JUMPINTERVAL - (PlayScreen.ONESEC_NANOS * board.getLevelNumber()/100);
}

public static Ex getNewEx(int col, boolean isPod, Board board) {
Expand All @@ -70,7 +70,7 @@ public static Ex getNewEx(int col, boolean isPod, Board board) {
else
ex = new Ex();
ex.init(col, isPod, board);
Log.d("wbt", "usedExes has "+usedExes.size());
//Log.d("wbt", "usedExes has "+usedExes.size());
return ex;
}

Expand All @@ -95,13 +95,23 @@ public void setPod(boolean isPod) {
* Spawns an additional ex, traveling in the opposite direction.
*/
public Ex spawn() {
return spawn(false);
}
public Ex spawn(boolean moveColumn){
Ex spawn = Ex.getNewEx(col, false, board);
spawn.z = z;
if (prefdir == State.JUMPLEFT1)
spawn.prefdir = State.JUMPRIGHT1;
else
spawn.prefdir = State.JUMPLEFT1;
return spawn;
spawn.z = z;
if (prefdir == State.JUMPLEFT1)
spawn.prefdir = State.JUMPRIGHT1;
else
spawn.prefdir = State.JUMPLEFT1;
if (moveColumn) {
// step around the continuous issue
if (col == 0)
col++;
else
col--;
}
return spawn;
}

/**
Expand All @@ -120,13 +130,14 @@ public void move(int xbound, int crawlerCol, float elapsedTime) {
z -= INIT_SPEED * elapsedTime/2; // go faster when they're just spinning aimlessly before hitting the board.

int ncols = board.getColumns().size();
long now = System.nanoTime();
switch (s) {
case STRAIGHT:
if ((board.exesCanMove() && !isPod) || z <= 0 || z > Board.BOARD_DEPTH){
// if exes are allowed to move column to column, or if we're already at
// the front of the board, move every now and then.
jumptimer--;
if (jumptimer <= 0) {
if (now >= nextJumpTime) {
currJumpStarted = now;
if (z < Board.BOARD_DEPTH && spawning)
{ // haven't chosen a direction yet
spawning = false;
Expand Down Expand Up @@ -201,18 +212,23 @@ public void move(int xbound, int crawlerCol, float elapsedTime) {
case LANDRIGHT2:
case LANDLEFT2:
if (z < Board.BOARD_DEPTH) {
jumptimer = jumpInterval;
if (z <= 0) {
jumptimer = (int)(.6 * jumpInterval);
nextJumpTime = jumpInterval;
if (z <= 0) { // ex is already at top - speed it up.
nextJumpTime = (long)(BOARD_TOP_SPEEDUP_FACTOR * nextJumpTime);
}
nextJumpTime += currJumpStarted;
}
else { // ex is still flying
jumptimer = JUMPINTERVAL_FLYING;
nextJumpTime = currJumpStarted + JUMPINTERVAL_FLYING;
}
s = State.STRAIGHT;
}
}

public boolean isJumping() {
return !(s == State.STRAIGHT);
}

public boolean isVisible() {
return visible;
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/bulsy/wbtempest/Missile.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
*
*/
public class Missile {
private static int BASE_SPEED = 500;
static int HEIGHT = 8;
private static int HEIGHT_H = HEIGHT/2;
private static int ENEMY_MISSILE_SPEED_FACTOR = 3;
private static final int BASE_SPEED = 500;
static final int HEIGHT = 8;
private static final int HEIGHT_H = HEIGHT/2;
private static final int ENEMY_MISSILE_SPEED_FACTOR = 3;
private int colnum;
private int zpos;
private boolean visible;
Expand Down
Loading

0 comments on commit 6a27044

Please sign in to comment.