xwirespongex

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. Thanks for the tips. I was just wondering what the proper structure of a game is like with canvas and js...I have started the game over and this time I am using one file which initializes some the objects from other files, though each file has a looping function. Also, I find myself declaring a lot of variables and objects globally like this: "window.object"....is this bad practice?
  2. Hello, I have started developing with canvas and JS this week and have a few questions on the structure of a program..... When is it appropriate to create a new file that declares an object? so far I have been declaring my objects using the object literal method in a single file but its coming close to 300 lines and I am now wondering if I should start making new files for my objects. for example, I want to make a gun class which acts as a parent class for all gun types. I have made a new JS file and have added this: function Gun(){ this.x=0; this.y=0; this.image1=9; this.image2=10; this.width=36; this.height=32; this.pickedUp=false;}now, would it be more efficient to declare this using object literal in the other file? Or should I continue writing this one and make a loop function in this file that handles all the actions that I would normally put in the other (300 line) file?