# enchant.js 宿題2-1 ## 課題1: Coreとアセットの設定 ## タスク: enchant()を呼び出し、ゲームライブラリを初期化します。 ゲームのコアを作成します。このとき、ディスプレイのサイズも指定します。 ゲームで使用するすべてのアセットをプレロードします。 キーバインドを設定します。このゲームでは、スペースキーを使用します。 ### ヒント ゲームで使う画像を全て用意してpreloadしましょう。 coreを640✖︎640の大きさで作りましょう。 ### 開始コード: enchant(); window.onload = function () { const FISH = const HEART = const SHARK = const SEA = const START = const DISP_SIZE = var core = core.preload(); core.fps = 30; core.keybind(32, "Space"); } function rand(n) { return Math.floor(Math.random() * (n + 1)); } <details> <summary>解答</summary> enchant(); window.onload = function () { const FISH = "res/fish.png"; const HEART = "res/heart.png"; const SHARK = "res/shark.png"; const SEA = "res/Sea.png"; const START = "res/start.png"; const DISP_SIZE = 640; var core = new Core(DISP_SIZE, DISP_SIZE); core.preload(FISH, HEART, SHARK, SEA, START); core.fps = 30; core.keybind(32, "Space"); } function rand(n) { return Math.floor(Math.random() * (n + 1)); } </details>
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up