modificado el qr y mejorada la kinestetika de los botones
This commit is contained in:
@@ -82,7 +82,7 @@ private static final int[][] STRATAGEMS = {
|
|||||||
new int[]{UP, DOWN, RIGHT, LEFT, UP}, // Reinforce
|
new int[]{UP, DOWN, RIGHT, LEFT, UP}, // Reinforce
|
||||||
new int[]{DOWN, DOWN, UP, RIGHT}, // Resupply
|
new int[]{DOWN, DOWN, UP, RIGHT}, // Resupply
|
||||||
new int[]{UP, DOWN, RIGHT, UP}, // SOS Beacon
|
new int[]{UP, DOWN, RIGHT, UP}, // SOS Beacon
|
||||||
new int[]{DOWN, UP, LEFT, DOWN, UP, RIGHT, DOWN, UP}, // NUX-223 Hellbomb
|
new int[]{DOWN, UP, LEFT, DOWN, UP, RIGHT, DOWN}, // NUX-223 Hellbomb
|
||||||
new int[]{DOWN, DOWN, DOWN, UP, UP}, // SSSD Delivery
|
new int[]{DOWN, DOWN, DOWN, UP, UP}, // SSSD Delivery
|
||||||
new int[]{UP, UP, LEFT, RIGHT, DOWN, DOWN}, // Seismic Probe
|
new int[]{UP, UP, LEFT, RIGHT, DOWN, DOWN}, // Seismic Probe
|
||||||
new int[]{UP, UP, LEFT, UP, RIGHT}, // Eagle Rearm
|
new int[]{UP, UP, LEFT, UP, RIGHT}, // Eagle Rearm
|
||||||
@@ -190,7 +190,7 @@ private static final String[] NAMES = {
|
|||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
private Handler handler = new Handler();
|
private Handler handler = new Handler();
|
||||||
|
|
||||||
private TextView tvCounter;
|
private TextView tvCounter, tvFailuresCounter;
|
||||||
private ImageView ivStratagemIcon;
|
private ImageView ivStratagemIcon;
|
||||||
private LinearLayout sequenceContainer;
|
private LinearLayout sequenceContainer;
|
||||||
private ImageButton btnUp, btnDown, btnLeft, btnRight, btnVolver;
|
private ImageButton btnUp, btnDown, btnLeft, btnRight, btnVolver;
|
||||||
@@ -200,6 +200,7 @@ private static final String[] NAMES = {
|
|||||||
private int[] sequence;
|
private int[] sequence;
|
||||||
private int playerIndex = 0;
|
private int playerIndex = 0;
|
||||||
private int completadas = 0;
|
private int completadas = 0;
|
||||||
|
private int fallos = 0;
|
||||||
private boolean esperando = false;
|
private boolean esperando = false;
|
||||||
private boolean juegoActivo = true;
|
private boolean juegoActivo = true;
|
||||||
private int currentStratagemIndex = 0;
|
private int currentStratagemIndex = 0;
|
||||||
@@ -214,6 +215,7 @@ private static final String[] NAMES = {
|
|||||||
catch (Exception e) { soundManager = null; }
|
catch (Exception e) { soundManager = null; }
|
||||||
|
|
||||||
tvCounter = findViewById(R.id.tv_counter);
|
tvCounter = findViewById(R.id.tv_counter);
|
||||||
|
tvFailuresCounter = findViewById(R.id.tv_failures_counter);
|
||||||
ivStratagemIcon = findViewById(R.id.iv_stratagem_icon);
|
ivStratagemIcon = findViewById(R.id.iv_stratagem_icon);
|
||||||
sequenceContainer = findViewById(R.id.sequence_container);
|
sequenceContainer = findViewById(R.id.sequence_container);
|
||||||
btnUp = findViewById(R.id.btn_up);
|
btnUp = findViewById(R.id.btn_up);
|
||||||
@@ -226,14 +228,32 @@ private static final String[] NAMES = {
|
|||||||
|
|
||||||
btnVolver.setOnClickListener(v -> finish());
|
btnVolver.setOnClickListener(v -> finish());
|
||||||
|
|
||||||
if (btnUp != null) btnUp.setOnClickListener(v -> onInputWithSound(UP));
|
if (btnUp != null) btnUp.setOnClickListener(v -> { animateButtonClick(v); onInputWithSound(UP); });
|
||||||
if (btnDown != null) btnDown.setOnClickListener(v -> onInputWithSound(DOWN));
|
if (btnDown != null) btnDown.setOnClickListener(v -> { animateButtonClick(v); onInputWithSound(DOWN); });
|
||||||
if (btnLeft != null) btnLeft.setOnClickListener(v -> onInputWithSound(LEFT));
|
if (btnLeft != null) btnLeft.setOnClickListener(v -> { animateButtonClick(v); onInputWithSound(LEFT); });
|
||||||
if (btnRight != null) btnRight.setOnClickListener(v -> onInputWithSound(RIGHT));
|
if (btnRight != null) btnRight.setOnClickListener(v -> { animateButtonClick(v); onInputWithSound(RIGHT); });
|
||||||
|
|
||||||
nuevaRonda();
|
nuevaRonda();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void animateButtonClick(View v) {
|
||||||
|
// Feedback háptico (vibración corta)
|
||||||
|
v.performHapticFeedback(android.view.HapticFeedbackConstants.VIRTUAL_KEY);
|
||||||
|
|
||||||
|
// Animación de escala más agresiva y rápida
|
||||||
|
v.animate()
|
||||||
|
.scaleX(0.7f)
|
||||||
|
.scaleY(0.7f)
|
||||||
|
.setDuration(40)
|
||||||
|
.withEndAction(() -> v.animate()
|
||||||
|
.scaleX(1.0f)
|
||||||
|
.scaleY(1.0f)
|
||||||
|
.setDuration(150)
|
||||||
|
.setInterpolator(new android.view.animation.OvershootInterpolator(4.0f)) // Rebote más fuerte
|
||||||
|
.start())
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
private int getArrowRotation(int dir) {
|
private int getArrowRotation(int dir) {
|
||||||
switch(dir) {
|
switch(dir) {
|
||||||
case UP: return 0;
|
case UP: return 0;
|
||||||
@@ -277,18 +297,20 @@ private static final String[] NAMES = {
|
|||||||
sequenceContainer.removeAllViews();
|
sequenceContainer.removeAllViews();
|
||||||
|
|
||||||
for (int i = 0; i < sequence.length; i++) {
|
for (int i = 0; i < sequence.length; i++) {
|
||||||
TextView arrowView = new TextView(this);
|
ImageView arrowView = new ImageView(this);
|
||||||
int size = (int)(56 * getResources().getDisplayMetrics().density);
|
int size = (int) (45 * getResources().getDisplayMetrics().density);
|
||||||
int margin = (int)(4 * getResources().getDisplayMetrics().density);
|
int margin = (int) (2 * getResources().getDisplayMetrics().density);
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(size, size);
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(size, size);
|
||||||
params.setMargins(margin, margin, margin, margin);
|
params.setMargins(margin, margin, margin, margin);
|
||||||
arrowView.setLayoutParams(params);
|
arrowView.setLayoutParams(params);
|
||||||
|
|
||||||
arrowView.setText(String.valueOf(ARROW_CHARS.charAt(sequence[i])));
|
arrowView.setImageResource(R.drawable.ic_dpad_button);
|
||||||
arrowView.setTextColor(Color.parseColor("#FFFFFF"));
|
arrowView.setBackgroundResource(R.drawable.btn_direction);
|
||||||
arrowView.setGravity(Gravity.CENTER);
|
arrowView.setRotation(getArrowRotation(sequence[i]));
|
||||||
arrowView.setBackgroundResource(R.drawable.arrow_white);
|
arrowView.setColorFilter(Color.WHITE);
|
||||||
|
int padding = (int) (8 * getResources().getDisplayMetrics().density);
|
||||||
|
arrowView.setPadding(padding, padding, padding, padding);
|
||||||
|
|
||||||
sequenceContainer.addView(arrowView);
|
sequenceContainer.addView(arrowView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -309,9 +331,9 @@ private static final String[] NAMES = {
|
|||||||
|
|
||||||
if (sequenceContainer != null && playerIndex <= sequence.length) {
|
if (sequenceContainer != null && playerIndex <= sequence.length) {
|
||||||
View child = sequenceContainer.getChildAt(playerIndex - 1);
|
View child = sequenceContainer.getChildAt(playerIndex - 1);
|
||||||
if (child instanceof TextView) {
|
if (child instanceof ImageView) {
|
||||||
TextView arrowView = (TextView) child;
|
ImageView arrowView = (ImageView) child;
|
||||||
arrowView.setTextColor(Color.parseColor("#00FF00"));
|
arrowView.setColorFilter(Color.parseColor("#fde902"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,8 +359,11 @@ private static final String[] NAMES = {
|
|||||||
try { soundManager.playFailure(); } catch (Exception e) {}
|
try { soundManager.playFailure(); } catch (Exception e) {}
|
||||||
}
|
}
|
||||||
juegoActivo = false;
|
juegoActivo = false;
|
||||||
if (ivFailure != null) ivFailure.setVisibility(View.VISIBLE);
|
fallos++;
|
||||||
handler.postDelayed(this::nuevaRonda, 1500);
|
if (tvFailuresCounter != null) tvFailuresCounter.setText(String.valueOf(fallos));
|
||||||
|
|
||||||
|
// Delay de medio segundo antes de reiniciar
|
||||||
|
handler.postDelayed(this::nuevaRonda, 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ public class ActivityQR extends AppCompatActivity {
|
|||||||
|
|
||||||
int width = bitMatrix.getWidth();
|
int width = bitMatrix.getWidth();
|
||||||
int height = bitMatrix.getHeight();
|
int height = bitMatrix.getHeight();
|
||||||
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
|
Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
|
|
||||||
int black = 0xFF000000;
|
int qrColor = 0xFFFFFFFF; // Blanco para los módulos del QR
|
||||||
int white = 0xFFFFFFFF;
|
int transparent = 0x00000000; // Transparente para el fondo
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
bmp.setPixel(x, y, bitMatrix.get(x, y) ? black : white);
|
bmp.setPixel(x, y, bitMatrix.get(x, y) ? qrColor : transparent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,20 +9,35 @@
|
|||||||
|
|
||||||
<!-- Nombre de la estratagema -->
|
<!-- Nombre de la estratagema -->
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/tv_counter"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginEnd="15dp"
|
android:layout_marginEnd="15dp"
|
||||||
android:layout_marginBottom="207dp"
|
android:layout_marginBottom="180dp"
|
||||||
android:text="0"
|
android:gravity="center_horizontal"
|
||||||
android:textColor="#fde902"
|
android:orientation="vertical">
|
||||||
android:textSize="24sp"
|
|
||||||
android:textStyle="bold" />
|
<TextView
|
||||||
|
android:id="@+id/tv_counter"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="0"
|
||||||
|
android:textColor="#fde902"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_failures_counter"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:text="0"
|
||||||
|
android:textColor="#bd0000"
|
||||||
|
android:textSize="24sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_stratagem_name"
|
android:id="@+id/tv_stratagem_name"
|
||||||
|
|||||||
@@ -22,12 +22,10 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/qr_image"
|
android:id="@+id/qr_image"
|
||||||
android:layout_width="440dp"
|
android:layout_width="404dp"
|
||||||
android:layout_height="379dp"
|
android:layout_height="344dp"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:background="#FFFFFF"
|
|
||||||
android:contentDescription="@string/qr_description"
|
android:contentDescription="@string/qr_description"
|
||||||
android:padding="8dp"
|
|
||||||
android:scaleType="fitCenter" />
|
android:scaleType="fitCenter" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
Reference in New Issue
Block a user