<commit_before>var PHY_SCALE = 10 // physics scale: 1m == 100px
var PLR_RADIUS = 20 / PHY_SCALE
var PLR_FORCE = 2
class Player {
    constructor(menu, image) {
        var shape = new Box2D.b2CircleShape();
        var fixdef = new Box2D.b2FixtureDef();
        shape.set_m_radius(PLR_RADIUS);
        fixdef.set_shape(shape);
        fixdef.set_restitution(0.3);
        var bd = new Box2D.b2BodyDef();
        bd.set_type(Box2D.b2_dynamicBody);
        var body = menu.world.CreateBody(bd);
        body.CreateFixture(fixdef);
        var temp = new Box2D.b2Vec2(0.0, 0.0);
        temp.Set(1300 / PHY_SCALE, -1085 / PHY_SCALE);
        body.SetTransform(temp, 0.0);
        body.SetLinearDamping(0.1);
        body.SetAwake(true);
        body.SetActive(true);
        this.body = body
        this.image = image
    }
    draw(dt, delta) {
        var pos = this.body.GetPosition()
        app.display.context.drawImage(this.image, PHY_SCALE * (pos.get_x() - PLR_RADIUS) * app.display.scale_ratio, -PHY_SCALE * app.display.scale_ratio * (pos.get_y() + PLR_RADIUS), this.image.width * app.display.scale_ratio, this.image.height * app.display.scale_ratio); // WARNING: y coordinates inverted
    }
}
class Game {
    constructor(display) {
        this.background = makeImage('img/level0.jpg')
        using(Box2D, "b2d.*")
        this.world = new Box2D.b2World(new Box2D.b2Vec2(0, 0))
        // define game area
        var ground = this.world.CreateBody(new Box2D.b2BodyDef())
        fixChain(ground, [950, 525, 2950, 525, 2950, 1650, 950, 1650])
        this.player = new Player(this, makeImage('img/p2.png'))
    }
    update(dt, delta) {
        let force = PLR_FORCE * delta
        if (app.keys.is_pressed('UP')) {
            this.player.body.ApplyLinearImpulse(this.player.body.GetWorldVector(new Box2D.b2Vec2(0, force)), this.player.body.GetPosition(), true);
        }
        if (app.keys.is_pressed('DOWN')) {
            this.player.body.ApplyLinearImpulse(this.player.body.GetWorldVector(new Box2D.b2Vec2(0, -force / 1.25)), this.player.body.GetPosition(), true);
        }
        if (app.keys.is_pressed('RIGHT')) {
            this.player.body.SetTransform(this.player.body.GetPosition(), this.player.body.GetAngle() - 0.75 * delta);
        }
        if (app.keys.is_pressed('LEFT')) {
            this.player.body.SetTransform(this.player.body.GetPosition(), this.player.body.GetAngle() + 0.75 * delta);
        }
        if (app.keys.is_new_press('ESC')) {
            app.push_menu(new MainMenu(app.display))
        }
    }
    draw(dt, delta) {
        app.display.scale_ratio = app.display.height / this.background.height
        var ref = app.display.height
        app.display.context.drawImage(this.background, 0, 0, ref * 1.7777, ref) // FIXME: fixed ratio for image size
        this.world.Step(delta, 3, 3);
        this.player.draw(dt, delta)
    }
}<commit_msg>add enemies in board<commit_after>var PHY_SCALE = 10 // physics scale: 1m == 100px
var PLR_RADIUS = 20 / PHY_SCALE
var PLR_FORCE = 2
class Player {
    constructor(menu, image) {
        var shape = new Box2D.b2CircleShape();
        var fixdef = new Box2D.b2FixtureDef();
        shape.set_m_radius(PLR_RADIUS);
        fixdef.set_shape(shape);
        fixdef.set_restitution(0.3);
        var bd = new Box2D.b2BodyDef();
        bd.set_type(Box2D.b2_dynamicBody);
        var body = menu.world.CreateBody(bd);
        body.CreateFixture(fixdef);
        var temp = new Box2D.b2Vec2(0.0, 0.0);
        temp.Set(1300 / PHY_SCALE, -1085 / PHY_SCALE);
        body.SetTransform(temp, 0.0);
        body.SetLinearDamping(0.1);
        body.SetAwake(true);
        body.SetActive(true);
        this.body = body
        this.image = image
    }
    draw(dt, delta) {
        var pos = this.body.GetPosition()
        app.display.context.drawImage(this.image, PHY_SCALE * (pos.get_x() - PLR_RADIUS) * app.display.scale_ratio, -PHY_SCALE * app.display.scale_ratio * (pos.get_y() + PLR_RADIUS), this.image.width * app.display.scale_ratio, this.image.height * app.display.scale_ratio); // WARNING: y coordinates inverted
    }
}
class Game {
    constructor(display) {
        this.background = makeImage('img/level0.jpg')
        using(Box2D, "b2d.*")
        this.world = new Box2D.b2World(new Box2D.b2Vec2(0, 0))
        // define game area
        var ground = this.world.CreateBody(new Box2D.b2BodyDef())
        fixChain(ground, [950, 525, 2950, 525, 2950, 1650, 950, 1650])
        this.player = new Player(this, makeImage('img/p2.png'))
        this.enemies = []

        for (var i = 0; i < app.config.DUDES; i++) {
          alert()
          this.enemies.push(new Player(this, makeImage('img/p2.png')))
        }
    }
    update(dt, delta) {
        let force = PLR_FORCE * delta
        if (app.keys.is_pressed('UP')) {
            this.player.body.ApplyLinearImpulse(this.player.body.GetWorldVector(new Box2D.b2Vec2(0, force)), this.player.body.GetPosition(), true);
        }
        if (app.keys.is_pressed('DOWN')) {
            this.player.body.ApplyLinearImpulse(this.player.body.GetWorldVector(new Box2D.b2Vec2(0, -force / 1.25)), this.player.body.GetPosition(), true);
        }
        if (app.keys.is_pressed('RIGHT')) {
            this.player.body.SetTransform(this.player.body.GetPosition(), this.player.body.GetAngle() - 0.75 * delta);
        }
        if (app.keys.is_pressed('LEFT')) {
            this.player.body.SetTransform(this.player.body.GetPosition(), this.player.body.GetAngle() + 0.75 * delta);
        }
        if (app.keys.is_new_press('ESC')) {
            app.push_menu(new MainMenu(app.display))
        }
    }
    draw(dt, delta) {
        app.display.scale_ratio = app.display.height / this.background.height
        var ref = app.display.height
        app.display.context.drawImage(this.background, 0, 0, ref * 1.7777, ref) // FIXME: fixed ratio for image size
        this.world.Step(delta, 3, 3);
        this.player.draw(dt, delta)
        this.enemies.map(dude => dude.draw(dt, delta))
    }
}
{'fraction_non_alphanumeric': 0.14323563503891373, 'fraction_numerical': 0.03510514985924822, 'mean_word_length': 2.5014492753623188, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '716502', 'n_tokens_mistral': 2219, 'n_tokens_neox': 2096, 'n_words': 362}