Skip to content

Conversation

igrep
Copy link
Contributor

@igrep igrep commented Jul 31, 2025

Description

I migrated all the examples and the descriptions in the "2D breakout game using Phaser" tutorial to Phaser 3. I also migrated the live samples from JSFiddle.

Motivation

Same as #35578

Additional details

Related issues and pull requests

Fixes #35578
Part of #40520

igrep added 25 commits July 31, 2025 22:12
…aser 3.90

I'm going to add the asset images later
@igrep igrep requested a review from a team as a code owner July 31, 2025 13:32
@igrep igrep requested review from hamishwillee and removed request for a team July 31, 2025 13:32
@github-actions github-actions bot added Content:Games Games docs size/xl [PR only] >1000 LoC changed labels Jul 31, 2025
Copy link
Contributor

github-actions bot commented Jul 31, 2025

Preview URLs (28 pages)
External URLs (10)

URL: /en-US/docs/Games/Tutorials/2D_breakout_game_Phaser
Title: 2D breakout game using Phaser


URL: /en-US/docs/Games/Tutorials/2D_breakout_game_Phaser/Animations_and_tweens
Title: Animations and tweens


URL: /en-US/docs/Games/Tutorials/2D_breakout_game_Phaser/Build_the_brick_field
Title: Build the brick field


URL: /en-US/docs/Games/Tutorials/2D_breakout_game_Phaser/Buttons
Title: Buttons


URL: /en-US/docs/Games/Tutorials/2D_breakout_game_Phaser/Initialize_the_framework
Title: Initialize the framework


URL: /en-US/docs/Games/Tutorials/2D_breakout_game_Phaser/Load_the_assets_and_print_them_on_screen
Title: Load the assets and print them on screen


URL: /en-US/docs/Games/Tutorials/2D_breakout_game_Phaser/Physics
Title: Physics


URL: /en-US/docs/Games/Tutorials/2D_breakout_game_Phaser/Player_paddle_and_controls
Title: Player paddle and controls

(comment last updated: 2025-08-02 17:41:42)

@hamishwillee
Copy link
Collaborator

Thanks @igrep I am removing my assignment as I am not familiar with this code or games in particular. There are a lot of reviewers on holiday at the moment, so this may not be picked up in a short timeframe.

@hamishwillee hamishwillee removed their request for review August 1, 2025 00:26
Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

Sorry I had a review but looks like I failed to commit it. I'm happy to take this on.

function preload() {
//
game.load.image("brick", "img/brick.png");
preload () {
Copy link
Member

Choose a reason for hiding this comment

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

This kind of code doesn't parse correctly, so as you can see it's not correctly formatted and will make my linter choke. You would need to wrap it with any necessary context. What I usually do is

class Example extends Phaser.Scene {
  // ...
  preload() {
    // ...
    this.load.image("brick", "img/brick.png");
  }
  // ...
}

You would need to update all other cases like this as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Fixed it by a5e4b71

@hamishwillee
Copy link
Collaborator

Sorry I had a review but looks like I failed to commit it. I'm happy to take this on.

Thank you. @igrep You're in the safest of hands.

@igrep
Copy link
Contributor Author

igrep commented Aug 2, 2025

😕Weird. Why did the formatter suggest only 3 blocks to change even after fixing the syntax errors pointed out by #40581 (comment)? I tried npx prettier --write files/en-us/games/tutorials/2d_breakout_game_phaser/*/index.md on my end, but I got the same result.

@igrep igrep requested a review from Josh-Cena August 2, 2025 12:18
@Josh-Cena
Copy link
Member

@bsmth @igrep I think we should transfer the code repository to the mdn org. WDYT? (Brian is OOO so it may take a while to respond, but this isn't blocking)

@Josh-Cena
Copy link
Member

I'm working on this locally and I think it's safe to remove all of the repo links, because the code is inside the live samples anyway. External repos, whether hosted somewhere else or in the mdn org, are hard to maintain because they need to be in sync with the tutorial's content (for example right now I'm doing refactors, and I don't want to manually make the same changes to another repo).

@Josh-Cena Josh-Cena requested a review from a team as a code owner August 2, 2025 16:45
@Josh-Cena Josh-Cena requested review from pepelsbey and removed request for a team August 2, 2025 16:45
@github-actions github-actions bot added the system [PR only] Infrastructure and configuration for the project label Aug 2, 2025
}
</style>
<script src="js/phaser.min.js"></script>
</head>
Copy link
Member

Choose a reason for hiding this comment

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

(In the line above) Should we consistently use the CDN version instead of a local version? (No strong opinions)

You can check the finished code for this lesson in the live demo below, and play with it to understand better how it works:

{{JSFiddleEmbed("https://jsfiddle.net/end3r/436bckb7/","","400")}}
_NOTE_: Due to the limitations of the live demo, you will not see the alert. The game will immediately reload when the ball goes out of bounds.
Copy link
Member

Choose a reason for hiding this comment

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

FYI here's how you allow alert():

{{EmbedLiveSample("compare your code", "", 480, , , , , "allow-modals")}}

I'm going to remove the alert() anyway because it's quite annoying.

Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

I've verified that everything works as intended. Thank you so, so much! You really deserve a big medal for all this work.

@Josh-Cena Josh-Cena merged commit 4483da6 into mdn:main Aug 2, 2025
9 checks passed
@Josh-Cena
Copy link
Member

@igrep I just realized we have another page using Phaser 2: https://developer.mozilla.org/en-US/docs/Games/Tutorials/HTML5_Gamedev_Phaser_Device_Orientation wondering if you are interested in updating that one as well. No pressure though.

@igrep igrep deleted the fix-35578 branch August 2, 2025 22:10
@igrep
Copy link
Contributor Author

igrep commented Aug 2, 2025

Thank you very much for modifying and merging!

External repos, whether hosted somewhere else or in the mdn org, are hard to maintain because they need to be in sync with the tutorial's content (for example right now I'm doing refactors, and I don't want to manually make the same changes to another repo).

I agree. However, we should consider the difference between the local version and the live sample: this.load.setBaseURL and the path to the image files.

I just realized we have another page using Phaser 2: https://developer.mozilla.org/en-US/docs/Games/Tutorials/HTML5_Gamedev_Phaser_Device_Orientation wondering if you are interested in updating that one as well. No pressure though.

If I remember, after Phaser 4 gets stabilized enough (currently it's in RC) 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Games Games docs size/xl [PR only] >1000 LoC changed system [PR only] Infrastructure and configuration for the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Phaser in "2D breakout game using Phaser"
3 participants