Advertisement
Guest User

xD

a guest
Jan 22nd, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1.  
  2. <!doctype html>
  3. <html>
  4. <head>
  5. <meta charset="UTF-8" />
  6. <title>Simple game</title>
  7.  
  8. <script src="phaser.min.js"></script>
  9.  
  10. </head>
  11. <body>
  12.  
  13. <script type="text/javascript">
  14. var game = new Phaser.Game(640, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });
  15. var player;
  16. var cursors;
  17. function preload() {
  18. game.load.image('asset', 'assets/asset.png');
  19. cursors = game.input.keyboard.createCursorKeys();
  20. }
  21. function create() {
  22. player = game.add.sprite(100, 100, 'asset');
  23. }
  24. function update() {
  25. if(cursors.left.isDown){
  26. player.x -= 1;
  27. }
  28. if(cursors.right.isDown){
  29. player.x += 1;
  30. }
  31. if (cursors.down.isDown){
  32. player.y += 1;
  33. }
  34. if (cursors.up.isDown){
  35. player.y -= 1;
  36. }
  37. }
  38. </script>
  39.  
  40. </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement