Urgent.News

What's breaking now, across thousands of outlets.

Tech

Why your falling-blocks game feels unfair (and three small fixes)

You can build a falling-blocks game that follows every rule and still have players call it unfair within a minute. The pieces fall, rows clear, the score goes up, but something feels off. They get five S pieces in a row. The long bar refuses to turn next to the wall. A piece freezes the instant it touches down, before they can slide it into the gap. None of those are bugs. They're missing…

Falling-blocks games often feel unfair, even when they are built according to the rules. Players may notice certain pieces appearing in clusters or long gaps between specific shapes, leading to frustration. To address these issues, three small fixes can be implemented.

First, replace pure randomness with a shuffled bag of pieces. Instead of each shape having an equal chance every time (1-in-7), the bag approach ensures every piece appears once per seven pieces. This method uses a Fisher-Yates shuffle algorithm to randomize the order of pieces in the bag. By dealing from the bag and refilling it when empty, players experience a more balanced distribution of shapes, preventing the dreaded "30-piece drought."

Second, implement wall kicks for smooth rotation near walls. The rotation process is straightforward once each piece is represented as a grid of 1s and 0s. However, when turning a long piece like the I-shaped one next to a wall, the rotated shape may stick out, causing the collision check to fail and the turn to be refused. To fix this, the game can attempt to nudge the piece slightly before giving up on the rotation.

By checking if the turned piece fits in six possible positions (no nudge, one cell left, one cell right, one cell up, two cells sideways), the game can find the first fitting position and allow the rotation to proceed without the player feeling ignored.

Lastly, introduce a lock delay to prevent instant death upon landing. When the player drops a piece onto the board, the game should introduce a brief delay before the piece locks into place. This delay gives players a chance to react if a piece gets stuck or collides unexpectedly. By adding a lock delay, the game reduces the frustration caused by sudden blockages and provides players with a small window to adjust their strategy, making the game feel more fair.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Python Decorators: A complete guide to decorators in Python

If you've seen something like @yo_i_am_decorating_this_func above a Python function and wondered what's going on, you're in the right place.

  • Decorators modify function behavior in Python
  • Functions are first-class objects in Python
  • Decorators use closures to wrap original functions

Why Translating a PDF Before Filling Forms Breaks Fields and Doubles Credit Costs

Sending a raw 25-page vendor packet to a document translator before fixing it locally causes two avoidable problems. First, at 2 credits per page, translating eight appendix pages you meant to delete…

  • Translating PDF before editing creates 16 extra credits for deleted pages.
  • Editing text in translated PDFs may break due to tightly subsetted fonts.
  • Editing in browser first ensures clean PDF before transmitting to recipients.

Elm for Beginners: Frontend Code With No Runtime Errors

Elm is a functional language for building web frontends, and it makes a bold promise: no runtime errors. If your Elm program compiles, it will not crash in the browser with an undefined value or a…

  • Elm is a functional language for error-free web frontends.
  • Its Model-Update-View architecture simplifies state management.
  • Elm's compiler ensures code compiles correctly, reducing runtime errors.

A Better Website Brief for a Manufacturing or B2B Supplier

A manufacturing or B2B supplier website is often asked to do several jobs at once: explain a complex product range, help buyers judge whether a supplier is credible, answer practical questions, and…

  • Focus on buyer's journey, not visual effects
  • Differentiate product families and SKUs with filters
  • Provide verifiable information and clear next steps

More from Friday 13 November →