<commit_before>LaggyDash = window.LaggyDash

class Landscape extends Phaser.State
  SPEED = 1

  constructor:->

  preload:->
    window.laggydash.connect('laggydash', laggydash.game.rnd.uuid() + ":#{@game.player_name}")

  create:->
    @game.stage.backgroundColor = '#000055'

    @night = @game.add.sprite(@game.world.centerX, @game.world.centerY, 'night')
    @night.alpha = 0
    @night.anchor.setTo(0.5, 0.5)

    fade = @game.add.tween(@night)
    fade.to({ alpha: 1 }, 300000 / SPEED, Phaser.Easing.Linear.None, true, 150000 / SPEED, 999, true)
    fade.start

    @sky = @game.add.sprite(@game.world.centerX, @game.world.centerY, 'sky')
    @sky.alpha = 1
    @sky.anchor.setTo(0.5, 0.5)

    fade = @game.add.tween(@sky)
    fade.to({ alpha: 0 }, 450000 / SPEED, Phaser.Easing.Linear.None, true, 0, 999, true)
    fade.start

    @sun = @game.add.sprite(0, 0, 'sun')
    @sun.anchor.setTo(0.5, 0.5)
    @sun.scale.setTo(0.3, 0.4)
    @sun.x = @game.world.centerX
    @sun.y = @game.world.centerY * 0.5 - 100

    grow = @game.add.tween(@sun.scale)
    grow.to({ x: 1.5, y: 1.5 }, 450000 / SPEED, Phaser.Easing.Cubic.InOut, true, 0, 999, true)
    grow.start

    set = @game.add.tween(@sun)
    set.to({ y: 675 }, 450000 / SPEED, Phaser.Easing.Sinusoidal.InOut, true, 0, 999, true)
    set.start

    fade = @game.add.tween(@sun)
    fade.to({ alpha: 0 }, 450000 / SPEED, Phaser.Easing.Linear.None, true, 0, true, true)
    fade.start

    @cloud = @game.add.sprite(1000, 70, 'cloud')
    @cloud.alpha = 0.4
    move = @game.add.tween(@cloud)
    move.to({x: -800}, 70000 / SPEED, Phaser.Easing.Linear.None, true, 0, 999)
    move.start

    @mountain0a = @game.add.sprite(0, 180, 'mountain0')
    @mountain0b = @game.add.sprite(2000, 180, 'mountain0')

    @player_group = @game.add.group()

    @coin = @game.add.sprite(400, 250, 'coin')
    @coin.anchor.setTo(0.5, 0.5)
    @coin.animations.add('spin', [0, 1, 2, 3, 4, 5], 10, true)
    @coin.animations.play('spin')

    @bomb = @game.add.sprite(450, 250, 'bomb')
    @bomb.anchor.setTo(0.5, 0.5)
    @bomb.animations.add('pulse', [0, 1, 2, 3, 4, 5], 10, true)
    @bomb.animations.play('pulse')

    @explosion = @game.add.sprite(500, 250, 'explosion')
    @explosion.anchor.setTo(0.5, 0.5)
    @explosion.animations.add('bang', [0, 1, 2, 3], 10, true)
    @explosion.animations.play('bang')

    @mountain1a = @game.add.sprite(0, 180, 'mountain1')
    @mountain1b = @game.add.sprite(2000, 180, 'mountain1')

    @heightmap = []
    y = 122
    for x in [0..@mountain1a.width]
      solid = @mountain1a.input.checkPixel(x, y)
      if solid
        while solid
          y -= 1
          solid = @mountain1a.input.checkPixel(x, y)
        y += 1
      else
        until solid
          y += 1
          solid = @mountain1a.input.checkPixel(x, y)
          break if y > 200
      @heightmap.push(y)

    @mountain1a.alpha = 0.95
    @mountain1b.alpha = 0.95

    @mountain2a = @game.add.sprite(0, 180, 'mountain2')
    @mountain2b = @game.add.sprite(2000, 180, 'mountain2')

    @mountain3a = @game.add.sprite(0, 180, 'mountain3')
    @mountain3b = @game.add.sprite(2000, 180, 'mountain3')
    @mountain3a.alpha = 0.4
    @mountain3b.alpha = 0.4

    @avatar_group = @game.add.group()

    @tree0 = @game.add.sprite(2000, 490, 'tree0')
    @tree0.anchor.setTo(0.5, 1)
    move = @game.add.tween(@tree0)
    move.to({x: -2000}, 3400 / SPEED, Phaser.Easing.Linear.None, true, 3000 / SPEED, 999)
    move.start

    @tree1 = @game.add.sprite(2000, 490, 'tree1')
    @tree1.anchor.setTo(0.5, 1)
    move = @game.add.tween(@tree1)
    move.to({x: -2000}, 3500 / SPEED, Phaser.Easing.Linear.None, true, 7000 / SPEED, 999)
    move.start

    @tree2 = @game.add.sprite(2000, 490, 'tree2')
    @tree2.anchor.setTo(0.5, 1)
    move = @game.add.tween(@tree2)
    move.to({x: -2000}, 3600 / SPEED, Phaser.Easing.Linear.None, true, 13000 / SPEED, 999)
    move.start

    @tree3 = @game.add.sprite(2000, 490, 'tree3')
    @tree3.anchor.setTo(0.5, 1)
    move = @game.add.tween(@tree3)
    move.to({x: -2000}, 3400 / SPEED, Phaser.Easing.Linear.None, true, 17000 / SPEED, 999)
    move.start

    @grass1 = @game.add.sprite(0, 380, 'grass')
    @grass2 = @game.add.sprite(896, 380, 'grass')

    @label_group = @game.add.group()

    @position = 0
    @players = {}
    @addPlayer(laggydash.user.replace(/:.*$/, ''), @game.player_name, true)

  update:->
    @position += 1

    @grass1.x -= 20 * SPEED
    @grass2.x -= 20 * SPEED
    @grass1.x += 896 * 2 if @grass1.x <= -896
    @grass2.x += 896 * 2 if @grass2.x <= -896

    @mountain0a.x -= 1.1 * SPEED
    @mountain0b.x -= 1.1 * SPEED
    @mountain0a.x += 2000 * 2 if @mountain0a.x <= -2000
    @mountain0b.x += 2000 * 2 if @mountain0b.x <= -2000

    @mountain1a.x -= 1.7 * SPEED
    @mountain1b.x -= 1.7 * SPEED
    @mountain1a.x += 2000 * 2 if @mountain1a.x <= -2000
    @mountain1b.x += 2000 * 2 if @mountain1b.x <= -2000

    @mountain2a.x -= 2.3 * SPEED
    @mountain2b.x -= 2.3 * SPEED
    @mountain2a.x += 2000 * 2 if @mountain2a.x <= -2000
    @mountain2b.x += 2000 * 2 if @mountain2b.x <= -2000

    @mountain3a.x -= 2.9 * SPEED
    @mountain3b.x -= 2.9 * SPEED
    @mountain3a.x += 2000 * 2 if @mountain3a.x <= -2000
    @mountain3b.x += 2000 * 2 if @mountain3b.x <= -2000

  addPlayer:(id, name, isPlayer=false)->
    x = if isPlayer then 600 else 300
    s = if isPlayer then 'runner' else 'wolf'

    runner = @game.add.sprite(x, 300, s)
    runner.anchor.setTo(0.5, 1.0)

    runner.animations.add('run', [0, 1, 2, 3, 4, 5], 10, true)
    runner.animations.play('run')

    @player_group.add(runner)

    avatar = @game.add.sprite(x, 475, "@#{name}")
    avatar.id = id
    avatar.name = name
    avatar.width = 60
    avatar.height = 60
    avatar.anchor.setTo(0.5, 1.0)
    avatar.alpha = 0.8
    avatar.inputEnabled = true
    avatar.useHandCursor = true
    avatar.events.onInputDown.add =>
      window.laggydash.showUser(name)

#   pen = @game.add.graphics(0, 0)
#   pen.lineStyle(2, 0xffd900, 0.5)
#   pen.moveTo(runner.x, runner.y)
#   pen.lineTo(avatar.x, avatar.y - 65)

    @avatar_group.add(avatar)

    style =
      font: "10pt Courier"<commit_msg>stick to the ground<commit_after>LaggyDash = window.LaggyDash

class Landscape extends Phaser.State
  SPEED = 1

  constructor:->

  preload:->
    window.laggydash.connect('laggydash', laggydash.game.rnd.uuid() + ":#{@game.player_name}")

  create:->
    @game.stage.backgroundColor = '#000055'

    @night = @game.add.sprite(@game.world.centerX, @game.world.centerY, 'night')
    @night.alpha = 0
    @night.anchor.setTo(0.5, 0.5)

    fade = @game.add.tween(@night)
    fade.to({ alpha: 1 }, 300000 / SPEED, Phaser.Easing.Linear.None, true, 150000 / SPEED, 999, true)
    fade.start

    @sky = @game.add.sprite(@game.world.centerX, @game.world.centerY, 'sky')
    @sky.alpha = 1
    @sky.anchor.setTo(0.5, 0.5)

    fade = @game.add.tween(@sky)
    fade.to({ alpha: 0 }, 450000 / SPEED, Phaser.Easing.Linear.None, true, 0, 999, true)
    fade.start

    @sun = @game.add.sprite(0, 0, 'sun')
    @sun.anchor.setTo(0.5, 0.5)
    @sun.scale.setTo(0.3, 0.4)
    @sun.x = @game.world.centerX
    @sun.y = @game.world.centerY * 0.5 - 100

    grow = @game.add.tween(@sun.scale)
    grow.to({ x: 1.5, y: 1.5 }, 450000 / SPEED, Phaser.Easing.Cubic.InOut, true, 0, 999, true)
    grow.start

    set = @game.add.tween(@sun)
    set.to({ y: 675 }, 450000 / SPEED, Phaser.Easing.Sinusoidal.InOut, true, 0, 999, true)
    set.start

    fade = @game.add.tween(@sun)
    fade.to({ alpha: 0 }, 450000 / SPEED, Phaser.Easing.Linear.None, true, 0, true, true)
    fade.start

    @cloud = @game.add.sprite(1000, 70, 'cloud')
    @cloud.alpha = 0.4
    move = @game.add.tween(@cloud)
    move.to({x: -800}, 70000 / SPEED, Phaser.Easing.Linear.None, true, 0, 999)
    move.start

    @mountain0a = @game.add.sprite(0, 180, 'mountain0')
    @mountain0b = @game.add.sprite(2000, 180, 'mountain0')

    @player_group = @game.add.group()

    @coin = @game.add.sprite(400, 250, 'coin')
    @coin.anchor.setTo(0.5, 0.5)
    @coin.animations.add('spin', [0, 1, 2, 3, 4, 5], 10, true)
    @coin.animations.play('spin')

    @bomb = @game.add.sprite(450, 250, 'bomb')
    @bomb.anchor.setTo(0.5, 0.5)
    @bomb.animations.add('pulse', [0, 1, 2, 3, 4, 5], 10, true)
    @bomb.animations.play('pulse')

    @explosion = @game.add.sprite(500, 250, 'explosion')
    @explosion.anchor.setTo(0.5, 0.5)
    @explosion.animations.add('bang', [0, 1, 2, 3], 10, true)
    @explosion.animations.play('bang')

    @mountain1a = @game.add.sprite(0, 180, 'mountain1')
    @mountain1b = @game.add.sprite(2000, 180, 'mountain1')

    @heightmap = []
    y = 122
    for x in [0..@mountain1a.width]
      solid = @mountain1a.input.checkPixel(x, y)
      if solid
        while solid
          y -= 1
          solid = @mountain1a.input.checkPixel(x, y)
        y += 1
      else
        until solid
          y += 1
          solid = @mountain1a.input.checkPixel(x, y)
          break if y > 200
      @heightmap.push(y)

    @mountain1a.alpha = 0.95
    @mountain1b.alpha = 0.95

    @mountain2a = @game.add.sprite(0, 180, 'mountain2')
    @mountain2b = @game.add.sprite(2000, 180, 'mountain2')

    @mountain3a = @game.add.sprite(0, 180, 'mountain3')
    @mountain3b = @game.add.sprite(2000, 180, 'mountain3')
    @mountain3a.alpha = 0.4
    @mountain3b.alpha = 0.4

    @avatar_group = @game.add.group()

    @tree0 = @game.add.sprite(2000, 490, 'tree0')
    @tree0.anchor.setTo(0.5, 1)
    move = @game.add.tween(@tree0)
    move.to({x: -2000}, 3400 / SPEED, Phaser.Easing.Linear.None, true, 3000 / SPEED, 999)
    move.start

    @tree1 = @game.add.sprite(2000, 490, 'tree1')
    @tree1.anchor.setTo(0.5, 1)
    move = @game.add.tween(@tree1)
    move.to({x: -2000}, 3500 / SPEED, Phaser.Easing.Linear.None, true, 7000 / SPEED, 999)
    move.start

    @tree2 = @game.add.sprite(2000, 490, 'tree2')
    @tree2.anchor.setTo(0.5, 1)
    move = @game.add.tween(@tree2)
    move.to({x: -2000}, 3600 / SPEED, Phaser.Easing.Linear.None, true, 13000 / SPEED, 999)
    move.start

    @tree3 = @game.add.sprite(2000, 490, 'tree3')
    @tree3.anchor.setTo(0.5, 1)
    move = @game.add.tween(@tree3)
    move.to({x: -2000}, 3400 / SPEED, Phaser.Easing.Linear.None, true, 17000 / SPEED, 999)
    move.start

    @grass1 = @game.add.sprite(0, 380, 'grass')
    @grass2 = @game.add.sprite(896, 380, 'grass')

    @label_group = @game.add.group()

    @position = 0
    @players = {}
    @addPlayer(laggydash.user.replace(/:.*$/, ''), @game.player_name, true)

  update:->
    @position += 1

    @grass1.x -= 20 * SPEED
    @grass2.x -= 20 * SPEED
    @grass1.x += 896 * 2 if @grass1.x <= -896
    @grass2.x += 896 * 2 if @grass2.x <= -896

    @mountain0a.x -= 1.1 * SPEED
    @mountain0b.x -= 1.1 * SPEED
    @mountain0a.x += 2000 * 2 if @mountain0a.x <= -2000
    @mountain0b.x += 2000 * 2 if @mountain0b.x <= -2000

    @mountain1a.x -= 1.7 * SPEED
    @mountain1b.x -= 1.7 * SPEED
    @mountain1a.x += 2000 * 2 if @mountain1a.x <= -2000
    @mountain1b.x += 2000 * 2 if @mountain1b.x <= -2000

    @mountain2a.x -= 2.3 * SPEED
    @mountain2b.x -= 2.3 * SPEED
    @mountain2a.x += 2000 * 2 if @mountain2a.x <= -2000
    @mountain2b.x += 2000 * 2 if @mountain2b.x <= -2000

    @mountain3a.x -= 2.9 * SPEED
    @mountain3b.x -= 2.9 * SPEED
    @mountain3a.x += 2000 * 2 if @mountain3a.x <= -2000
    @mountain3b.x += 2000 * 2 if @mountain3b.x <= -2000

    min = Math.round(Math.min(@mountain1a.x, @mountain1b.x))
    @player_group.forEachAlive (player) =>
      x = (player.x - min) % 2000
      player.y = @heightmap[x] + @mountain1a.y + 3

  addPlayer:(id, name, isPlayer=false)->
    x = if isPlayer then 600 else 300
    s = if isPlayer then 'runner' else 'wolf'
    f = if isPlayer then 8 else 12

    runner = @game.add.sprite(x, 300, s)
    runner.anchor.setTo(0.5, 1.0)

    runner.animations.add('run', [0, 1, 2, 3, 4, 5], f, true)
    runner.animations.play('run')

    @player_group.add(runner)

    avatar = @game.add.sprite(x, 475, "@#{name}")
    avatar.id = id
    avatar.name = name
    avatar.width = 60
    avatar.height = 60
    avatar.anchor.setTo(0.5, 1.0)
    avatar.alpha = 0.8
    avatar.inputEnabled = true
    avatar.useHandCursor = true
    avatar.events.onInputDown.add =>
      window.laggydash.showUser(name)

#   pen = @game.add.graphics(0, 0)
#   pen.lineStyle(2, 0xffd900, 0.5)
#   pen.moveTo(runner.x, runner.y)
#   pen.lineTo(avatar.x, avatar.y - 65)

    @avatar_group.add(avatar)

    style =
      font: "10pt Courier"
{'fraction_non_alphanumeric': 0.18113986347039213, 'fraction_numerical': 0.09104619780917605, 'mean_word_length': 2.6339775021632534, 'pattern_counts': {'":': 2, '<': 23, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1316561', 'n_tokens_mistral': 6108, 'n_tokens_neox': 5210, 'n_words': 1038}