Kraken

Members
  • Content count

    25
  • Joined

  • Last visited

About Kraken

  • Rank
    Member

Recent Profile Visitors

119 profile views
  1. OK so should I put the code of the game inside the IIFE? I'm fairly new to JS and I'm not sure how this would protect the code on the client.
  2. Hey Arcanorum, I guess once the files are on the web they are not really safe anymore. Do you recommend JSCompress?
  3. Thanks JohnCitron, do you recommend I use something like JScrambler to encrypt the game?
  4. I didn't even know about circle physics bodies. Thanks Arcanorum! I contemplated using a timer but I wanted to keep the bubble effect and make the player hit an urchin to shrink back.
  5. Here is my second try at a phaser game. I based it on the flappy bird tutorial. Let me know what you think I could do to improve it. https://kraken18.github.io/flappyboard/
  6. Awesome, I'm gonna have a look around those sites
  7. I'm pretty new to phaser and JS and I'm wondering if anyone knows where to get good graphics. Possibly custom graphics if possible.
  8. This did the trick thanks alot Samme!
  9. Yes I noticed that as well but you're right it did not fix the issue
  10. if(this.x+this.width < this.bird.x && this.giveScore){
  11. I'm trying to make a flappy bird game and I'm getting an error Uncaught TypeError: Cannot read property 'x' of undefined Game.js:76 I'm not sure if its the constructor or something else giving me this error...I have attached the code for reference var FlappyBoard = FlappyBoard || {}; FlappyBoard.GameState = { init: function() { // bird gravity, will make bird fall if you don't flap this.birdGravity = 800; // horizontal bird speed this.birdSpeed = 125; // flap thrust this.birdFlapPower = 300; // milliseconds between the creation of two pipes this.pipeInterval = 2000; // hole between pipes, in puxels this.pipeHole = 120; this.score=0; this.pipeGroup = this.add.group(); }, create:function(){ this.topScore = localStorage.getItem("topFlappyScore")==null?0:localStorage.getItem("topFlappyScore"); scoreText = this.add.text(10,10,"-",{ font:"bold 16px Arial" }); this.updateScore(); this.stage.backgroundColor = "#87CEEB"; this.stage.disableVisibilityChange = true; //game.physics.startSystem(Phaser.Physics.ARCADE); this.bird = this.add.sprite(80,240,'bird'); this.bird.anchor.set(0.5); this.game.physics.arcade.enable(this.bird); this.bird.body.gravity.y = this.birdGravity; this.game.input.onDown.add(this.flap, this); this.game.time.events.loop(this.pipeInterval, this.addPipe); this.addPipe(); }, update:function(){ this.game.physics.arcade.collide(this.bird, this.pipeGroup, this.die, null, this); }, //this.game.state.start('GameState'); updateScore: function(){ scoreText.text = "Score: "+this.score+"\nBest: "+this.topScore; }, flap: function(){ this.bird.body.velocity.y = -this.birdFlapPower; }, addPipe: function(){ var pipeHolePosition = this.rnd.between(50,430-this.pipeHole); var upperPipe = new FlappyBoard.Pipe(this.game,320,pipeHolePosition-480,-this.birdSpeed, 'pipe'); this.game.add.existing(upperPipe); this.pipeGroup.add(upperPipe); var lowerPipe = new FlappyBoard.Pipe(this.game,320,pipeHolePosition+this.pipeHole,-this.birdSpeed); this.game.add.existing(lowerPipe); this.pipeGroup.add(lowerPipe); }, die: function(){ localStorage.setItem("topFlappyScore",Math.max(this.score,topScore)); } }; FlappyBoard.Pipe = function (game, x, y, speed) { Phaser.Sprite.call(this, game, x, y, 'pipe'); game.physics.enable(this, Phaser.Physics.ARCADE); this.body.velocity.x = speed; this.giveScore = true; }; FlappyBoard.Pipe.prototype = Object.create(Phaser.Sprite.prototype); FlappyBoard.Pipe.prototype.constructor = FlappyBoard.Pipe; FlappyBoard.Pipe.prototype.update = function() { if(this.x+this.width < this.bird.x && this.giveScore){ this.score+=0.5; this.updateScore(); this.giveScore = false; } if(this.x<-this.width){ this.destroy(); } };
  12. Hi Pheaset, thanks for trying it out. I'm not sure why the game.html doesn't work for you but either way it should be on either URL. I used the infinite runner tutorial from the Zenva Academy.
  13. I created my first game, an endless runner game based off the tutorial. Let me know any improvements or recommendations you have. https://kraken18.github.io/game.html
  14. Just to confirm... gravity was the issue now that I have set it to 1000 I no longer get stuck. Anything over that number somehow causes problems when the platform created is lower than the previous one. Thanks scheffgames, I honestly would of never thought it was the gravity.
  15. I'm using arcade physics, I have disabled the cache as you suggested this is basically my player code... this.player = this.add.sprite(200, 200, 'player1'); this.player.anchor.setTo(0.5); this.player.animations.add('running', [1,2,3,4,5,6], 10, true); this.player.animations.add('jumping', [7], true); this.game.physics.arcade.enable(this.player); this.player.body.setSize(58,83, 10, 11); but as for the buggy code I honestly couldn't tell you what it would be as the game will be working fine and then the player gets stuck randomly. I did see the correlation between the gravity setting though I even increased it on the enemy bodies only and it seems to effect the player getting stuck as well. I lowered the gravity equally on everything and I get stuck very rarely now if at all.