Advertisement
metalx1000

make_phaser

Jun 14th, 2015
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.35 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. browser="google-chrome"
  4.  
  5. if [ "$1" != "" ]
  6. then
  7.   mkdir "$1"
  8.   cd "$1"
  9. fi
  10.  
  11. mkdir -p js css res/sounds res/sprites res/images res/music
  12.  
  13. #get phaser
  14. wget "https://raw.githubusercontent.com/photonstorm/phaser/master/build/phaser.js" -O "js/phaser.js"
  15.  
  16. #get some resources
  17. wget "http://files.gamebanana.com/img/ico/sprays/mario_tux_3.png" -O res/images/image1.png
  18. #music by http://multi8it.blogspot.com/
  19. wget "https://github.com/metalx1000/Phaser_Game_Template/blob/master/res/music/music.mp3?raw=true" -O res/music/music1.mp3
  20.  
  21. ffmpeg -i res/music/music1.mp3 res/music/music1.ogg
  22.  
  23. #create index
  24. cat << EOF > index.html
  25. <!DOCTYPE html>
  26. <html>
  27. <head>
  28.   <!-- Include stylesheets -->
  29.   <link rel="stylesheet" href="css/main.css">
  30.   <!-- Include Phaser library -->
  31.   <script src="js/phaser.js"></script>
  32.   <!-- Include the Game libraries -->
  33.   <script src="js/main.js"></script>
  34. </head>
  35. <body>
  36. </body>
  37. </html>
  38. EOF
  39.  
  40. #create basic CSS
  41. cat << EOC > css/main.css
  42. body{
  43.   width: 800px;
  44.   margin: 0px auto;
  45.   background-color:black;
  46. }
  47. EOC
  48.  
  49. #create main JS
  50. cat << EOJ > js/main.js
  51. var game = new Phaser.Game(1280, 720, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update});
  52. var centerx = game.width / 2;
  53. var centery = game.height / 2;
  54.  
  55. function preload() {
  56.  
  57.   //  You can fill the preloader with as many assets as your game requires
  58.  
  59.   //  Here we are loading an image. The first parameter is the unique
  60.   //  string by which we'll identify the image later in our code.
  61.  
  62.  //  The second parameter is the URL of the image (relative)
  63.  game.load.image('image1', 'res/images/image1.png');
  64.  
  65.  game.load.audio('music', ['res/music/music1.ogg', 'res/music/music1.mp3']);
  66. }
  67.  
  68. function create() {
  69.  
  70.  //  This creates a simple sprite that is using our loaded image and
  71.  //  displays it on-screen
  72.  
  73.  image = game.add.sprite(centerx, centery, 'image1');
  74.  image.scale.setTo(0.5,0.5);
  75.  image.anchor.setTo(0.5, 0.5);
  76.  
  77.  
  78.  //  Play some music
  79.  music = game.add.audio('music');
  80.  music.play('',0,1,true);
  81.  
  82.  // start fullscreen on click
  83.  game.input.onDown.add(go_fullscreen, this);
  84. }
  85.  
  86. function update(){
  87.  //this is where things are updated
  88. }
  89.  
  90. function go_fullscreen(){
  91.  game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL;
  92.  game.scale.startFullScreen();
  93. }
  94.  
  95. EOJ
  96.  
  97. #$browser localhost
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement