• Content count

  • Joined

  • Last visited

About Thunderfist

  • Rank
    Advanced Member
  1. I can't find the bugs in my code

    I found that my enemyPrefab.js has a bug: According to my console, it says Cannot set property 'prototype' of undefined at enemyPrefab.js line 20. Is there a workaround for that? It's the only thing that's showing up in the console for bugs. EDIT I took a look at someone's tutorial and found what I did wrong. The code still isn't working right yet, but I'm getting there. I found this in the console: Phaser.StateManager - No state found with the key: game
  2. I can't find the bugs in my code

    I just checked the console, and it says GainNode.gain.value setting is deprecated and can't be used after last month. Is there some sort of work-around? UPDATE: All of the errors in the console are pointing at my phaser.js. does the Phaser library get updated?
  3. I can't find the bugs in my code

    Okay, I still can't find the bug... Maybe it's in my player.js? var RPG = RPG || {}; RPG.Player = function (state, x, y, data) {,, x, y, 'player'); this.state = state; =; = data; this.anchor.setTo(0.5); //walking animation this.animations.add('walk', [0, 1, 0], 6, false); //enable physics; }; RPG.Player.prototype = Object.create(Phaser.Sprite.prototype); RPG.Player.prototype.constructor = RPG.Player; RPG.Player.prototype.collectItem = function (item) { //two types of items, quest items and consumables if ( {; //check quest completion this.checkQuestCompletion(item); } else { //consumable items //add properties += || === 0; += || === 0; += || === 0; += || === 0; //refresh stats this.state.refreshStats(); } item.kill(); }; RPG.Player.prototype.checkQuestCompletion = function (item) { var i = 0; var len =; while (i < len) { if ([i].code === {[i].isCompleted = true; console.log([i].name + ' has been completed'); break; } } }; I hope I can find the bugs soon... otherwise I can't make a simple Role-Playing Game.
  4. I can't find the bugs in my code

    I didn't think of that. I'll try that, and if none of them have a bug, I'll post code for another .js file
  5. I can't find the bugs in my code

    Here's my game.js var RPG = RPG || {}; RPG.GameState = { init: function (currentLevel) { //keep track of the current level this.currentLevel = currentLevel || currentLevel === 'testroom1'; //constants this.PLAYER_SPEED = 90; //no gravity in a top-down game = 0; //keyboard cursors this.cursors =; }, create: function () { =; this.loadLevel(); }, update: function () { //player can't walk through walls, this.collisionLayer); //items collection, this.items, this.collect, null, this); //stop each time this.player.body.velocity.x = 0; this.player.body.velocity.y = 0; if (this.cursors.left.isDown || this.player.btnsPressed.left || this.player.btnsPressed.upleft || this.player.btnsPressed.downleft) { this.player.body.velocity.x = -this.PLAYER_SPEED; this.player.scale.setTo(1, 1); } if (this.cursors.right.isDown || this.player.btnsPressed.right || this.player.btnsPressed.upright || this.player.btnsPressed.downright) { this.player.body.velocity.x = this.PLAYER_SPEED; this.player.scale.setTo(-1, 1); } if (this.cursors.up.isDown || this.player.btnsPressed.up || this.player.btnsPressed.upright || this.player.btnsPressed.upleft) { this.player.body.velocity.y = -this.PLAYER_SPEED; } if (this.cursors.down.isDown || this.player.btnsPressed.down || this.player.btnsPressed.downright || this.player.btnsPressed.downleft) { this.player.body.velocity.y = this.PLAYER_SPEED; } //stop all movement if nothing is being pressed if ( {; } //play walking animation' if (this.player.body.velocity.x !== 0 || this.player.body.velocity.y !== 0) {'walk'); } else { this.player.animations.stop(); this.player.frame = 0; } }, loadLevel: function () { //create a tilemap object = this.add.tilemap(this.currentLevel); //join the tile images to the json data'terrains', 'tilesheet'); //create tile layers this.backgroundLayer ='backgroundLayer'); this.collisionLayer ='collisionLayer'); //send background to the back; //collision layer should be collisionLayer, 16, true, 'collisionLayer'); //resize the world to fit the layer this.collisionLayer.resizeWorld(); //create player var playerData = { //list of items items: [], //player stats health: 30, attack: 10, defense: 10, gold: 0, //quest quests: [ { name: 'find the map in Schnyders room ', code: 'robschneider', isCompleted: false }, { name: 'aquire the Sword of Destiny', code: 'destiny-sword', isCompleted: false }, { name: 'aquire the Staff of Gods', code: 'godsstaff', isCompleted: false } ] }; this.player = new RPG.Player(this, 100, 100, playerData); //add player to the world this.add.existing(this.player); //group of items this.items =; this.loadItems(); //enemies this.enemies =; //this.loadEnemies(); //this.enemy = new RPG.Enemy(this, 200, 60, 'monster', {attack: 10, health: 20, defense: 5}); //this.enemies.add(this.enemy); //follow player with the camera; this.initGUI(); }, gameOver: function () {'Game', true, false, this.currentLevel); }, initGUI: function() { //onscreen controls setup, { left: true, right: true, up: true, down: true, upleft: true, downleft: true, upright: true, downright: true, action: false }); this.showPlayerIcons(); }, collect: function(player, item) { this.player.collectItem(item); }, showPlayerIcons: function() { //gold icon this.goldIcon = this.add.sprite(10, 10, 'coin'); this.goldIcon.fixedToCamera = true; var style = {font: '14px Arial', fill: '#fff'}; this.goldLabel = this.add.text(30, 10, '0', style); this.goldLabel.fixedToCamera = true; //attack icon this.attackIcon = this.add.sprite(70, 10, 'sword'); this.attackIcon.fixedToCamera = true; var style = {font: '14px Arial', fill: '#fff'}; this.attackLabel = this.add.text(90, 10, '0', style); this.attackLabel.fixedToCamera = true; //defense icon this.defenseIcon = this.add.sprite(130, 10, 'shield'); this.defenseIcon.fixedToCamera = true; var style = {font: '14px Arial', fill: '#fff'}; this.defenseLabel = this.add.text(150, 10, '0', style); this.defenseLabel.fixedToCamera = true; this.refreshStats(); }, refreshStats: function() { this.goldLabel.text =; this.attackLabel.text =; this.defenseLabel.text =; }, findObjectsByType: function(targetType, tilemap, layer){ var result = []; tilemap.objects[layer].forEach(function (element) { if ( === targetType) { element.y -= tilemap.tileHeight / 2; element.x += tilemap.tileHeight / 2; result.push(element); } }, this); return result; }, loadItems: function () { var elementsArr = this.findObjectsByType('item',, 'objectsLayer'); var elementObj; elementsArr.forEach(function (element) { elementObj = new RPG.Item(this, element.x, element.y,,; this.items.add(elementObj); }, this); } }; Thing is, I don't know if this is the one filled with bugs.
  6. I can't find the bugs in my code

    I have a problem: I'm making an RPG and it's not working. I just keep getting a green bar on a white screen. I have multiple .js files, and I can't figure out which file might be it.
  7. HTML5 JS Quiz help

    It worked! but only on result pages 1 and 2. --EDIT-- I just made some minor adjustments. That fixed it! I got it working! Thanks for the help.
  8. HTML5 JS Quiz help

    Ok. got it. I was just about to test that.
  9. HTML5 JS Quiz help

    They are 'q1' through to 'q11'. I still need to get it to send people to a different page when the submit button is pressed. --EDIT-- I just realized that I probably should do that. --EDIT-- Just fixed it so it did sum up all 11.
  10. HTML5 JS Quiz help

    I just of rid of the error! All I did was change the value of i in for (i = 0; i <NUM_QUESTIONS; ++i) from 0 to 1.
  11. HTML5 JS Quiz help

    I want to sum up the values of all 11 questions in my quiz.
  12. HTML5 JS Quiz help

    It's the var value = document.querySelector('input[name = "q' + i +'"]:checked').value; that's giving me the problem, and I just don't understand why it's not working properly.
  13. HTML5 JS Quiz help

    Okay. i think I'm starting to get frustrated. I've only got until Tuesday to finish this and I just can't get it to work properly! No matter what I've tried, It just won't send me to a result page when I hit submit! P.S. - I tried in the HTML first. It kept saying it couldn't read the property 'value' of null.
  14. HTML5 JS Quiz help

    I just tried that, and It's giving me even more problems. Maybe I should just use it in the HTML.
  15. HTML5 JS Quiz help

    I just put the code into my .js, and i'm getting a message saying: Move 'var' declarations to the top of the function. for(var i = 0; i < NUM_QUESTIONS; ++i){ After that it just stops checking the rest of the code. Any idea why?