Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2023:drtranca:x_si_o [2023/05/28 23:47]
andreea.stefan1110 [Rezultate Obţinute]
pm:prj2023:drtranca:x_si_o [2023/05/30 00:47] (current)
andreea.stefan1110 [Bibliografie/Resurse]
Line 23: Line 23:
 ===== Hardware Design ===== ===== Hardware Design =====
  
-<note tip> 
-Aici puneţi tot ce ţine de hardware design: 
-  * listă de piese 
-  * scheme electrice (se pot lua şi de pe Internet şi din datasheet-uri,​ e.g. http://​www.captain.at/​electronic-atmega16-mmc-schematic.png) 
-  * diagrame de semnal ​ 
-  * rezultatele simulării 
-</​note>​ 
  
 === Lista de piese === === Lista de piese ===
Line 48: Line 41:
  
  
-<note tip> +Libraries:
-Descrierea codului aplicaţiei (firmware): +
-  * mediu de dezvoltare (if any) (e.g. AVR Studio, CodeVisionAVR) +
-  * librării şi surse 3rd-party (e.g. Procyon AVRlib) +
-  * algoritmi şi structuri pe care plănuiţi să le implementaţi +
-  * (etapa 3) surse şi funcţii implementate +
-</​note>​+
  
 +    SPI.h
 +    TFT.h
 +
 +The game logic is implemented in the code using a 2D array to represent the game grid. Each cell in the grid can have one of the following values:
 +
 +    "​-1":​ Empty cell
 +    "​0": ​ Player O's mark
 +    "​1": ​ Player X's mark
 +    "​2": ​ Temporary mark (used during player X's turn)
 +
 +The game checks for a winning condition by examining each row, column, and diagonal. If a winning condition is found, the game displays the winner and resets the grid for a new round. If all cells are filled and no winner is found, the game declares a draw and resets.
 +
 +
 +
 +Functions:
 +
 +
 +
 +void next():
 +
 +Updates the previous position and value variables to keep track of the previous move in the game.
 +
 +
 +bool isWin():
 +
 +Checks if there is a winning condition in the game. It examines each row, column, and diagonal to determine if all three cells have the same non-
 +empty value (either 0 or 1). If a winning condition is found, it returns true, otherwise, false.
 +
 +
 +void resetGame():​
 +
 +Resets the game by reinitializing all the necessary variables and the game grid. It sets the grid cells to -1 (empty) and resets the position and counter variables.
 +
 +
 +void Enter():
 +
 +Handles the player'​s move when the button is pressed. It assigns the appropriate mark (X or O) to the selected cell on the grid based on the round counter. It then checks for a winning condition or a draw and displays the corresponding message. If the game is not over, it resets the necessary variables and increments the round counter.
 +
 +
 +void Round():
 +
 +Handles each round of the game. It updates the grid based on the joystick input (left, right, up, or down) by changing the current position and updating the temporary mark (2) accordingly. It redraws the grid after each move. When the button is pressed, it calls the Enter() function to process the player'​s move and increments the round counter.
 +
 +
 +void drawX(int x, int y):
 +
 +Draws the X mark on the display at the specified coordinates (x, y).
 +
 +
 +void drawO(int x, int y):
 +
 +Draws the O mark on the display at the specified coordinates (x, y).
 +
 +
 +void drawtemp(int x, int y):
 +
 +Draws a temporary mark ? on the display at the specified coordinates (x, y). This mark is used during the players turn before they confirm their move.
 +
 +
 +void draw(int c, int i, int j):
 +
 +Draws the appropriate mark (X, O, or ?) on the display at the specified grid position (i, j) based on the value stored in the game grid.
 +
 +
 +void drawAll():
 +
 +Redraws the entire grid on the display by iterating through the game grid and calling the draw() function for each cell.
 +
 +
 +void displayWinner():​
 +
 +Displays the winner (X or O) on the display when a winning condition is met. It shows the corresponding message for a certain period of time before resetting the game.
 +
 +
 +void displayDraw():​
 +
 +Displays a draw message on the display when the game ends in a draw. It shows the message for a certain period of time before resetting the game.
 ===== Rezultate Obţinute ===== ===== Rezultate Obţinute =====
  
Line 66: Line 130:
 ===== Concluzii ===== ===== Concluzii =====
  
-În etapele următoare... stay tuned!+It's a simple implementation of a Tic-Tac-Toe game using an Arduino board and a TFT displayPlayers can navigate the grid using a joystick and place their marks (X or O) by pressing a buttonThe game checks for a winning condition or a draw after each move. It provides an interactive and enjoyable gaming experience with the Arduino platform.
  
 ===== Download ===== ===== Download =====
  
 <note warning> <note warning>
-O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectuluisurse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-).+Arhiva:
  
-Fişierele se încarcă pe wiki folosind facilitatea **Add Images or other files**. Namespace-ul în care se încarcă fişierele este de tipul **:​pm:​prj20??:​c?​** sau **:​pm:​prj20??:​c?:​nume_student** (dacă este cazul). **Exemplu:​** Dumitru Alin, 331CC -> **:pm:prj2009:cc:dumitru_alin**.+{{:pm:prj2023:drtranca:stefan_bianca.zip|}}
 </​note>​ </​note>​
  
-===== Jurnal ===== 
- 
-<note tip> 
-Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului. 
-</​note>​ 
  
 ===== Bibliografie/​Resurse ===== ===== Bibliografie/​Resurse =====
  
 <​note>​ <​note>​
-Listă cu documente, datasheet-uri,​ resurse Internet folosite, eventual grupate pe **Resurse Software** şi **Resurse Hardware**.+Listă cu documente, datasheet-uri,​ resurse Internet folosite
 +https://​exploreembedded.com/​wiki/​Analog_JoyStick_with_Arduino 
 +https://​docs.arduino.cc/​retired/​getting-started-guides/​TFT 
 +https://​create.arduino.cc/​projecthub/​electropeak/​ultimate-beginner-s-guide-to-run-tft-lcd-displays-by-arduino-081006
 </​note>​ </​note>​
  
 <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​ <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​
pm/prj2023/drtranca/x_si_o.1685306864.txt.gz · Last modified: 2023/05/28 23:47 by andreea.stefan1110
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0