Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7dd68476d | ||
|
|
fa997fb77a | ||
|
|
c4cc0517f6 |
@@ -244,10 +244,11 @@ containing a value of this type.
|
|||||||
public static final int sprite_i4r=0x7f020033;
|
public static final int sprite_i4r=0x7f020033;
|
||||||
public static final int sprite_l1=0x7f020034;
|
public static final int sprite_l1=0x7f020034;
|
||||||
public static final int sprite_l2=0x7f020035;
|
public static final int sprite_l2=0x7f020035;
|
||||||
public static final int sprite_s=0x7f020036;
|
public static final int sprite_pause=0x7f020036;
|
||||||
public static final int sprite_score=0x7f020037;
|
public static final int sprite_s=0x7f020037;
|
||||||
public static final int sprite_t=0x7f020038;
|
public static final int sprite_score=0x7f020038;
|
||||||
public static final int sprite_z=0x7f020039;
|
public static final int sprite_t=0x7f020039;
|
||||||
|
public static final int sprite_z=0x7f02003a;
|
||||||
}
|
}
|
||||||
public static final class id {
|
public static final class id {
|
||||||
public static final int action_settings=0x7f050005;
|
public static final int action_settings=0x7f050005;
|
||||||
|
|||||||
@@ -163,4 +163,10 @@ public class GameMenu extends GameStateInterface
|
|||||||
{
|
{
|
||||||
Rect(canvas, 0f, 160f, 0f, 90f, Color.parseColor("lime"));
|
Rect(canvas, 0f, 160f, 0f, 90f, Color.parseColor("lime"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void SendMove(int angle, int speed) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
After Width: | Height: | Size: 161 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 161 KiB |
|
After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
@@ -13,7 +13,6 @@ public class CanvasView extends View // Dev2
|
|||||||
Resources r;
|
Resources r;
|
||||||
|
|
||||||
GameStateInterface Foreground = null;
|
GameStateInterface Foreground = null;
|
||||||
GameStateInterface Gamemenu = null;
|
|
||||||
GameStateInterface Gameplay = null;
|
GameStateInterface Gameplay = null;
|
||||||
|
|
||||||
// Score.
|
// Score.
|
||||||
@@ -32,18 +31,15 @@ public class CanvasView extends View // Dev2
|
|||||||
public void SetActivity(Activity activity)
|
public void SetActivity(Activity activity)
|
||||||
{
|
{
|
||||||
Gameplay = new GamePlay(activity);
|
Gameplay = new GamePlay(activity);
|
||||||
Gamemenu = new GameMenu(activity);
|
|
||||||
|
|
||||||
Gamemenu.SetCanvas(this);
|
|
||||||
Gamemenu.SetPayedVersion(PayedVersion);
|
|
||||||
|
|
||||||
Gamemenu.Load();
|
|
||||||
Gamemenu.Start();
|
|
||||||
|
|
||||||
Gameplay.SetCanvas(this);
|
Gameplay.SetCanvas(this);
|
||||||
Gameplay.SetPayedVersion(PayedVersion);
|
Gameplay.SetPayedVersion(PayedVersion);
|
||||||
|
|
||||||
Foreground = Gamemenu;
|
((GamePlay)Gameplay).SetStartLevel(startLevel);
|
||||||
|
Gameplay.Load();
|
||||||
|
Gameplay.Start();
|
||||||
|
|
||||||
|
Foreground = Gameplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,24 +75,17 @@ public class CanvasView extends View // Dev2
|
|||||||
Foreground = Gameplay;
|
Foreground = Gameplay;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GameStateInterface.GS_PAUSED:
|
|
||||||
{
|
|
||||||
Gamemenu.SetGameState(Foreground.GetGameState(), true);
|
|
||||||
Foreground = Gamemenu;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GameStateInterface.GS_RESUME:
|
case GameStateInterface.GS_RESUME:
|
||||||
{
|
{
|
||||||
Gameplay.SetGameState(Foreground.GetGameState(), true);
|
Gameplay.SetGameState(Foreground.GetGameState(), true);
|
||||||
Foreground = Gameplay;
|
Foreground = Gameplay;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GameStateInterface.GS_GAMEOVER:
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMove(int angle, int speed)
|
||||||
{
|
{
|
||||||
Gamemenu.SetGameState(Foreground.GetGameState(), true);
|
Foreground.SendMove(angle, speed);
|
||||||
Foreground = Gamemenu;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,13 @@ public class GamePlay extends GameStateInterface
|
|||||||
public void onPause()
|
public void onPause()
|
||||||
{
|
{
|
||||||
mp.pause();
|
mp.pause();
|
||||||
|
if (GameState != GS_GAMEOVER)
|
||||||
SetGameState(GS_PAUSED, false);
|
SetGameState(GS_PAUSED, false);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
canvasView.postInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,7 +87,7 @@ public class GamePlay extends GameStateInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isPostBack)
|
if ((!isPostBack) && (GameState != GS_GAMEOVER))
|
||||||
canvasView.OnGameStateChanged(GameState);
|
canvasView.OnGameStateChanged(GameState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,6 +373,7 @@ public class GamePlay extends GameStateInterface
|
|||||||
bitmapi1r, bitmapi2r, bitmapi3r, bitmapi4r, bitmapblockline, bitmapscore, bitmapcontroller, bitmapgameover;
|
bitmapi1r, bitmapi2r, bitmapi3r, bitmapi4r, bitmapblockline, bitmapscore, bitmapcontroller, bitmapgameover;
|
||||||
|
|
||||||
Bitmap Font0, Font1, Font2, Font3, Font4, Font5, Font6, Font7, Font8, Font9;
|
Bitmap Font0, Font1, Font2, Font3, Font4, Font5, Font6, Font7, Font8, Font9;
|
||||||
|
Bitmap bitmappause;
|
||||||
|
|
||||||
// Audio.
|
// Audio.
|
||||||
MediaPlayer mp;
|
MediaPlayer mp;
|
||||||
@@ -444,7 +450,6 @@ public class GamePlay extends GameStateInterface
|
|||||||
handler.postDelayed(runnable, 100);
|
handler.postDelayed(runnable, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO game state
|
|
||||||
@Override
|
@Override
|
||||||
public void Load()
|
public void Load()
|
||||||
{
|
{
|
||||||
@@ -601,6 +606,13 @@ public class GamePlay extends GameStateInterface
|
|||||||
bitmapgameover = Bitmap.createScaledBitmap(bitmapgameover,
|
bitmapgameover = Bitmap.createScaledBitmap(bitmapgameover,
|
||||||
(int)GetRealPixelSize(DIP_W, dpWidth, (GameSpaceRight - GameSpaceLeft)),
|
(int)GetRealPixelSize(DIP_W, dpWidth, (GameSpaceRight - GameSpaceLeft)),
|
||||||
(int)GetRealPixelSize(DIP_H, dpHeight, (GameSpaceBottom - GameSpaceTop)), false);
|
(int)GetRealPixelSize(DIP_H, dpHeight, (GameSpaceBottom - GameSpaceTop)), false);
|
||||||
|
|
||||||
|
bitmappause = BitmapFactory.decodeResource(r,
|
||||||
|
R.drawable.sprite_pause);
|
||||||
|
|
||||||
|
bitmappause = Bitmap.createScaledBitmap(bitmappause,
|
||||||
|
(int)GetRealPixelSize(DIP_W, dpWidth, (GameSpaceRight - GameSpaceLeft)),
|
||||||
|
(int)GetRealPixelSize(DIP_H, dpHeight, (GameSpaceBottom - GameSpaceTop)), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadFont()
|
private void LoadFont()
|
||||||
@@ -689,15 +701,17 @@ public class GamePlay extends GameStateInterface
|
|||||||
|
|
||||||
if (PayedVersion)
|
if (PayedVersion)
|
||||||
{
|
{
|
||||||
|
// Scores.
|
||||||
DrawLines(canvas, lines);
|
DrawLines(canvas, lines);
|
||||||
DrawLevel(canvas, startLevel + level);
|
DrawLevel(canvas, level);
|
||||||
DrawScore(canvas, score);
|
DrawScore(canvas, score);
|
||||||
|
|
||||||
// Next Coming Tetrimino.
|
// Next Coming Tetrimino.
|
||||||
|
|
||||||
ShowNextComingTetrimino(canvas);
|
ShowNextComingTetrimino(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(GameState == GS_PLAYING)
|
||||||
|
{
|
||||||
for (int x=0; x<10; x++)
|
for (int x=0; x<10; x++)
|
||||||
{
|
{
|
||||||
for (int y=0; y<18; y++)
|
for (int y=0; y<18; y++)
|
||||||
@@ -792,7 +806,7 @@ public class GamePlay extends GameStateInterface
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
// In case of error.
|
||||||
Rect(canvas, map(y, 0, 18, GameSpaceTop, GameSpaceBottom), map(y+1, 0, 18, GameSpaceTop, GameSpaceBottom),
|
Rect(canvas, map(y, 0, 18, GameSpaceTop, GameSpaceBottom), map(y+1, 0, 18, GameSpaceTop, GameSpaceBottom),
|
||||||
map(x, 0, 10, GameSpaceLeft, GameSpaceRight), map(x+1, 0, 10, GameSpaceLeft, GameSpaceRight),
|
map(x, 0, 10, GameSpaceLeft, GameSpaceRight), map(x+1, 0, 10, GameSpaceLeft, GameSpaceRight),
|
||||||
Color.RED);
|
Color.RED);
|
||||||
@@ -801,12 +815,19 @@ public class GamePlay extends GameStateInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (GameState == GS_GAMEOVER)
|
if (GameState == GS_GAMEOVER)
|
||||||
{
|
{
|
||||||
canvas.drawBitmap(bitmapgameover, (int)GetRealPixelSize(DIP_W, dpWidth, GameSpaceLeft),
|
canvas.drawBitmap(bitmapgameover, (int)GetRealPixelSize(DIP_W, dpWidth, GameSpaceLeft),
|
||||||
(int)GetRealPixelSize(DIP_H, dpHeight, GameSpaceTop), null);
|
(int)GetRealPixelSize(DIP_H, dpHeight, GameSpaceTop), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GameState == GS_PAUSED)
|
||||||
|
{
|
||||||
|
canvas.drawBitmap(bitmappause, (int)GetRealPixelSize(DIP_W, dpWidth, GameSpaceLeft),
|
||||||
|
(int)GetRealPixelSize(DIP_H, dpHeight, GameSpaceTop), null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowNextComingTetrimino(Canvas canvas)
|
private void ShowNextComingTetrimino(Canvas canvas)
|
||||||
@@ -1875,4 +1896,39 @@ public class GamePlay extends GameStateInterface
|
|||||||
|
|
||||||
return true;
|
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;
|
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.AdRequest;
|
||||||
import com.google.android.gms.ads.AdSize;
|
import com.google.android.gms.ads.AdSize;
|
||||||
import com.google.android.gms.ads.AdView;
|
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.app.Activity;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
public class MainActivity extends Activity
|
public class MainActivity extends Activity
|
||||||
@@ -17,10 +24,40 @@ public class MainActivity extends Activity
|
|||||||
CanvasView canvasClass;
|
CanvasView canvasClass;
|
||||||
private AdView adView;
|
private AdView adView;
|
||||||
|
|
||||||
|
private Sgesture mGesture;
|
||||||
|
private SgestureHand mHand;
|
||||||
|
|
||||||
|
private boolean SamsungDevice = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
// Gesture. Samsung only
|
||||||
|
mGesture = new Sgesture();
|
||||||
|
|
||||||
|
try {
|
||||||
|
mGesture.initialize(this);
|
||||||
|
SamsungDevice = true;
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
//Error Handling
|
||||||
|
Log.d("MangaValk", "mark1");
|
||||||
|
SamsungDevice = false;
|
||||||
|
} catch (SsdkUnsupportedException e2) {
|
||||||
|
//Error Handling
|
||||||
|
Log.d("MangaValk", "mark2");
|
||||||
|
SamsungDevice = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SamsungDevice)
|
||||||
|
{
|
||||||
|
if(mGesture.isFeatureEnabled(Sgesture.TYPE_HAND_PRIMITIVE)){
|
||||||
|
mHand = new SgestureHand(Looper.getMainLooper(), mGesture);
|
||||||
|
mHand.start(Sgesture.TYPE_HAND_PRIMITIVE, mChangeListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FrameLayout ll;
|
FrameLayout ll;
|
||||||
|
|
||||||
ll = new FrameLayout(this);
|
ll = new FrameLayout(this);
|
||||||
@@ -37,6 +74,8 @@ public class MainActivity extends Activity
|
|||||||
.addTestDevice("2CA96A8B6B805B3323F65A934FB31DC7") // Samsung Galaxy S5
|
.addTestDevice("2CA96A8B6B805B3323F65A934FB31DC7") // Samsung Galaxy S5
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
canvasClass = new CanvasView(this);
|
canvasClass = new CanvasView(this);
|
||||||
|
|
||||||
canvasClass.PayedVersion = true; // Set payment status
|
canvasClass.PayedVersion = true; // Set payment status
|
||||||
@@ -63,16 +102,32 @@ public class MainActivity extends Activity
|
|||||||
canvasClass.SetActivity(this);
|
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
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
canvasClass.onPause();
|
canvasClass.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
//canvasClass.onResume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 161 KiB |