vmars316

Members
  • Content Count

    97
  • Joined

  • Last visited

  • Days Won

    1

vmars316 last won the day on January 30 2016

vmars316 had the most liked content!

About vmars316

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

1270 profile views
  1. Hello & Thanks , A javascript Tutorial for BenghaziGame : I just wanted to let you know that I have written a javascript tutorial for my BenghaziGame , and to thank all you folks on this Forum who have helped me to convert this game to javascript . Benghazi Game is a shoot 'em up political satire browser game . But instead of bullets , we throw cowpies at politicians when we see them lying . How do we know when they are lying ? When their noses turn into long carrot noses , they are lying . The Tutorial game begins here : http://liesandcowpies.com/javascript/BenghaziGame.00-TUTORIAL.html I have also posted the whole Tutorial for download here : http://liesandcowpies.com/javascript/BenghaziGame-TUTORIALS.zip Hope this is helpful
  2. Matt , What's the differences between these two ? : var Bullet = function( x, y ) { this.name = 'bullet' this.x = x this.y = y this.update = function( dt ) { this.x += dt this.y += dt } } Bullet.prototype.update = function( dt ) { this.x += dt this.y += dt } I haven't used prototype before . Thanks
  3. Matt , How true ! I'll work with this a while . Thank you very much !
  4. Thanks , but what I need is an example of how to set up the Object definitions , object , constructor , prototype , etc.. I only know how to set up Object & new object .
  5. 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
  6. Thanks matt , The actual code in http://phaser.io/sandbox/obNsxTrv/play does have an active link : http://liesandcowpies.com/testMe/vm-phaser/vm-play-music-WEB.html I am confused , why does http://phaser.io/sandbox/obNsxTrv/ or http://phaser.io/sandbox/obNsxTrv/play show empty . What happened to the code ? Thanks
  7. Hello & Thanks , Code below runs great in Brackets but not online : http://liesandcowpies.com/testMe/vm-phaser/vm-play-music-WEB.html no errors in Chrome . & not on : http://phaser.io/sandbox/obNsxTrv or http://phaser.io/sandbox/obNsxTrv/play Anyone know why ? Thanks . var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'vm-play-music', { preload: preload, create: create, update: update}); // http://liesandcowpies.com/testMe/vm-phaser/vm-play-cowMoo-WEB.html var s; var cowMoo; var onceThru =1; function preload() { // game.load.baseURL = 'http://liesandcowpies.com/testMe/vm-phaser/'; // game.load.crossOrigin = 'anonymous'; game.load.audio('cowmoo', 'CowMoo.mp3'); } function create() { cowMoo = game.sound.add('cowmoo', .5,'false'); cowMoo.play(); } function update() { if (onceThru == 1) { alert('function update() ' + onceThru); collisionLies02(); onceThru = onceThru + 1 ; } } function collisionLies02() { onceThru = onceThru + 1; alert('function collisionLies02() , onceThru = ' + onceThru); // cowMoo = game.sound.add('cowmoo', .5,'false'); cowMoo.play(); } var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'vm-play-music', { preload: preload, create: create, update: update}); // http://liesandcowpies.com/testMe/vm-phaser/vm-play-cowMoo-WEB.html var s; var cowMoo; var onceThru =1; function preload() { // game.load.baseURL = 'http://liesandcowpies.com/testMe/vm-phaser/'; // game.load.crossOrigin = 'anonymous'; game.load.audio('cowmoo', 'CowMoo.mp3'); } function create() { cowMoo = game.sound.add('cowmoo', .5,'false'); cowMoo.play(); } function update() { if (onceThru == 1) { alert('function update() ' + onceThru); collisionLies02(); onceThru = onceThru + 1 ; } } function collisionLies02() { onceThru = onceThru + 1; alert('function collisionLies02() , onceThru = ' + onceThru); // cowMoo = game.sound.add('cowmoo', .5,'false'); cowMoo.play(); }
  8. Please delete this Post . Thanks
  9. Please delete this Post , I have broken it down into a couple smaller Posts . Thanks
  10. game.add.audio vs game.sound.add I notice that the tutorial : http://thoughts.amphibian.com/2015/11/hit-ground-play-sound.html uses game.sound.add where as the phaser/examples use game.add.audio . Any pros/cons ? Thanks
  11. Guess I'll answer my own Post: I just found out about the improved Phaser Docs here: http://phaser.io/learn/chains Great stuff ! Thanks Arian Fornaris (@boniatillo_com)
  12. https://jsfiddle.net/vmars316/8yttu1cy/1/ jsfiddle seems to do nothing . and http://liesandcowpies.com/testMe/vm-phaser/vm-play-music-WEB.html
  13. Thanks , I decided to reWrite code from 'play music.js' example to be sure I had it right . It works , except the sound keeps on playing . Sounds like it is stuck on static reverb . I specified loop = 'false' . Any ideas why it does that ? It runs fine here: http://liesandcowpies.com/testMe/vm-phaser/vm-play-music-WEB.html I also tried to run it here: http://phaser.io/sandbox/edit/wojtlUJC but just get a black screen .
  14. Hello & Thanks , I can't seem to play an *.mp3 file . XMLHttpRequest cannot load file:///C:/Phaser/vm-WIP/CowMoo.mp3. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. Pls, what am I doing wrong ? Thanks
  15. Yes , http://phaser.io/docs/2.4.4/index is a great resource . The prob for a noob though is not knowing what word to look for . I finally got there by thinking : Lets see now , if .kill() operates on a sprite . Probably the opposite of kill will be a sprite method also . A look thru sprite methods , a promising one is 'reset' . So I used that . Which works fine . When would I use revive ? Thanks