Skip to content
Snippets Groups Projects
Select Git revision
  • 757293a903855ea1123976f395d6c87f48a13a83
  • main default protected
2 results

player.js

Blame
  • player.js 735 B
    import {Entity} from "../../../hampsterengine/src/things";
    import {round, roundToRatio} from "../extras";
    
    export default class Player extends Entity {
        constructor(props) {
            super(props);
    
            this.jumping = false;
        }
    
        draw() {
            canvas.setFillColor('red');
            const timeSinceLastFrame = (performance.now() - engine.lastPhysicsFrame) / 1000 / (query.get('slowdown') ? 60 : 1);
            const interpolationX = this.vx * timeSinceLastFrame;
            const interpolationY = this.vy * timeSinceLastFrame;
            // const interpolationX = 0;
            // const interpolationY = 0;
            canvas.fillRect(roundToRatio(this.x+interpolationX),roundToRatio(this.y+interpolationY),this.width,this.height);
        }
    }