ruffle-rs / ruffle

A Flash Player emulator written in Rust
https://ruffle.rs
Other
15.06k stars 776 forks source link

Collision detection not working on Juicy Breakout game #16757

Open leissler opened 2 weeks ago

leissler commented 2 weeks ago

Describe the bug

I've downloaded the Juicy Breakout Flash game from the famous talk "Juice it or lose it" by Martin Jonasson & Petri .Purho (https://www.youtube.com/watch?v=Fy0aCDmgnxg&ab_channel=grapefrukt). It seems to be taken down from their own site, but I put it back up here: http://play.fbmd.h-da.de/juicybreakout/ Everything works fine except when enabling the ball trail in the TAB-Menu under particles (or just pressing ENTER to enable all effects). Any collision detection completely fails and spawning balls with "b" freezes the former ball. The source code of Juicy Breakout ActionScript3 project is at GitHub here: https://github.com/grapefrukt/juicy-breakout. I've also included a version with the same SWF running locally with the Ruffle desktop app. Just download and unzip; then select the juicybreakout.swf file and run it. juicybreakout_local.zip

Expected behavior

When running the game with the official Flash player, enabling the Ball Trail feature works fine and the ball with trail still has collision detection against walls, blocks, and the paddle.

Content Location

Local: juicybreakout_local.zip

Web: http://play.fbmd.h-da.de/juicybreakout/

Affected platform

Desktop app

Operating system

macOS Sonoma (14.5)

Browser

Google Chrome, Version 125.0.6422.144 (Official Build) (x86_64)

Additional information

No response

kjarosh commented 2 weeks ago

Logs:

ERROR run_frame:run_all_phases_avm2: ruffle_core::avm2::events: Error dispatching event EventObject(EventObject { type: "enterFrame", class: flash.events::Event, ptr: 0x5596fe33fd10 }) to handler FunctionObject(FunctionObject { ptr: 0x5596fcc9e190, name: Ok("com.grapefrukt.games.juicy::Main/handleEnterFrame()") }) : RangeError: Error #1125: The index 120 is out of range 120.
        at flash.display::Graphics/flash::display::Graphics::drawTriangles()
        at com.grapefrukt.games.juicy.effects::Rainbow/redrawSegments()
        at com.grapefrukt.games.juicy.gameobjects::Ball/update()
        at com.grapefrukt.games.general.collections::GameObjectCollection/update()
        at com.grapefrukt.games.juicy::Main/handleEnterFrame()

It seems that it's an issue with Graphics.drawTriangles — when indices are out of range, they should be ignored and no error should be thrown.

kjarosh commented 2 weeks ago

Enabling the ball trail now works, but there are some rendering issues due to wrong winding rule used in Graphics.drawTriangles.