<commit_before>
import GameMode from './_gamemode';
import config from '../config';
import gamestate from '../gamestate';
import {shakeUpdate} from '../ScreenShake.js'
import * as Cars from '../Cars.js';

import _ from 'lodash';

let lastTime = 0;

export default class Valet {
  static loop(now) {
    const delta = now - lastTime;
    lastTime = now

    // Only update the topmost (last) (currently "active") menu layer
    if (gamestate.menus.length > 0) {
      gamestate.menus[gamestate.menus.length - 1].update(now, delta)
    }

    shakeUpdate()

    //TODO: Have a gameloop function. Maybe have a seperate one for each gametype
    if (gamestate.playing) {
      // TODO: do initialization better somehow?
      if (!gamestate.player) {
        var car = _.sample(Cars);
        let spawn = _.sample(gamestate.level.spawnPoints);

        gamestate.player =  new car(spawn);
      }
      gamestate.player.update();

      if (p2.vec2.length(gamestate.player.chassisBody.velocity) <= 0.05) {
        gamestate.player.chassisBody.backWheel.setBrakeForce(2);
        gamestate.player.boxShape.collisionGroup = config.CAR;
        gamestate.cars.push(gamestate.player);
        var car = _.sample(Cars);
        let spawn = _.sample(gamestate.level.spawnPoints);
        gamestate.player =  new car(spawn);
      }

      for (let i = gamestate.cars.length - 1; i >= 0; i--) {
        gamestate.cars[i].update()
      }
    }

    requestAnimationFrame(Valet.loop);<commit_msg>nit(js): now conforms to eslint rules<commit_after>import GameMode from './_gamemode';
import config from '../config';
import gamestate from '../gamestate';
import { shakeUpdate } from '../ScreenShake.js'
import * as Cars from '../Cars.js';

import _ from 'lodash';

let lastTime = 0;

export default class Valet extends GameMode {
  static loop(now) {
    const delta = now - lastTime;
    lastTime = now

    // Only update the topmost (last) (currently "active") menu layer
    if (gamestate.menus.length > 0) {
      gamestate.menus[gamestate.menus.length - 1].update(now, delta)
    }

    shakeUpdate()

    // TODO: Have a gameloop function. Maybe have a seperate one for each gametype
    if (gamestate.playing) {
      // TODO: do initialization better somehow?
      if (!gamestate.player) {
        const car = _.sample(Cars);
        const spawn = _.sample(gamestate.level.spawnPoints);

        gamestate.player =  new car(spawn);
      }
      gamestate.player.update();

      if (p2.vec2.length(gamestate.player.chassisBody.velocity) <= 0.05) {
        gamestate.player.chassisBody.backWheel.setBrakeForce(2);
        gamestate.player.boxShape.collisionGroup = config.CAR;
        gamestate.cars.push(gamestate.player);
        const car = _.sample(Cars);
        const spawn = _.sample(gamestate.level.spawnPoints);
        gamestate.player =  new car(spawn);
      }

      for (let i = gamestate.cars.length - 1; i >= 0; i--) {
        gamestate.cars[i].update()
      }
    }

    requestAnimationFrame(Valet.loop);
{'fraction_non_alphanumeric': 0.1275256707519046, 'fraction_numerical': 0.00728718118582312, 'mean_word_length': 2.6919315403422983, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5362910', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1009, 'n_words': 233}