Jump to content

New to Phaser and JS, how'd I do with Pong?


Jokgee
 Share

Recommended Posts

Apologies if this is the wrong board, but I'm not sure where else to post it. I've been learning Javascript over the past few months and decided to make Pong a few days ago, over the course of a few hours and I was hoping a few people could critique my code. I'm not new to programming by any stretch of the imagination, but my JS and gamedev knowledge using a library like this is a bit shaky to say the least so any tips, critiques, etc. would be extremely helpful.

 

The game. There's a link to play it in the readme.md, all of the code is in main.js. Ignore the /lib/ folder.

 

I'm also hoping for some critiques on my project layout. I'm not sure what the standard is for something like Phaser.

Link to comment
Share on other sites

I think it looks pretty good for a first time in Phaser :).

Anyway, talking about layout:

In general I make a separate js file for the preloader. This way you can make a custom loading screens (by first loading the loading screen assets quickly followed by loading in all assets). Now for a small game like pong this doesn't really matter, but for bigger games with a lot of assets this prevents you from seeing a black screen for a few seconds. It also makes it easier to make a menu and multiple levels (if that applies for the game you are making). There is a template available: https://github.com/photonstorm/phaser/tree/master/resources/Project Templates/Basic

Link to comment
Share on other sites

11 hours ago, Taggrin said:

I think it looks pretty good for a first time in Phaser :).

Anyway, talking about layout:

In general I make a separate js file for the preloader. This way you can make a custom loading screens (by first loading the loading screen assets quickly followed by loading in all assets). Now for a small game like pong this doesn't really matter, but for bigger games with a lot of assets this prevents you from seeing a black screen for a few seconds. It also makes it easier to make a menu and multiple levels (if that applies for the game you are making). There is a template available: https://github.com/photonstorm/phaser/tree/master/resources/Project Templates/Basic

Thanks :)

Is there a more up to date template? The last commit was 2 years ago and there are a ton of issues on the repo

Link to comment
Share on other sites

This looks good and congrats on your first Phaser game. :) I would just say

  • You can omit `Phaser.Physics.ARCADE` if you like since it's the default.

https://github.com/photonstorm/phaser/tree/master/resources/Project Templates/Basic should work fine; the new issues are for Phaser itself.

Before you add a second state (preloader) I would try writing your existing game as a single state object. Once you're comfortable with that using multiple states will be easier to understand.

Edited by samme
Oops, can be strings
Link to comment
Share on other sites

I think use whatever folder structure makes sense and helps you find what you're looking for.

For example, I tend to put everything in a "src" folder. Underneath that there's a folder for "sprites", with a "particles" folder inside that. I have another folder called "states". "filters" holds the (you guessed it) filters, "map" holds everything to do with the tilemaps that I'm loading. "plugins" are the Phaser plugins that I write for my game.

I don't think there's a right or wrong approach here.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...