Search the Community

Showing results for tags 'bullet'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 14 results

  1. Platformer collision problem

    Hi guys! I'm new to Phaser, with basic knowledge of JS. I have a problem with my platform game, which I've started with this tutorial. https://phaser.io/news/2015/09/platformer-tutorial-part2 The code is different from every tutorial I've seen on Phaser main webpage, so It's hard for me to get in to. (no update, create, preload function in main is the beggining of all my problems)... I wanted to add a shooting system, which I learned from this: https://phaser.io/examples/v2/arcade-physics/group-vs-group I applied this code to the platformer engine, and I am not sure if I did it correctly. I have created shooting system in Player object, because I didn't know how to do it other way. This code look like this: //In player: Platformer.Player = function (game_state, position, properties) { "use strict"; Platformer.Prefab.call(this, game_state, position, properties); (...) //bullets bullets = game.add.group(); bullets.enableBody = true; bullets.physicsBodyType = Phaser.Physics.ARCADE; bullets.callAll('events.onOutOfBounds.add', 'events.onOutOfBounds', resetBullet, this); bullets.setAll('checkWorldBounds', true); bullets.createMultiple(100, 'pocisk'); function resetBullet (bullet) { bullet.kill(); } //In player.prototype.update : Platformer.Player.prototype = Object.create(Platformer.Prefab.prototype); Platformer.Player.prototype.constructor = Platformer.Player; Platformer.Player.prototype.update = function () { "use strict"; this.game_state.game.physics.arcade.collide(this, this.game_state.layers.collision); this.game_state.game.physics.arcade.overlap(this, this.game_state.groups.enemies, this.hit_enemy, null, this); (...) //bullets if (this.spaceKey.isDown) { this.fireBullet(); } this.fireBullet = function() { if (game.time.now > bulletTime) { bullet = bullets.getFirstExists(false); if (bullet) { this.game_state.game.physics.arcade.overlap(bullet, Platformer.Enemy, this.zderzenie, null, this); bullet.reset(this.body.x + 6, this.body.y - 8); bullet.body.allowGravity = false; if (this.profil==1) //direction of shooting bullet.body.velocity.x = 300; else bullet.body.velocity.x = -300; if(bullet.body.x==Platformer.Enemy.x && bullet.body.y==Platformer.Enemy.y) bullet.kill(); bulletTime = game.time.now + 250; } } } And it works, the player is shooting circles in left or right direction. The problem starts now. I need to somehow code the collision between the bullet and the enemy. As you can see above, I wrote thing like this : if(bullet.body.x==Platformer.Enemy.x && bullet.body.y==Platformer.Enemy.y) bullet.kill(); But this don't work. What can I do? It is the problem with seperate objects? Or maybe I know nothing and made serious stupid mistakes?
  2. Phaser JS Weapon plugin

    Hello! I'm having a hell of a time trying figure out how to change Phaser Weapon plugins bullet speed after it's been shot. I also set "weapon.bulletSpeed" negative value, because by default it was going in opposite direction. I attached weapon to a spaceship sprite, but on "weapon.fire()" bullet goes backwards. Weapon definition. addWeapon: function(target) { var weapon; var weapon; weapon = game.add.weapon(100, 'bullet'); weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; weapon.bulletAngleOffset = 90; weapon.bulletSpeed = 5; weapon.trackSprite(target, (this.ship.height), 0); weapon.trackRotation = true; weapon.fireRate = 200; weapon.bulletRotateToVelocity = false; weapon.onFire.add(function() {this.blastSound.play()},this); return weapon; } this.ship = this.add.sprite(this.world.centerX, this.world.centerY +300, 'ship'); this.ship.anchor.setTo(0.5, 0.5); this.ship.scale.setTo(0.22); this.ship.angle = -90; game.physics.arcade.enable(this.ship); this.ship.body.drag.set(70); this.ship.body.maxVelocity.set(220); this.weapon = this.addWeapon(this.ship); I am trying to set the direction of the bullet to opposite, so I don't have to set bulletSpeed to negative value. change every bullets anchor. change the speed of particular bullet after it's been shot. It would be grate to hear any suggestion. Тhank you in advance.
  3. Shmups & Shmupjam

    Hey All, We are a little late posting to this forum and I hope this is an appropriate section to place our post in. We have a Shoot-em-up Game Jam (of sorts) running all the way through 2015, in monthly installments, called.. #ShmupJam. So the basic idea is anyone with the skills to make a shmup, or a first time game in this genre, can participate in the monthly jam. Each month the era moves forwards in time. **updated 7th May 2015** We’ve added compilation images for waves 1-4! Wave 05 is ACTIVE! - http://jams.gamejolt.io/shmupjam05/ Wave 04 Games – http://jams.gamejolt.io/shmupjam04/games Wave 03 Games – http://jams.gamejolt.io/shmupjam03/games Wave 02 Games – http://jams.gamejolt.io/shmupjam02/games Wave 01 Games – http://jams.gamejolt.io/Shmuproom01/games The rules are fairly open.. it's not really a competition, just for fun. The theory was that starting with some of the earliest games would ease us (in terms of technical demands) into the Jam, and each month we would have more and more of a framework and some experience to work with. Create something retro looking, modernize a classic.. perhaps simplicity could be the key to getting in a quick submission. You don't have to submit a full game, prototypes, visualizations or simple tech demo's are perfectly acceptable. Each jam runs for a whole month, and if you miss the deadline you could still get away submitting it to the next one. You might also check out our Shmup community over on deviant art the Shmuproom, which has all kinds of inspiration on it too. So.. if you are interested, please feel free to join in. You can leave comments on this thread (let us know which framework you using) or if you can get your games onto GameJolt even better. Thanks all, -kb
  4. Hey everyone! So I'm pretty new to Phaser and I'm having a hard time making the player's bullets stop at a certain point (e.g killing the projectile at around 30px after its original position, etc). I want the player to have a limited projectile range and I'm just wondering how you can implement that because all my attempts of trying to figure it out have failed so far, so I'm seeking help from you guys... Thanks for any advise!
  5. Weapon plugin bullet wrong angle

    I´m having a problem with the weapon plugin. When I use the function weapon.fire() it fires a bullet 90 degrees from the canon sprite (the one the weapon plugin is tracking). Any idea what I am doing Wrong? Thnxs!
  6. Update - the game is now available on Google Play as a native app: https://play.google.com/store/apps/details?id=com.afgt.naval The link http://www.askforgametask.com/mobile/games/naval/ Description Naval Battle is an HTML5 arcade game in which your mission is to destroy a fleet of enemy cargo ships before they deliver ammunition and provisions to the enemy troops. You are the commander of the VIC Victory, a fast light tank used by the Mobile Costal Artillery in defending a country against sea attacks. Your tank is armed with a limitless supply of anti-ship shells, but be aware that only one shell can be in view at a time! You have only 70 seconds to sink all enemy ships. They are not armed, but they are protected by the gun fire from a fortified enemy battery on the other side of the bay. And they are moving with different speeds. So you need to aim very carefully! The game ends if you fail to complete the mission within the 70-second time limit or if your tank is destroyed by enemy gun fire. Controls Use the left and right keys to move. Use the up or space key to fire. Screenshots
  7. After some research on Internet how to make bullet hell game with Phaser, no good tutorial found, so I decided to use 3rd framework, then I found bulletml.js, so I give it a try, running 3rd demo, work great. (3rd one is orginal, no dependency, also, bunch of Japanese in comment and on github page, maybe I should learn it...). So I tried to modify it without Phaser, work great too. After saw what it can do, I tried to make it work with Phaser, little hard for me to understand demo's code (I'm still a beginner). So I tried, got error: Uncaught TypeError: this.onTextureUpdate is not a function and a bunch of warning. Anybody know why or it is impossible to do, or maybe suggestion on tutorial? (Also, Rich, can you consider use bulletml.js into Phaser.Weapon or Phaser.Bullet or Phaser.Particle or else? ) (Sorry for bad english )
  8. Fire bullet to predefined angle

    Hi Guys, So I'm flying a space ship using the accelerometer and gyro.js, with gyro.js I calculate the angle the ship is flying in. Now I want to fire a laser when I touch my mobile device's screen. The laser should fire in the direction the ship is flying in, no matter where the user touches the screen. I've searched for a couple of hours, but still didn't find a way to make this work. Any ideas? function fire(angle) { if(game.time.now > bulletTime) { bullet = bullets.getFirstExists(false); if(bullet) { bullet.reset(player.x, player.y + 8); bullet.rotation = this.game.physics.arcade.moveToObject(bullet, game.input.activePointer, 500); bulletTime = game.time.now + 200; } }}This is what I have got so far, and this works. But it doesn't fire in the direction the ship is flying in. ps. I've calculated the angle with the following code: var anglePlayer = Math.atan2(o.y * 20, o.x * 20);anglePlayer *= 180/Math.PI;anglePlayer = 180 - anglePlayer;player.angle = anglePlayer;
  9. Hello & Thanks , I am working on a javescript(only) game . I have the shooter(thrower) setup and moving via arrowKeys . And have initial setup for bullet(cowpie) . But I need help(example) setting cowpie up so that I can have multiple cowpies in play . var Cowpie = function () { var self = this; this.idTag = 'cowpie'; this.x = thrower.x; this.y = thrower.y; this.width= 64; this.height = 64; this.speedX = 0; this.speedY = 5; this.visible = true; this.directionY = -1; this.moveMe = false ; this.update = function() { self.y = self.y+ (self.speedY * self.directionY); // always -1 } self.moveMe = false ; } } // cowpie = new Cowpie(); cowpie.idTag ; // = 'cowpie'; cowpie.x ; // = 0; cowpie.y ; // = thrower.y; cowpie.width ; // = 64; cowpie.height ; // = 64; cowpie.speedX ; // = 0; cowpie.speedY ; // = -5; cowpie.visible ; // = true ; cowpie.directionY ; // = -1; cowpie.moveMe ; // = true ; . The running game is here: http://liesandcowpies.com/javascript/BenghaziGame-starter-05-Thrower-Cowpie.html The code shown below: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta charset="utf-8" /> <title>move pieThrower</title> <!-- file:///C:/javascript-Pure/otherObj/BenghaziGame-starter-05-Thrower-Cowpie.html --> <!-- http://liesandcowpies.com/javascript/ --> <style> canvas { border:1px solid #d3d3d3; background-color: #f1f1f1; } #assets { visibility: hidden; } </style> </head> <body onload="startGame()"> fromWhere= <span id="fromWhere">fromWhere</span><br> idTag= <span id="idTag">idTag</span><br> this.idTag= <span id="thisIdTag">this.idTag</span><br> this.visible= <span id="this.visible"> this.visible</span><br> this.tripsMax= <span id="this.tripsMax"> this.tripsMax</span><br> this.tripsCnt= <span id="this.tripsCnt"> this.tripsCnt</span><br> this.directionX= <span id="this.directionX"> this.directionX</span><br> this.x= <span id="this.x"> this.x</span><br> thrower x,y,w,h= <span id="thrower.xywh">thrower.x,y,w,h</span><br> <div align="center"> <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="width:70%";><p id="traceMsg">traceLog goes here:</p> </td> <td style="width:30%";> <canvas id="canvas" width="300" height="300"></canvas> </td> </tr> </tbody> </table> </div> <div id="assets"> <img id="truth01" src="sprites/truth01.png" width="64" height="64" /> <img id="truth02" src="sprites/truth02.png" width="64" height="64" /> <img id="lies01" src="sprites/lies01.png" width="64" height="64" /> <img id="lies02" src="sprites/lies02.png" width="64" height="64" /> <img id="cowpie" src="sprites/cowpie.png" width="32" height="32" /> <img id="thrower" src="sprites/thrower.png" width="64" height="64" /> <audio id="closeDoor" src="sounds/CloseDoor.ogg"></audio> </div> <script type='text/javascript'> // var oneTraceLine = ""; var traceYESorNO = false; var updateFor1stTime = 0; var fromWhere = "fromWhere"; var timesInTripsCk=0; var visible = true; var thisx=0; var tripsMax=0; priorTripsMax = 0; var thisIdTag; var holdThrower_x = 0; var idTag = "truth01"; var idTagTh = "thrower"; var tripsCnt=0; var directionX=1 ; var addit = 0; // canvas = document.getElementById("canvas"); // get the canvas ctx = canvas.getContext('2d'); // create canvas Context; var targetImgsCnt = 0; var idTag = "truth01"; var totalTrips = 0; var targetImgs = [document.getElementById("truth01"), document.getElementById("lies01"), //, document.getElementById("truth02"), document.getElementById("lies02"), document.getElementById("thrower"), document.getElementById("cowpie") ] ; // // function startGame() { var Cowpie = function () { var self = this; this.idTag = 'cowpie'; this.x = thrower.x; this.y = thrower.y; this.width= 64; this.height = 64; this.speedX = 0; this.speedY = 5; this.visible = true; this.directionY = -1; this.moveMe = false ; this.update = function() { self.y = self.y+ (self.speedY * self.directionY); // always -1 } self.moveMe = false ; } } // cowpie = new Cowpie(); cowpie.idTag ; // = 'cowpie'; cowpie.x ; // = 0; cowpie.y ; // = thrower.y; cowpie.width ; // = 64; cowpie.height ; // = 64; cowpie.speedX ; // = 0; cowpie.speedY ; // = -5; cowpie.visible ; // = true ; cowpie.directionY ; // = -1; cowpie.moveMe ; // = true ; // var Thrower = function () { var self = this; this.idTag = 'thrower'; this.x = (canvas.width / 2); this.y = canvas.height - 64; this.width= 64; this.height = 64; this.speedX = 1; this.speedY = 0; this.visible = true; this.directionX = 5; this.moveMe = false ; this.update = function() { self.x = self.x + (self.speedX * self.directionX); // always either +1 or -1 } self.moveMe = false ; } } // thrower = new Thrower(); thrower.idTag ; // = 'thrower'; thrower.x ; // = 0; thrower.y ; // = canvas.height - 64; thrower.width ; // = 64; thrower.height ; // = 64; thrower.speedX ; // = 1; thrower.speedY ; // = 0; thrower.visible ; // = true ; thrower.directionX ; // = 1; thrower.moveMe ; // = true ; // myGameArea.start(); } // function updateGameArea() { myGameArea.clear(); targetImgsCnt = 4; if(thrower.visible) { if(thrower.moveMe) {thrower.update();} ctx.drawImage(targetImgs[targetImgsCnt], thrower.x, thrower.y, thrower.width, thrower.height); /*120*/ document.getElementById("thrower.xywh").innerHTML = thrower.x; } } // var myGameArea = { start : function() { thrower.moveMe = false ; interval = setInterval(updateGameArea, 5); // updateGameArea(); }, clear : function() { ctx.clearRect(0, 0, canvas.width, canvas.height); }, stop : function() { clearInterval(this.interval); } } // document.addEventListener("keydown", keyDownHandler, false); document.addEventListener("keyup", keyUpHandler, false); document.addEventListener("mousemove", mouseMoveHandler, false); function keyDownHandler(e) { if(e.keyCode == 39 || event.keyCode == 68) { // rightPressed = true; // alert("keyDownHandler: rightPressed"); thrower.directionX = 7; thrower.moveMe = true; } else if(e.keyCode == 37 || event.keyCode == 65) { // leftPressed = true; // alert("keyDownHandler: leftPressed"); thrower.directionX = -7; thrower.moveMe = true; } } function keyUpHandler(e) { if(e.keyCode == 38 || event.keyCode == 87) { rightPressed = false; } else if(e.keyCode == 40 || event.keyCode == 83) { leftPressed = false; } } function mouseMoveHandler(e) { var relativeX = e.clientX - canvas.offsetLeft; // alert("function mouseMoveHandler(e)"); } // // file:///C:/javascript-Pure/otherObj/ // </script> </body> </html> Thanks
  10. bullets.body.velocity.

    Hello & Thanks : I am having trouble getting bullets to go : I get error :Uncaught TypeError: Cannot read property 'velocity' of undefined m-vertical-collision.js:124 Pls , what do I need to make this puppy go ? Thanks
  11. My character fires a bullet and how far it goes depends on what it hits or passes through. Box2D and other physics engines have useful callbacks for collision detection for moving objects, but this bullet would be rendered instantaneously so I figured raytracing would be the solution. How would I go about doing this?
  12. bullet switch sprite

    Hello, I want to switch sprite or frame when i fire. I use this for the moment but it's only working when i load the game. It's possible to switch sprite or frame in createMultiple(quantity, key, frame, exists) ? APP.bullets = game.add.group(); APP.bullets.createMultiple(10, random_card()); APP.bullets.setAll('anchor.x', 0.5); APP.bullets.setAll('anchor.y', 1); APP.bullets.enableBody = true; game.physics.enable(APP.bullets);function random_card() { var bullet var rand = Math.floor(Math.random() * 3 + 1); switch (rand) { case 1: bullet = "bullet1"; return bullet; break; case 2: bullet = "bullet2"; return bullet; break; case 3: bullet = "bullet3"; return bullet; break; case 1: bullet = "bullet4"; return bullet; break; default: return "error!"; }}
  13. Bullet and layer collision issue

    Hi, I have an issue on my fire function. When i keep spacebar pressed collision between the bullet and the layer doesn't working. You can test it http://s475613576.onlinehome.fr/portfolio/jeu/jeu/warped/index.html create() {// bullet group APP.bullets = game.add.group(); APP.bullets.createMultiple(10, 'bullet'); APP.bullets.setAll('anchor.x', 0.5); APP.bullets.setAll('anchor.y', 1);}update(){if (APP.fireButton.isDown) { fireBullet(); }game.physics.arcade.overlap(APP.bullet, APP.layer, function(bullet, layer) { bullet.kill(); }, null, this);}}function fireBullet() { if (game.time.now > APP.bulletTime) { //game.sound.play('fire'); APP.bulletTime = game.time.now + APP.bulletRate; // Grab the first bullet we can from the pool APP.bullet = APP.bullets.getFirstExists(false); if (APP.bullet) { APP.bullet.lifespan = 2000; //kill after 2000ms game.physics.enable(APP.bullet); if (APP.facing === "right") { // And fire it APP.bullet.reset(APP.player.x + 15, APP.player.y + 15); APP.bullet.body.velocity.x = APP.bulletvelocity; } else if (APP.facing === "left") { APP.bullet.reset(APP.player.x, APP.player.y + 15); APP.bullet.body.velocity.x = -APP.bulletvelocity; } } }}Thank you for you're help .
  14. Hello. I have seen several posts that talk about this topic. I do not understand what happens when the bullets hit platforms. Function when the collision occurs is not executed. This only happens when the bullet hits a group of platforms. This is my code create: this.bullets = this.game.add.group(); this.bullets.createMultiple(30, 'bullet'); this.bullets.forEach(utils.setupBullet, this); utils.setupBullet = function(bullet) { bullet.anchor.x = 0.5; bullet.anchor.y = 0.5; bullet.outOfBoundsKill = true; bullet.lifespan = 2300; bullet.body.setCircle(15); bullet.animations.add('default', [0, 1, 2, 1], 10, true); bullet.animations.play('default'); }; update: this.game.physics.overlap(this.bullets, this.layer, this.collisionBulletWall, null, this); collisionBulletWall: function(bullet, wall) { bullet.kill(); } any idea?