Two Eleven App aka 2048 (#16)

This commit is contained in:
Shadowtrance
2025-12-31 05:24:50 +10:00
committed by GitHub
parent b769ede7a8
commit 64402e261a
26 changed files with 1972 additions and 145 deletions
@@ -0,0 +1,71 @@
#ifndef TWOELEVEN_LOGIC_H
#define TWOELEVEN_LOGIC_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "TwoElevenHelpers.h"
/***********************
* FUNCTION PROTOTYPES
**********************/
/**
* @brief Initialize the matrix with two random tiles
*/
void init_matrix_num(uint16_t matrix_size, uint16_t **matrix);
/**
* @brief Add a random tile (2 or 4) to the matrix
*/
void add_random(uint16_t matrix_size, uint16_t **matrix);
/**
* @brief Move up
*/
bool move_up(uint16_t * score, uint16_t matrix_size, uint16_t **matrix);
/**
* @brief Move down
*/
bool move_down(uint16_t * score, uint16_t matrix_size, uint16_t **matrix);
/**
* @brief Move left
*/
bool move_left(uint16_t * score, uint16_t matrix_size, uint16_t **matrix);
/**
* @brief Move right
*/
bool move_right(uint16_t * score, uint16_t matrix_size, uint16_t **matrix);
/**
* @brief Check if the game is over (no moves left)
* Does not mutate the original matrix
*/
bool game_over(uint16_t matrix_size, const uint16_t **matrix);
/**
* @brief Get the current score
*/
uint16_t twoeleven_get_score(lv_obj_t * obj);
/**
* @brief Get the game over status
*/
bool twoeleven_get_status(lv_obj_t * obj);
/**
* @brief Get the best tile value
*/
uint16_t twoeleven_get_best_tile(lv_obj_t * obj);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*TWOELEVEN_LOGIC_H*/