test game — Aitewinrobot Esp32C3 Supermini simulation

An interactive Aitewinrobot Esp32C3 Supermini circuit simulation you can run free in your browser on Velxio, by vup129623.

Components

Sketch code

#include <Arduino.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <math.h>

// =====================================================
// ESP32-C3 + ILI9341 320x240 - GAME CENTER (FULL 5 GAMES)
// TAI XIU + QUAY HU + CANH CUT + XOC DIA + VONG QUAY
// =====================================================

#define TFT_SCK   4
#define TFT_MOSI  6
#define TFT_CS    7
#define TFT_DC    2
#define TFT_RST   10

#define BTN_UP     0
#define BTN_DOWN   1
#define BTN_A      3
#define BTN_B      8
#define BTN_C      9
#define BTN_EXIT   21

Adafruit_ILI9341 tft(TFT_CS, TFT_DC, TFT_RST);

// Bộ đệm vẽ dùng cho Vòng Quay (Canvas)
GFXcanvas16 canvas(320, 70);

// =====================================================
// ENUM
// =====================================================
enum ButtonId { BID_UP, BID_DOWN, BID_A, BID_B, BID_C, BID_EXIT, BUTTON_COUNT };
enum AppState { START_BALANCE, GAME_MENU, PLAY_TAIXIU, PLAY_SLOT, PLAY_PENGUIN, PLAY_XOCDIA, PLAY_WHEEL };
enum BQPhase { BQ_IDLE, BQ_PLAYING, BQ_JUMPING, BQ_LANDING, BQ_BREAKING, BQ_FALLING, BQ_RESULT };
enum XDPhase { XD_IDLE, XD_SHAKING, XD_OPENING, XD_RESULT };
enum WWPhase { WW_IDLE, WW_SPINNING, WW_RESULT };

AppState appState = START_BALANCE;
BQPhase  bqPhase = BQ_IDLE;
XDPhase  xdPhase = XD_IDLE;
WWPhase  wwPhase = WW_IDLE;

// =====================================================
// MÀU SẮC
// =====================================================
#define BG          0x0000
#define PANEL_DK    0x18C3
#define WHITE       0xFFFF
#define GRAY_LT     0xC618
#define GRAY        0x8410
#define GRAY_DK     0x4208
#define BLACK       0x0000
#define YELLOW      0xFFE0
#define RED         0xF800
#define RED_DK      0x8000
#define GREEN       0x07E0
#define GREEN_LT    0x87F0
#define GOLD        0xFEA0
#define GOLD_DK     0xC800
#define GOLD_LT     0xFFF0
#define ORANGE      0xFD20
#define CYAN        0x07FF
#define CYAN_DK     0x0450
#define CYAN_LT     0x87FF

#define ICE_FILL    0x059F   
#define ICE_BORDER  0xAEFF   
#define ICE_SHADOW  0x02B5   
#define ICE_CRACK   0x0210   

#define C_1 0xE820 // Đỏ thẫm
#define C_2 0x033F // Xanh dương
#define C_3 0x0400 // Xanh lá
#define C_4 0xFC00 // Cam
#define C_5 0x8010 // Tím

// =====================================================
// LAYOUT CHUNG
// =====================================================
#define SCREEN_W    320
#define SCREEN_H    240
#define HEADER_H    26
#define CENTER_X    160

// Tài Xỉu
#define TX_CAU_SIZE 24

// Slot
#define CARD_W      58
#define CARD_H      96
#define CARD_GAP    5
#define CARD_Y      32
#define CARD_COUNT  5

// Penguin
const int POS_COUNT = 15;
const float bqMult[POS_COUNT] = {0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.5, 10.0, 12.5, 20.0, 30.0, 50.0};
const long  bqMultX10[POS_COUNT] = {0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100, 125, 200, 300, 500};
const int BLOCK_W   = 54;
const int BLOCK_H   = 40;
const int STEP      = BLOCK_W + 4; 
const int BLOCK_Y   = 135;
const int JUMP_

More projects by vup129623