# Tetris Game
## Introduction
Tetris is a classic tile-matching puzzle video game where the player arranges falling blocks of various shapes to create complete horizontal lines.
## MVC Design Pattern
The Tetris game is built using the Model-View-Controller (MVC) design pattern. This pattern separates the application into three interconnected components:
### Model
The Model represents the game's core logic. It includes modules for handling game rules, object movements, and scoring. In our implementation, the Model also manages random object generation and line clearing.
### View
The View is responsible for the game's presentation and user interface. It handles interactions with external devices, such as TFT displays. The View communicates with the Model to obtain game data and render it on the screen.
### Controller
The Controller processes user input and translates it into actions within the game. It includes modules for button handling, allowing players to move and rotate falling blocks.
## System Architecture
The game is structured into three layers: the Microcontroller Abstraction Layer (MCAL), the Hardware Abstraction Layer (HAL), and the Application (APP) Layer.
### MCAL (Microcontroller Abstraction Layer)
- **RCC (Reset and Clock Control):** Manages the microcontroller's clock settings.
- **DIO (Digital Input/Output):** Provides a GPIO interface for digital input and output operations.
- **AFIO (Alternate Function I/O):** Handles alternate function configurations for GPIO pins.
- **NVIC (Nested Vector Interrupt Controller):** Manages interrupt priorities and settings.
- **STK (SysTick Timer):** Controls the SysTick timer for precise timing.
- **EXTI (External Interrupts):** Enables and manages external interrupts.
- **GPT (General-Purpose Timer):** Provides timer functionality for various time-related operations.
- **SPI (Serial Peripheral Interface):** Manages communication with external devices using the SPI protocol.
### HAL (Hardware Abstraction Layer)
- **Buttons:** Handles button configurations and input reading.
- **TFT (Thin-Film Transistor) Display:** Manages the TFT display for rendering the game interface.
### APP (Application Layer)
- **Model:** Contains game logic, rules, scoring, and object management.
- **View:** Renders the game on external devices (e.g., TFT display) based on data from the Model.
- **Controller:** Processes user input (button presses) and translates them into game actions.
## Module Structure
Each module in the game follows a consistent structure:
- **Interface File:** Contains declarations of functions and data structures exposed to other modules.
- **Private File:** Contains private functions and internal data structures used within the module.
- **Config File:** Provides configuration settings for the module.
- **Program (.c) File:** Implements the module's functionality.
## Components Required
To set up and play the Tetris game, the following components are required:
- **Microcontroller (STM32F103):** The heart of the game, responsible for controlling all aspects of gameplay.
- **Five Buttons:** These buttons serve as the game controller, including navigation and rotation.
- **TFT Screen:** (ST7735S 1.8inch)A Thin-Film Transistor (TFT) display for rendering the game's visuals.
- **Wires and Breadboard:** Used for connecting the microcontroller, buttons, TFT screen, and power supply.
## Pins Connection
- **Buttons:**
- UP: PA10
- DOWN: PA1
- LEFT: PA6
- RIGHT: PA8
- ROTATE OK: PA9
- **SPI Configuration (for TFT):**
- SPI1:
- SCK (Clock): PA5
- MOSI (Master Out Slave In): PA7
- **TFT Screen:**
- A0 (Data/Command Control): PA2
- Reset: PA3
## Configuration
**Buttons Configuration:**
- Customize button assignments by modifying the pins in the `Tetris_Controller_Button.h` file.
**Buttons Behavior:**
- Configure button behavior, including pull type and interrupt state, in the `controller_Buttons.c` file's initialization function.
**Debouncing and Long Press:**
- Adjust debouncing delay and long-press duration settings via the `Button_config.h` file to fine-tune button responsiveness.
**Color Customization (TFT Display):**
- Tailor the game's visual interface by modifying color settings in the `Tetris_View_TFT.h` file.
**TFT Display Configuration:**
- Adapt TFT screen pin assignments and SPI settings according to your hardware setup by editing the `TFT_config.h` file.
**Game Logic Customization:**
- Personalize game parameters such as score values, speed, and other game options in the `Tetris_model.h` file to align the gameplay with your preferences.
## System Configuration
**System Clock Source (HSI):**
- The system clock is sourced from HSI (High-Speed Internal) with a frequency of 8 MHz, ensuring accurate timing.
**Tick Timer (Timer 2):**
- Timer 2 is configured as the tick timer, providing essential timing functions for the system.
**System Tick and Delay:**
- The system tick is used as a delay mechanism to control timing within the game.
**Button Configuration:**
- Buttons are configured with internal pull-down resistors for reliable input handling.
## Video and Images
### Gameplay Video
- Watch a short video demonstration of the Tetris game in action [here](https://drive.google.com/file/d/17LM5EVKs0PjUvsnb-pFeqHGKEiAGLBNa/view?usp=sharing).
### Screenshots
![Welcome Screen](Images/welcome%20screen.jpg)
* Welcome Screen*
![Input Name](Images/player%20name.jpg)
* Input Name*
![Game Play](Images/game%20play.jpg)
* Game Play*
![Top Players](Images/top%20players.jpg)
* Top Players*
## Conclusion
The Tetris project embodies a classic game design with a flexible architecture. Utilizing the MVC pattern and a well-structured system, you can effortlessly customize gameplay rules, visuals, and hardware components. This project demonstrates the power of modularity in software design, making it a valuable resource for embedded systems and game development enthusiasts.
没有合适的资源?快使用搜索试试~ 我知道了~
这款嵌入式系统项目的经典俄罗斯方块游戏。使用MVC模式构建,为游戏规则提供模块化和定制.zip
共424个文件
index:47个
h:38个
c:18个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 39 浏览量
2023-12-05
16:13:02
上传
评论
收藏 1.63MB ZIP 举报
温馨提示
这款嵌入式系统项目的经典俄罗斯方块游戏。使用MVC模式构建,为游戏规则提供模块化和定制.zip
资源推荐
资源详情
资源评论
收起资源包目录
这款嵌入式系统项目的经典俄罗斯方块游戏。使用MVC模式构建,为游戏规则提供模块化和定制.zip (424个子文件)
0004364dff51001e1b83f2d88946d632 2KB
00067cdb0052001e1b83f2d88946d632 4KB
002c98e00452001e1b83f2d88946d632 2KB
00532c61fb51001e1f91b9a846134af6 721B
00a906cffd51001e1b83f2d88946d632 10KB
00b6b5070452001e1b83f2d88946d632 6KB
00c2a727ff51001e1b83f2d88946d632 3KB
00d3f0df0552001e1b83f2d88946d632 1KB
100c08410352001e1b83f2d88946d632 8KB
102de1af0852001e1b83f2d88946d632 2KB
104404480452001e1b83f2d88946d632 30KB
104a12070452001e1b83f2d88946d632 30KB
1053824f0152001e1b83f2d88946d632 9KB
106822e3fe51001e1b83f2d88946d632 1KB
1084a5fdfe51001e1b83f2d88946d632 2KB
109df803fb51001e1f91b9a846134af6 3KB
10c759630b52001e1b83f2d88946d632 2KB
10e41efcfe51001e1b83f2d88946d632 712B
10e8126dff51001e1b83f2d88946d632 6KB
10fd4dd20352001e1b83f2d88946d632 30KB
10fe78030152001e1b83f2d88946d632 4KB
200fc156fe51001e1b83f2d88946d632 712B
20151105ff51001e1b83f2d88946d632 606B
2.2.0.202306231147 0B
2036b332ff51001e1b83f2d88946d632 6KB
20370e0e0952001e1b83f2d88946d632 9KB
20669862fb51001e1f91b9a846134af6 4KB
2077ad700352001e1b83f2d88946d632 2KB
209635500452001e1b83f2d88946d632 30KB
20a515240052001e1b83f2d88946d632 1KB
20a5d54b0952001e1b83f2d88946d632 10KB
20c1663a0952001e1b83f2d88946d632 2KB
20cf0bf2fd51001e1b83f2d88946d632 30KB
20d6836f0152001e1b83f2d88946d632 2KB
20dad4680852001e1b83f2d88946d632 2KB
20eea54bff51001e1b83f2d88946d632 1KB
20f81c060552001e1b83f2d88946d632 2KB
3019bcb00752001e1b83f2d88946d632 6KB
304677360352001e1b83f2d88946d632 8KB
30724c110952001e1b83f2d88946d632 3KB
3089b6dcfd51001e1b83f2d88946d632 3KB
309ad6980152001e1b83f2d88946d632 2KB
30b5b6240252001e1b83f2d88946d632 8KB
30cedc6aff51001e1b83f2d88946d632 1KB
30ebf803fb51001e1f91b9a846134af6 3KB
30efb99d0052001e1b83f2d88946d632 8KB
4004d4310052001e1b83f2d88946d632 1KB
400c1b7e0552001e1b83f2d88946d632 1KB
402d45bf0552001e1b83f2d88946d632 3KB
4098bc29ff51001e1b83f2d88946d632 1KB
40adaa0f0252001e1b83f2d88946d632 30KB
5013810dfe51001e1b83f2d88946d632 13KB
5019b2b10452001e1b83f2d88946d632 2KB
501d91820052001e1b83f2d88946d632 13KB
5037c5d1fe51001e1b83f2d88946d632 2KB
504b9425ff51001e1b83f2d88946d632 834B
507d8e5f0252001e1b83f2d88946d632 2KB
50a4eb440252001e1b83f2d88946d632 3KB
50aca08bfe51001e1b83f2d88946d632 1KB
50b168620052001e1b83f2d88946d632 1KB
50ba696c0052001e1b83f2d88946d632 1KB
50c0e234ff51001e1b83f2d88946d632 813B
50e0c86fff51001e1b83f2d88946d632 2KB
50e6ecddfd51001e1b83f2d88946d632 8KB
50ecee8c0052001e1b83f2d88946d632 9KB
50fc1a240052001e1b83f2d88946d632 13KB
50fe3a6b0052001e1b83f2d88946d632 9KB
50ff26260852001e1b83f2d88946d632 4KB
60221405ff51001e1b83f2d88946d632 2KB
602ea52bff51001e1b83f2d88946d632 4KB
6043b632ff51001e1b83f2d88946d632 4KB
605e11600152001e1b83f2d88946d632 1KB
60cae2b40552001e1b83f2d88946d632 3KB
60cc2a61fb51001e1f91b9a846134af6 834B
60d81be3fe51001e1b83f2d88946d632 30KB
701c9d500252001e1b83f2d88946d632 2KB
7027848d0052001e1b83f2d88946d632 9KB
704c1bff0452001e1b83f2d88946d632 4KB
7054ea9a0052001e1b83f2d88946d632 30KB
7061296ffe51001e1b83f2d88946d632 1KB
707fc04fff51001e1b83f2d88946d632 3KB
707fe534ff51001e1b83f2d88946d632 985B
70b3f2250952001e1b83f2d88946d632 3KB
70dad8bc0052001e1b83f2d88946d632 6KB
801dac29ff51001e1b83f2d88946d632 1KB
8032a7810052001e1b83f2d88946d632 5KB
805320240052001e1b83f2d88946d632 9KB
8089a627ff51001e1b83f2d88946d632 3KB
80c5680cfe51001e1b83f2d88946d632 6KB
80d16c6a0352001e1b83f2d88946d632 8KB
80e262e6fd51001e1b83f2d88946d632 10KB
80e736200452001e1b83f2d88946d632 6KB
901b60980a52001e1b83f2d88946d632 2KB
903174180b52001e1b83f2d88946d632 2KB
90589725ff51001e1b83f2d88946d632 721B
9061a00afe51001e1b83f2d88946d632 4KB
9063374dff51001e1b83f2d88946d632 6KB
9074c80b0352001e1b83f2d88946d632 2KB
90791c49fe51001e1b83f2d88946d632 1KB
907f1ef80052001e1b83f2d88946d632 13KB
共 424 条
- 1
- 2
- 3
- 4
- 5
资源评论
处处清欢
- 粉丝: 159
- 资源: 2521
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功