Welcome to the beginning of your game development journey! In this lesson, we’ll explore the folder structure and prepare the foundational setup for our Spanish language quiz game. If you’d like to follow along, use the files in the 00-starting folder, which contain all the assets you’ll need. For this lesson, I’ll be coding in the 01 folder, which includes the finished files for reference. To practice, start from 00 and build the game alongside the tutorial.
The folder structure is simple and organized for ease of use:
index.html:
js folder:
assets folder:
In the game.js file, we start by defining a new scene named "Game"
with the following basic methods:
We define key settings to control how the game behaves:
The preload method ensures all assets are loaded into memory before gameplay begins, preventing disruptions during play.
Use this.load.image
to load images. Each image is given a key and a file path. Example:
Other images, such as background-city
, building
, car
, house
, and tree
, follow the same pattern.
In the create method, which is executed after all assets are loaded, we display the background sprite using:
To position the sprite easily, we adjust its origin to the top-left corner:
Audio files are loaded in a similar manner using this.load.audio
. Assign each audio file a key and specify its location. Example:
Other audio files, like car
, house
, building
, correct
, and wrong
, are loaded the same way.
When choosing audio formats, consider compatibility:
MP3:
AAC:
For this project, MP3 is ideal due to its broad compatibility.
For this project: