gameover working again
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -99,4 +99,9 @@ public class CanvasView extends View // Dev2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMove(int angle, int speed)
|
||||
{
|
||||
Foreground.SendMove(angle, speed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,4 +163,10 @@ public class GameMenu extends GameStateInterface
|
||||
{
|
||||
Rect(canvas, 0f, 160f, 0f, 90f, Color.parseColor("lime"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SendMove(int angle, int speed) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class GamePlay extends GameStateInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPostBack)
|
||||
if ((!isPostBack) && (GameState != GS_GAMEOVER))
|
||||
canvasView.OnGameStateChanged(GameState);
|
||||
}
|
||||
|
||||
@@ -444,7 +444,6 @@ public class GamePlay extends GameStateInterface
|
||||
handler.postDelayed(runnable, 100);
|
||||
}
|
||||
|
||||
// TODO game state
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
@@ -1875,4 +1874,39 @@ public class GamePlay extends GameStateInterface
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SendMove(int angle, int speed)
|
||||
{
|
||||
if (angle <= 315 && angle >= 225 ) // Left
|
||||
{
|
||||
if(CanBlockGoLeft())
|
||||
{
|
||||
MoveBlockLeft();
|
||||
canvasView.postInvalidate();
|
||||
}
|
||||
}
|
||||
else if (angle <= 135 && angle >= 45 ) // Right
|
||||
{
|
||||
if(CanBlockGoRight())
|
||||
{
|
||||
MoveBlockRight();
|
||||
canvasView.postInvalidate();
|
||||
}
|
||||
}
|
||||
else if (angle <= 225 && angle >= 135 ) // Rotate Right
|
||||
{
|
||||
RotateBlockRight();
|
||||
canvasView.postInvalidate();
|
||||
}
|
||||
else if ((angle <= 30 || angle >= 330 ) && (speed >= 80)) // go down
|
||||
{
|
||||
// Hard Drop
|
||||
while (CanBlockGoDown())
|
||||
{
|
||||
MoveBlockDown();
|
||||
}
|
||||
canvasView.postInvalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,4 +122,6 @@ public abstract class GameStateInterface
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
public abstract void SendMove(int angle, int speed);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,19 @@ package mangavalk.tetris;
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdSize;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
import com.samsung.android.sdk.SsdkUnsupportedException;
|
||||
import com.samsung.android.sdk.gesture.Sgesture;
|
||||
import com.samsung.android.sdk.gesture.SgestureHand;
|
||||
import com.samsung.android.sdk.gesture.SgestureHand.Info;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.PointF;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class MainActivity extends Activity
|
||||
@@ -17,10 +24,30 @@ public class MainActivity extends Activity
|
||||
CanvasView canvasClass;
|
||||
private AdView adView;
|
||||
|
||||
private Sgesture mGesture;
|
||||
private SgestureHand mHand;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Gesture. Samsung only
|
||||
mGesture = new Sgesture();
|
||||
|
||||
try {
|
||||
mGesture.initialize(this);
|
||||
} catch (IllegalArgumentException e) {
|
||||
//Error Handling
|
||||
} catch (SsdkUnsupportedException e2) {
|
||||
//Error Handling
|
||||
}
|
||||
|
||||
if(mGesture.isFeatureEnabled(Sgesture.TYPE_HAND_PRIMITIVE)){
|
||||
mHand = new SgestureHand(Looper.getMainLooper(), mGesture);
|
||||
mHand.start(Sgesture.TYPE_HAND_PRIMITIVE, mChangeListener);
|
||||
}
|
||||
|
||||
|
||||
FrameLayout ll;
|
||||
|
||||
ll = new FrameLayout(this);
|
||||
@@ -37,6 +64,8 @@ public class MainActivity extends Activity
|
||||
.addTestDevice("2CA96A8B6B805B3323F65A934FB31DC7") // Samsung Galaxy S5
|
||||
.build();
|
||||
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
canvasClass = new CanvasView(this);
|
||||
|
||||
canvasClass.PayedVersion = true; // Set payment status
|
||||
@@ -63,16 +92,31 @@ public class MainActivity extends Activity
|
||||
canvasClass.SetActivity(this);
|
||||
}
|
||||
|
||||
private final SgestureHand.ChangeListener mChangeListener =
|
||||
new SgestureHand.ChangeListener() {
|
||||
@Override
|
||||
public void onChanged(Info info) {
|
||||
Log.d("gesture", "Hand : angle = " + info.getAngle());
|
||||
// do something with data
|
||||
canvasClass.sendMove(info.getAngle(), info.getSpeed());
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
canvasClass.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
//canvasClass.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user