Skip to content

Add ANSI escape code colors to tetromino pieces#13

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-colors-to-pieces
Draft

Add ANSI escape code colors to tetromino pieces#13
Copilot wants to merge 4 commits intomainfrom
copilot/add-colors-to-pieces

Conversation

Copy link

Copilot AI commented Feb 14, 2026

  • Update tetris/assets/textures/blocks to contain 7 colored block strings separated by commas, matching the Shape enum order (L=Orange, T=Pink, J=Purple/DarkBlue, S=Green, Z=Red, O=Yellow, I=Cyan)
  • Load coloredBlocks from the blocks file at runtime via loadBlocks() instead of hardcoding in the header
  • Declare coloredBlocks as extern const in tetromino.h, define in tetromino.cc
  • Update tetromino.cc shapes map to use coloredBlocks[Shape] instead of plain "■"
  • Update Tetromino::rotate() to use coloredBlocks[shapeType] for the current shape
  • Update Board::lockPiece() to store the colored block string from the piece matrix into the grid
  • Update Board::render() to display the colored block from the piece matrix for the active piece
  • Update Board::gameOver() and Board::calculateBaseline() comparisons from == "■" to != " " so colored blocks are properly detected
  • Verify all modified files compile successfully
  • Run code review and security scan
Original prompt

This section details on the original issue you should resolve

<issue_title>[optional] add colors to the pieces using "ANSI Escape Codes"</issue_title>
<issue_description>More info:

https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
https://en.wikipedia.org/wiki/ANSI_escape_code


This repo is using Opire - what does it mean? 👇
💵 Everyone can add rewards for this issue commenting /reward 100 (replace 100 with the amount).
🕵️‍♂️ If someone starts working on this issue to earn the rewards, they can comment /try to let everyone know!
🙌 And when they open the PR, they can comment /claim itssimmons/tetris.cpp#4 either in the PR description or in a PR's comment.

🪙 Also, everyone can tip any user commenting /tip 20 @itssimmons (replace 20 with the amount, and @itssimmons with the user to tip).

📖 If you want to learn more, check out our documentation.

<agent_instructions>There is a texture called blocks, u will need to create 7 blocks separated in ansi characters codes and colons in between them

These are the available colours for pieces

Z -> Red
T -> Pink
I -> Cian
O -> Yellow
L -> Orange
S -> Green
J -> Purple/Dark Blue

\x1b[31m■\x1b[0m,...

If u need to separate the blocks using another character than a, you'll be free of it, but you need to separate the blocks and match their position with the enum Shape, so it will be easy to find what colour the current shape block is. You will need a global variable, maybe inlined as well, that tells what the current block is, and these "■" if now will change for that variable</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 14, 2026 10:48
- Update blocks texture with 7 colored block strings (comma-separated)
- Add inline coloredBlocks array in tetromino.h indexed by Shape enum
- Use colored blocks in shapes map and rotate() in tetromino.cc
- Update board.cc comparisons from == "■" to != " " for colored blocks
- Preserve colored block strings when locking pieces to the grid

Co-authored-by: itssimmons <62354548+itssimmons@users.noreply.github.com>
Co-authored-by: itssimmons <62354548+itssimmons@users.noreply.github.com>
Copilot AI changed the title [WIP] Add colors to the pieces using ANSI escape codes Add ANSI escape code colors to tetromino pieces Feb 14, 2026
Copilot AI requested a review from itssimmons February 14, 2026 10:49
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot You create the file, which is good, but you don't use it because you end up creating a coloredBlocks variable. What would be the goal of this file otherwise?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7fbd619. coloredBlocks is now loaded from tetris/assets/textures/blocks at runtime via loadBlocks(), which reads the file and parses the comma-separated colored blocks. The header now just declares it as extern const—the file is the single source of truth.

…ding

The blocks file is now the single source of truth for piece colors.
coloredBlocks is declared extern in tetromino.h and defined in
tetromino.cc via loadBlocks() which reads and parses the file.

Co-authored-by: itssimmons <62354548+itssimmons@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[optional] add colors to the pieces using "ANSI Escape Codes"

2 participants