Skip to content
Snippets Groups Projects
Select Git revision
  • 420c5ab273467e443e4f863cf9c016593fcc1303
  • master default protected
2 results

objects.js

Blame
  • objects.js 766 B
    class GameObject {
        draw() {}
        step() {}
    }
    
    
    class Room extends GameObject {
        constructor(name="") {
            super();
            this.objects = [];
            this.name = name; // needs to be unique, otherwise the searching code will just use the first one it finds.
            this.background = "#000000";
        }
    
        init(){}
    
        draw() {
            for (const item of this.objects) {
                item.draw();
            }
        }
    
        drawGUI() {
    
        }
    
        keyDown(key) {
            for (const item of this.objects) {
                item.keyDown(key);
            }
        }
    
        keyUp(key) {
        }
    
        onclick(pos){
    
        }
    
    
    
        step() {
            for (let i = 0; i < this.objects.length; i++) {
                this.objects[i].step();
            }
        }
    }
    
    
    
    export { GameObject, Room };