Created
April 14, 2015 04:23
-
-
Save thaisingle/aa146d9806229d2bf26f to your computer and use it in GitHub Desktop.
How to create Flappy Bird (Part 1) - Create game world
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Flappy Bird</title> | |
<script type="text/javascript" src="js/phaser.min.js"></script> | |
<script type="text/javascript" src="js/main.js"></script> | |
</head> | |
<body> | |
<div id="flappyDiv"> </div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//เราจะสร้าง Game Wolrd ของเราขึ้นมาขนาด 400 x 490 | |
//โดยใช้ระบบ Render แบบ Auto | |
//และให้ Game แสดงผลใน flappyDiv คือส่วนของ <div> ที่กำหนดไว้ใน flappy.html | |
//จากนั้นสร้าง Game World ไว้ใน ตัวแปร game | |
var game = new Phaser.Game(400, 490, Phaser.AUTO, 'flappyDiv'); | |
//ส่วนของ logic เกมส์ที่เราเขียนแล้วเก็บไว้ในตัวแปร mainstate | |
var mainState = { | |
preload: function() { | |
//พื่นที่สำหรับโหลด /assets | |
game.stage.backgroundColor = '#71c5cf'; | |
}, | |
create: function() { | |
//พื่นที่ setup game และแสดงผล | |
}, | |
update: function() { | |
//พื่นที่ loop game 60 times ต่อวินาที | |
//ไว้เขียน logic | |
}, | |
}; | |
//ตัวแปร mainState จะถูกสร้างเป็น state ตั้งชื่อเป็น main | |
game.state.add('main', mainState); | |
//เริ่มต้น state | |
game.state.start('main'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment