Jump to content

vmars316

Members
  • Content Count

    421
  • Joined

  • Last visited

Everything posted by vmars316

  1. Where should I put game.start() ? Thanks
  2. Probably But when I do it exactly like you said , no images and no sound . /***********/ /** Logic **/ /***********/ window.addEventListener("load", setup, false); // Listen for Browser ReFresh-Button function setup() { // Wrap the entire logic section in a function and set a window load event to call /* Initialize the game object */ var canvas = document.getElementById("canvas"); var game = new Game(canvas); // Sounds game.sounds.splat = new Audio("sounds/CowMooSplat.mp3"); game.sounds.goodbye = new Audio("sounds/GoodBye-Female.mp3"); game.sounds.cheering = new Audio("sounds/ch
  3. Hello & Thanks , Sorry to say , but now the cowpies won't launch . Any ideas ? Thanks
  4. Wow , Thank you very much for all your help , works great ! Understanding/learning from  Your version will keep me busy for a long time . Now I see what you meant by using as few Globals as possible : function Game(c) {  //  from statement 173  to  366   var self = this;     . I understand what you are saying  and I will review all my requirements above & add to as needed . Side note: none of the requirements you mentioned above are part of the original code I presented .   I had stripped down the code to use only 1 target ,
  5. <!DOCTYPE html> <html> -<head> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta charset="utf-8" /> <title>GameObject.html</title> http://vmars.us/javascript/GameObject.html --> <style> #assets { height: 0px; overflow: hidden; visibility: hidden; width: 0px; } body { background-color: Black; margin: 0; overflow: hidden; padding: 0; } canvas { cursor: none; } table { color: #E1E1E1; background-color: #732222; height: 24px; width: 800px; border: none; } button {font-size: 16px;} #b
  6. Ah , back at it ; Reminder.. Code works fine on desktop browser , but hangs on phone . Here is my more readable code : Thanks
  7. Thanks ; Yes , I fixed that . I still couldn't find all the errors , so I stripped out everything (js) except var Game = {} and Game.start = function() {} (then added Game.hitTest(a, {) However when I pruned code down to this: <script type='text/javascript'> /** Game object **/ var Game = {} // Movable objects Game.cowpies = []; /* Properties */ // For drawing Game.canvas = document.getElementById("canvas"); Game.context = Game.canvas.getContext("2d"); // Starts up the game Game.start = function() { } // Detect a rectangular collision between two
  8. <!DOCTYPE html> <html> -<head> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta charset="utf-8" /> <title>goBegin</title> http://vmars.us/javascript/GameObject.html --> </head> <!-- <body onload="Game.start()" > --> <body> <canvas id="canvas" width="600" height="450" style="background-color:#992D2D"></canvas> <script type='text/javascript'> /*****************/ /** Game object **/ /*****************/ /*****************/ /** Game object
  9. Ok, I have got it stripped down , and no errors:
  10. Oops , I misunderstood what you were saying . I fixed code & no error here .
  11. Pls notice that the code I last presented does include the changes you mentioned . I had already fixed the errors . I deliberately removed the "objects, their properties and methods" to make it easier to debug js syntax . Again , what I am trying to do now , is simply to debug the js syntax , I am trying to establish an error free 'starting point . So that any errors that pop up after this 'starting point' are indeed my errors . Yes I realize that . Isn't the diagram that you gave me , though incomplete , program structure ? Or do you mean something else ? Thanks
  12. Yes , I try it every time . Most often it doesn't work . I use Notepad++ . 1) copy the code i want to paste. 2) then click on the <> lable . 3) select html 4) paste in code 5) click save Code shows up as colored . Then I click 'save'. Code doesn't show up , just a small empty colored box . What am I doing wrong ? Thanks
  13. Hello & Thanks ; I am trying to get a clean compile on the Diagram , I am getting the following errors and I can't figure out what the prob is , Pls help . The Diagram code is at bottom . : Uncaught SyntaxError: Unexpected token { // Detect a rectangular collision between two objects Game.hitTest(a, { return a.x <= b.x + b.width && a.x + a.width >= b.x && a.y <= b.y + b.height && a.y + a.height >= b.y; } : Uncaught SyntaxError: Unexpected token { // Create or destroy cowpies Game.createCowpie =
  14. Thanks , I am getting an "GameObject-Copy.html:163 Uncaught SyntaxError: Unexpected token {" on this: Game.hitTest(a, b { return a.x <= b.x + b.width && a.x + a.width >= b.x && a.y <= b.y + b.height && a.y + a.height >= b.y; } This syntax is new to me , is return supposed to return 'true or false' ? Thanks
  15. <!DOCTYPE html> <html> -<head> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta charset="utf-8" /> <title>Debug Hillary Only</title> http://vmars.us/javascript/GameObject.html --> <style> #assets { height: 0px; overflow: hidden; visibility: hidden; width: 0px; } body { background-color: Black; margin: 0; overflow: hidden; padding: 0; } canvas { cursor: none; } table { color: #E1E1E1; background-color: #732222; height: 24px; width: 600px; border: none; } #buttonsArea { color: #
  16. Thanks This is working ok . . I forgot I needed to reference id="buttonsArea" as #buttonsArea . Thanks
  17. Still trouble with <> code , try this : <!DOCTYPE html> <html> -<head> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta charset="utf-8" /> <title>Debug Hillary Only</title> http://vmars.us/javascript/GameObject.html --> <style> #assets { height: 0px; overflow: hidden; visibility: hidden; width: 0px; } body { background-color: Black; margin: 0; overflow: hidden; padding: 0; } canvas { cursor: none; } table { color: #E1E1E1; background-color: #992D2D; height: 24px; width: 800px; bor
  18. Hmm.. THis sort of worked . <!DOCTYPE html> <html> -<head> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta charset="utf-8" /> <title>Debug Hillary Only</title> <!-- --> <style> #assets { height: 0px; overflow: hidden; visibility: hidden; width: 0px; } body { background-color: Black; margin: 0; overflow: hidden; padding: 0; } canvas { cursor: none; } table, th, tr, td { color: #E1E1E1; background-color: #732222; height: 24px; width: 600px; border: none; text-align: cen
  19. Hello & Thanks ; <!DOCTYPE html> <html> -<head> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <meta charset="utf-8" /> <title>Debug Hillary Only</title> <!-- --> <style> #assets { height: 0px; overflow: hidden; visibility: hidden; width: 0px; } body { background-color: Black; margin: 0; overflow: hidden; padding: 0; } canvas { cursor: none; } table { color: #E1E1E1; background-color: #732222; height: 24px; width: 600px; border: none; } button {font-size: 16px;} </sty
  20. id.tag : to identify which Target has focus . directionX & Y : to identify which direction Target is moving . Pls, what is your rational for this ?
×
×
  • Create New...