Skip to content
Snippets Groups Projects
objects.js 631 B
Newer Older
  • Learn to ignore specific revisions
  • Bye's avatar
    Bye committed
    class Object {
        draw() {}
        step() {}
    }
    
    
    Bye's avatar
    Bye committed
    
    
    Bye's avatar
    Bye committed
    class Room extends Object {
    
    Bye's avatar
    Bye committed
        constructor(name="") {
    
    Bye's avatar
    Bye committed
            super();
            this.objects = [];
    
    Bye's avatar
    Bye committed
            this.name = name; // needs to be unique, otherwise the searching code will just use the first one it finds.
    
    Bye's avatar
    Bye committed
        }
    
    
    Bye's avatar
    Bye committed
        init(){}
    
    
    Bye's avatar
    Bye committed
        draw() {
            for (let i = 0; i < this.objects.length; i++) {
                this.objects[i].draw();
            }
        }
    
        drawGUI() {
    
        }
    
    
    Bye's avatar
    Bye committed
        keyDown(key) {
        }
    
        keyUp(key) {
        }
    
    
    
    
    Bye's avatar
    Bye committed
        step() {
            for (let i = 0; i < this.objects.length; i++) {
                this.objects[i].step();
            }
        }
    }
    
    
    
    export { Object, Room };