Creating a Simple Game Discussion

problem

hey @ivan what is this second error comming plz guide me problem 2
@ivan in the power shall it is saying python not found but i have installed the python on my pc

Hey @Ali_Ameen, hope you are ok.

You might have to install python, if the command python -m http.server shows the same error than your console, probably is because you do not have python installed in your computer.

Carlos Z

can you plz guide me what is that second error in the google chrome console tab

i have installed python but still it is giving the same error

Now you can try this options:

  • Open powershell as Administrator.
  • Use windows terminal (cmd) instead powershell.

If you have already python installed, one of those should be able to run it.

Carlos Z

thanks for your guidence but can you tell me after doing all that i have managed to resolve my problem but what is this error comming @ivan problem 3

You mean the favicon error? do not pay too much attention to that, its a common warning when there is no favicon (the icon for the website) configured.

Carlos Z

When im on windows powershell i type, python -m SimpleHTTPServer 8000 and it says, Python was not found; run without arguments to install from the Microssoft store, or disable this shortcut from settings
@Ivanontech_User01

it still doesnt work

Try with this tutorial, you might have not install it properly since does not recognize the path for python.
https://thewisebulb.com/fix-python-not-recognized-error-in-the-windows-command-prompt/

Carlos Z

1 Like

Hey, I found a phaser-ts template for anyone with Typescript addict xD

https://github.com/yandeu/phaser-project-template

1 Like

this is my code, the pictures do not show up can someone please help?.

Our gross game <3
<h1>Game website</h1>
<h2>game website sencond heading bestie</h2>

<script>

  var cursors;
  var knight;
  var crates;

  // configure the game (height, width, render-type, game loop functions
  var config = {
    width:800,
    height:500,
    type:Phaser.AUTO,

    scene:{
      preload: gamePreload,
      create: gameCreate,
      update: gameUpdate
    },

    physics:{
      default:"arcade",
      arcade:{
        gravity:{y:200},
        debug:false
      }
    }

  }

  function gamePreload(){
    // loading assets
    console.log("game is loading assets bestie");
    this.load.image("knight","assets/knight.png");
    this.load.image("crate","assets/crate.png");
  }

  function gameCreate(){
    // initial setup logic on the asset and other setups
    console.log("game is setting up the assets etc");

    // create the knight
    knight = this.physics.add.sprite(200,100,"knight");
    knight.body.setSize(400,600,10,0);
    knight.scaleX = 0.3;
    knight.scaleY = knight.scaleX;

    //create the crates
    crates = this.physics.add.staticGroup();
    crates.create(40,460,"crate");
    crates.create(120,460,"crate");
    crates.create(200,460,"crate");
    crates.create(280,460,"crate");
    crates.create(360,460,"crate");
    crates.create(440,460,"crate");

    this.physics.add.collider(crates, knight);

    cursors = this.input.keyboard.createCursorKeys();
  }

  function gameUpdate(){
    // monitoring inputs and telling game how to update

    if(cursors.left.isDown){
      knight.setVelocityX(-100);
    }
    else if(cursors.right.isDown){
      knight.setVelocityX(100);
    }
    else{
      knight.setVelocityX(0);
    }
    if(cursors.up.isDown && knight.body.touching.down){
      knight.setVelocityY(-300);
    }
  }

  var game = new Phaser.Game(config);

Thanks for the help, but its still not working. Any other options?.

What about using windows command promt? (CDM) instead of powershell.

Try to run the same command but in CMD, maybe its powershell that is not working properly.

Carlos Z

heya…
Added sound in the game to make it more ambient and immersive. Have a look -
https://github.com/tagupta/Pump-Up-Your-Bag-Game

Thanks

3 Likes

Install Python from Windows Store. Just type windows store in your windows search bar and then install it from there. That worked for me.

1 Like

For all people having this error “No module named SimpleHTTPServer” when runing the code: “python -m SimpleHTTPServer” :

You have to type “python -m http.server”. http.server instead of SimpleHTTPServer.

3 Likes

Worth placing an update/note below the video, chances are people will take the latest version of Python or any Python version 3.X:

Use the command ‘python -m http.server’ (for anyone using Python 3.X) to run a local web server

1 Like

Hi, @thecil
Im having and error when trying to get coins to collide, can you help me out?

<html>

<head>
  <title>ETHERUEM KNIGHTS GAME</title>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script>

</head>

<body>

<h1>ETHEREUEM KNIGHTS</h1>

<h2> Game Website second heading</h2>


<script>
  //configure the game (height,width, render-type,game loop)

    var cursors;
    var knight;
    var crate;
    var coinTimer;


    var config = {
      width:800,
      height:500,
      type:Phaser.AUTO,
      scene:{
        preload: gamePreload,
        create: gameCreate,
        update: gameUpdate
      },

      physics:{
        default: "arcade",
        arcade:{
          gravity:{y:800},
          debug:false
        }
      }
    }

    function gamePreload(){
      //loading assets
      console.log("game is loading assets")
      this.load.image("knight", "assets/knight.png");
      this.load.image("crate", "assets/crate.png");
      this.load.image("background", "assets/background.png");
      this.load.image("bitcoin", "assets/bitcoin.png");

      //Load Run Animation
      this.load.image("run_frame_1", "assets/Run (1).png");
      this.load.image("run_frame_2", "assets/Run (2).png");
      this.load.image("run_frame_3", "assets/Run (3).png");
      this.load.image("run_frame_4", "assets/Run (4).png");
      this.load.image("run_frame_5", "assets/Run (5).png");
      this.load.image("run_frame_6", "assets/Run (6).png");
      this.load.image("run_frame_7", "assets/Run (7).png");
      this.load.image("run_frame_8", "assets/Run (8).png");
      this.load.image("run_frame_9", "assets/Run (9).png");
      this.load.image("run_frame_10", "assets/Run (10).png");

      //Load Idle Animation
      this.load.image("idle_frame_1", "assets/Idle (1).png");
      this.load.image("idle_frame_2", "assets/Idle (2).png");
      this.load.image("idle_frame_3", "assets/Idle (3).png");
      this.load.image("idle_frame_4", "assets/Idle (4).png");
      this.load.image("idle_frame_5", "assets/Idle (5).png");
      this.load.image("idle_frame_6", "assets/Idle (6).png");
      this.load.image("idle_frame_7", "assets/Idle (7).png");
      this.load.image("idle_frame_8", "assets/Idle (8).png");
      this.load.image("idle_frame_9", "assets/Idle (9).png");
      this.load.image("idle_frame_10", "assets/Idle (10).png");

    }


    function gameCreate(){
      //intial setup logic on the asset
      console.log("game is setting up assets")


      //create backround
      this.add.image(300,300,"background");

      //create coins



      //create Knight
      knight = this.physics.add.sprite(200,100, "knight")
      knight.body.setSize(200,600,10,0);
      knight.scaleX = 0.15;
      knight.scaleY = knight.scaleX;

      // create the floor
      crates = this.physics.add.staticGroup();
      crates.create(40,460,"crate");
      crates.create(120,460,"crate");
      crates.create(200,460,"crate");
      crates.create(280,460,"crate");



      //Create platforms
      crates.create(440,360, "crate");
      crates.create(480,260, "crate");
      crates.create(280,260, "crate");
      crates.create(180,220, "crate");

      crates.create(720,460, "crate");
      crates.create(720,150, "crate");
      crates.create(530,350, "crate");

      // create run Animation
      this.anims.create({
        key: "knight_run",
        frames:[
          {key: "run_frame_1"},
          {key: "run_frame_2"},
          {key: "run_frame_3"},
          {key: "run_frame_4"},
          {key: "run_frame_5"},
          {key: "run_frame_6"},
          {key: "run_frame_7"},
          {key: "run_frame_8"},
          {key: "run_frame_9"},
          {key: "run_frame_10"},
        ],
        frameRate: 10,
        repeat: 1
      });

      // create idle Animation
      this.anims.create({
        key: "knight_idle",
        frames:[
          {key: "idle_frame_1"},
          {key: "idle_frame_2"},
          {key: "idle_frame_3"},
          {key: "idle_frame_4"},
          {key: "idle_frame_5"},
          {key: "idle_frame_6"},
          {key: "idle_frame_7"},
          {key: "idle_frame_8"},
          {key: "idle_frame_9"},
          {key: "idle_frame_10"},
        ],
        frameRate: 10,
        repeat: 1
      });

      this.physics.add.collider(crates, knight);

      cursors = this.input.keyboard.createCursorKeys();

      coinTimer = this.time.addEvent({

          delay: Phaser.Math.Between(1000,3000),
          callback: generateCoins,
          callbackScope: this,
          repeat: -1


      });

    }

    // Randomly generates coins in game
    function generateCoins(){


      var coins = this.physics.add.group({
        key: "bitcoin",
        repeat: 1,
        setXY:{
          x:Phaser.Math.Between(0,800),
          y: -100,
          stepX: Phaser.Math.Between(30, 100)
        }
      });

      coins.childern.iterate(function(child){
        // code to execute on each coin
        child.setBounceY(Phaser.Math.FloatBetween(0.4,1.5))
      });

      this.physics.add.collider(coins,crates);
    }


    // Game is Updated continuosly
    function gameUpdate(){
      //monitor inputs, telling game how to update
      //console.log("game is updating")
      if(cursors.left.isDown){
        knight.setVelocityX(-200);
        knight.play("knight_run", true);
        knight.flipX = true;
      }
      else if(cursors.right.isDown){
        knight.setVelocityX(200);
        knight.play("knight_run", true);
        knight.flipX = false;
      }
      else{
        knight.setVelocityX(0);
        knight.play("knight_idle", true);
      }

      if(cursors.up.isDown && knight.body.touching.down){
        knight.setVelocityY(-500);
      }

    }

    var game = new Phaser.Game(config);


  </script>




</body>






</html>

Hello @Javier_Flores

You might need to correct the typo to access the right property then iterating the children (coins):

coins.childern.iterate(function(child){

‘childern’ => ‘children’

Hope that solves the issue.
With kind regards

1 Like