Cookie Consent by Free Privacy Policy Generator 📌 Tetris Development #5 - The HOLD Piece


✅ Tetris Development #5 - The HOLD Piece


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

In this post, I will talk about the implementation of the HOLD piece in our Tetris game.

First, what is a HOLD piece? In Tetris, there is a HOLD slot, which is empty at the start of the game, and the player can press a button to put the currently controlled piece into the HOLD slot to be used later. The game then continues as if the hold piece vanished. When the player thinks it is time to use the HOLD piece, they can press the same button again to swap the HOLD piece with the currently controlled piece and continue the game.

This allows for strategic planning and setup, where players can HOLD a useful piece to be used later in the game.

"Ok but how do we implement it?"

Logic

I started by adding a new variable for HOLD piece, and it is empty at the start of the game.

When the HOLD button (spacebar) is pressed, the game logic will check if there exists a piece being held. If there isn't, the HOLD piece will clone the current active piece, and the active piece will be replaced by the next piece in line.

If there is already a piece being held, then pressing the HOLD button will swap the held piece with the active piece.

Details

There are two important details in the HOLD implementation.
Firstly, when the active piece is replaced by the HOLD piece, the drop indicator will need to change as well. Without it, the drop indicator will still show where the original block (now in HOLD) will drop, instead of the newly swapped piece. Therefore, extra logic on the drop indicator piece was implemented to correct the behavior.

Next, to ensure consistency, I made it so that when a piece is put into HOLD, its orientation (i.e. rotation) is reverted back to upright. This means that every time the player swap a piece out of HOLD, the piece will be in an upright position, instead of whatever position it was when the player pressed HOLD. Since there are 4 possible orientations, if the player has to remember which orientation the HOLD piece was in, it is a huge burden especially if the player is swapping between different HOLD pieces. Thus, by reverting to always being upright, it adds more consistency to the outcome when using the HOLD functionality.

UI updates

But the HOLD piece won't work if the player can't see it!
Thus, the HUD must now have space for the HOLD slot, and the player should be able to see what piece is being held right now. I updated the UI to free up some space on the top-right in order to show the HOLD slot.

Image description

That is the end of the HOLD piece implementation. Personally, I feel that similar to the Next Piece Indicators, the HOLD piece adds another level of depth to the game and more rewards to carefully planned gameplay by strategic players. This also makes the training of an AI to play the game later more interesting.

...

✅ Tetris Development #5 - The HOLD Piece


📈 49.35 Punkte

✅ Tetris Development 3 - Simple Tetris Game in Godot


📈 36.52 Punkte

✅ Tetris Development 2 - Intro to Godot and Basic Tetris Setup


📈 36.52 Punkte

✅ »Tetris«-Rekord: 13-Jähriger stellt mit der Trommelmethode »Tetris«-Rekord auf


📈 29.94 Punkte

✅ Erster Tetris-Trailer: Apple zeigt die Geschichte von Tetris als Spionage-Thriller


📈 29.94 Punkte

✅ As Tetris Turns 35, Here’s How to Play Tetris in the Terminal


📈 29.94 Punkte

✅ Tetris Effect: Sony bringt das Hypno-Tetris


📈 29.94 Punkte

✅ Was ist ein Legal Hold (Litigation Hold)? - Storage-Insider


📈 26.89 Punkte

✅ A New Google Assistant Feature, 'Hold For Me,' Waits On Hold So You Don't Have To


📈 26.89 Punkte

✅ Tetris Development #6 - Risk and Reward


📈 21.55 Punkte

✅ Tetris Development #4 - Stop, Drop (and Roll?)


📈 21.55 Punkte

✅ Tetris Development 1 - Setting Up


📈 21.55 Punkte

✅ After years of development, 'Tetris' premieres March 31 on Apple TV+


📈 21.55 Punkte

✅ Even in low-code software development, IT departments still need to hold users' hands


📈 20.02 Punkte

✅ Bethesda Puts The Elder Scrolls: Legends Development on Hold Indefinitely


📈 20.02 Punkte

✅ Corporate Cultural Issues Hold Back Secure Software Development


📈 20.02 Punkte

✅ Als erster Gamer aller Zeiten: 13-Jähriger spielt Tetris bis zum Ende durch


📈 14.97 Punkte

✅ Tetris timer - the first part


📈 14.97 Punkte

✅ Hier kannst du Tetris als Font nutzen – und GIFs davon herunterladen


📈 14.97 Punkte

✅ Puyo Puyo Tetris 2 heute erschienen


📈 14.97 Punkte

✅ Electronic Arts nimmt Tetris aus dem App Store – und kappt die Spielbarkeit vorhandener Installationen


📈 14.97 Punkte

✅ "Tetris Effect VR": Epic-exklusives Game setzt Nutzung von Steam voraus


📈 14.97 Punkte

✅ Erstmals haben drei vernetzte Gehirne miteinander Tetris gespielt


📈 14.97 Punkte

✅ Teens Are Rewriting What Is Possible In the World of Competitive Tetris


📈 14.97 Punkte

✅ No terminal? No problem. Terminal-based Tetris clone netris now playable via web browser


📈 14.97 Punkte

✅ Tetris Royale: Neues Mobile-Game für Android und iOS angekündigt


📈 14.97 Punkte

✅ Tetris-Film: Dreh beginnt 2017, Macher versprechen "Überraschung"


📈 14.97 Punkte

✅ Bis zum Absturz: 13-Jähriger bezwingt als erster Mensch überhaupt Tetris


📈 14.97 Punkte

✅ Tetris, Zelda und Co.: Nintendo bringt Game-Boy-Klassiker auf die Switch


📈 14.97 Punkte

✅ Tetris im Web Englisch


📈 14.97 Punkte

✅ Tetris geschlagen: Ein Kind schafft nach 34 Jahren das Unmögliche


📈 14.97 Punkte

✅ MacStories Unwind: Tetris and Shrinking


📈 14.97 Punkte

✅ Stacker: So sieht Apples nie veröffentlichter Tetris-Klon für den iPod aus


📈 14.97 Punkte











matomo

Datei nicht gefunden!