frankdev

Members
  • Content Count

    23
  • Joined

  • Last visited

  1. Hey all, As I develop my games in html5, I often notice that browser games feel different than downloadable games. This is simply because of the nature of web browsers; they are not specifically meant to showcase games. Because of this, I often find even myself clicking on other tabs as I play my game; kinda going in and out of the gaming experience. I don't really want my game to be displayed in a normal browser window for these reasons. Is there any way that I can make my game downloadable and have a file that opens a window which only contains the canvas? Thanks!
  2. Yeah that is what I meant. Thanks for the tip. I will look into texture atlases!
  3. Hello All, Sorry if this is a duplicate post; I thought this would be a fairly popular topic but I have yet to find my answer. I was wondering if it is possible to easily change the frame width of a spritesheet. When I preload the spritesheet: this.game.load.spritesheet(ResKeys.playerSprite, 'assets/playersprites.png', 30, 30);I pass in 30 as the width. For one of my animations, however, I want the width to be 60. Thanks!
  4. Wow thanks! Any way to do this with tile maps?
  5. Hello all, I think the title pretty much sums up what I want to ask. Is it possible to have sprites that don't collide as if they were rectangles, but rather as the shape they actually are. I am fairly certain that this cannot be achieved as easily as I hope and I wonder if it is possible at all. Thanks
  6. Hello all, I was wondering if there was a way to make sure an animation plays until completion. In my code, I start one animation when a certain condition is met. I want the animation to play to completion even though the condition isn't met throughout. Is this possible using built in Phaser methods? Thanks!
  7. Hi all, Is there any way to set up a Phaser environment in a free ide so that the ide gives method parameters and descriptions? -Thanks
  8. Yeah. I think recycling is the only option; since every object is identical splicing it erases the whole array. Thanks!
  9. Quetzacotl, I am looping through a for loop...it is an array of bullets. Could that be the problem, that I am still using those objects after they were deleted?
  10. How would one go about destroying a specific entity in an array? I have tried destroy, I have tried setting the object equal to null, but nothing has helped. After about 400 enemy ships spawn the game just lags. Any advice?
  11. I am not... I have it "up" here: lionela.site90.com -- for some reason the background music won't work. Thanks for the feedback!
  12. Yesterday I coded up this space invaders like game. I am a beginner and I didn't follow any tutorials so I was just wondering if there was anything really bad -- something I shouldn't do or have in my code. Thanks. window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(/* function */ callback, /* DOMElement */ element){ window.setTimeout(callback, 1000 / 60); }; })(); var canvas = document.getElementById("myCanvas"), ctx = canvas.getContext("2d"), bullets = [], keyCode = "", enemies = [], enemyShip, bulletCount, paused = false;//BACKGROUNDvar bg = new Image();bg.src = "BG.jpg";//PLAYERvar playerShip = new Image();playerShip.src = "playerShip.png";//ENEMY//MUSIC AND SOUNDSvar shootSound = document.getElementById("shoot");var BGMusic = document.getElementById("bg");var Player = { x: 250, y: 450, width: 56, height: 35, speed: 4, left: false, right: false, space: false, state: "alive", score: 0};function update(){if(paused != true) { requestAnimFrame(update); } render(); move(); dead(); BGMusic.play();}function move(){ document.onkeydown = function(e){ keyCode = e.keyCode; if(keyCode == 37){ Player.left = true; e.preventDefault(); } if(keyCode == 39){ Player.right = true; e.preventDefault(); } if(keyCode == 32){ Player.space = true; bulletCount = 0; e.preventDefault(); } if(keyCode == 27){ paused == true; } } document.onkeyup = function(e){ keyCode = e.keyCode; if(keyCode == 37){ Player.left = false; } if(keyCode == 39){ Player.right = false; } if(keyCode == 32){ Player.space = false; } } if(Player.left == true){ Player.x -= Player.speed; } if(Player.right == true){ Player.x+= Player.speed; } if(Player.space == true){ if(bulletCount < 20){ playerShoot(); bulletCount++; shootSound.play(); } } }function dead(){ count = 0; for(var i = 0; i < bullets.length; i++){ for(var j = 0; j < enemies.length; j++){ if(collide(bullets[i], enemies[j])){ enemies[j].image = "explosion.png"; enemy = enemies[j]; destroy(enemies[j]); if(count < 1){ Player.score++; count++; } } } } for(var t = 0; t < enemies.length; t++){ if(collide(enemies[t], Player)){ enemies = []; Player = {}; bullets = []; ctx.fillStyle = "yellow"; ctx.fillText("Hello World!",10,50); } }}function render(){ctx.clearRect(0,0,canvas.width, canvas.height);ctx.drawImage(bg, 0, 0);ctx.drawImage(playerShip, Player.x, Player.y, Player.width, Player.height); for(var j = 0; j < enemies.length; j++){ enemy = enemies[j]; enemyShip = new Image(); enemyShip.src = enemy.image; if(enemy.state != "dead"){ enemy.y += enemy.speed; ctx.drawImage(enemyShip, enemy.x, enemy.y, enemy.width, enemy.height); if(enemy.y > canvas.height){ delete enemy; } } } for(var i = 0; i < bullets.length; i++){ bullet = bullets[i]; ctx.fillStyle = "yellow"; ctx.fillRect(bullet.x, bullet.y, bullet.width, bullet.height); bullet.vy += bullet.acceleration; bullet.y -= bullet.vy; if(bullet.y < 0){ bullets.length -- ; delete bullet; } } ctx.fillText(Player.score, 300, 20);}function playerShoot(){ bullets.push({ x: Player.x + (1/2 * Player.width), y: Player.y - (1/2 * Player.height), vy: 1, acceleration: 0.1, width: 2, height: 2 });}function enemySpawn(){ enemies.push({ x: Math.random() * canvas.width, y: 20, speed: 1.5, width: 64, height: 64, state: "alive", image: "enemy.gif"});}function collide(a, { if((a.x > b.x && (a.x < b.x + b.width)) && (a.y > b.y && (a.y < b.y+ b.height))){ return true; }else{ return false; }}function destroy(entity){ setTimeout(function(){entity.state = "dead";}, 500); }setInterval(enemySpawn, 500);update();
  13. In my code, below, I have a bouncing circle animation. I would like to make an array called circles and push back new circles when needed. I want every circle in the array to be represented by the variable circle, but have separate x and y values. Any ideas as to how I could do this ? window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(/* function */ callback, /* DOMElement */ element){ window.setTimeout(callback, 1000 / 60); }; })(); // example code from mr doob : http://mrdoob.com/lab/javascript/requestanimationframe/var canvas = document.getElementById("myCanvas"), c = canvas.getContext("2d"), time = 0, gravity = 0.1, dampening = 0.99, pullStrength = 0.01;var circle = { x: 50, y: 50, //(VX, VY) = Velocity Vector vx: 0, vy: 0, radius: 20};function update(){ requestAnimFrame(update); render();}function render (){ //c.clearRect(0, 0,canvas.width, canvas.height); c.fillStyle = 'rgba(255, 255, 255, 0.05)'; c.fillRect(0, 0, canvas.width, canvas.height); //Increment location by Velocity circle.x += circle.vx; circle.y += circle.vy; //Increment gravity over time -- Acceleration circle.vy+= gravity; //Slow it down circle.vy *= dampening; circle.vx *= dampening; //Bouncing //bottom if(circle.y + circle.radius > canvas.height){ circle.vy = -Math.abs(circle.vy); } //top if(circle.y - circle.radius < 0){ circle.vy = Math.abs(circle.vy); } //right if(circle.x + circle.radius > canvas.width){ circle.vx = -Math.abs(circle.vx); } //left if(circle.x - circle.radius < 0){ circle.vx = Math.abs(circle.vx); } c.fillStyle = 'black'; c.beginPath(); c.arc(circle.x,circle.y,circle.radius, 0 , 2* Math.PI); c.closePath(); c.fill();} canvas.addEventListener('mousedown', function(e){ var mouseX = (e.pageX||e.clientX||e.offsetX) - canvas.offsetLeft, mouseY = (e.pageY||e.clientY||e.offsetY) - canvas.offsetTop; var dx = mouseX - circle.x, dy = mouseY - circle.y; circle.vx += dx * pullStrength; circle.vy += dy * pullStrength;});update();
  14. Just was fooling around with a little bit of a pvp "shooter" and I couldn't really think of a good bullet function. Right now, you fire, and once the bullet leaves the screen, you can fire again. I would prefer a rapid firing system where you hold down the key and it fires over and over. I am a beginner and I have ordered some of those books The game is here: www.lionela.site90.com Controls: WASD and Q fire and Arrow Keys and Space fire