bemusic/bemuse

View on GitHub
public/skins/default/_lib/common.jade

Summary

Maintainability
Test Coverage

mixin media(type, width, height, extra)
  if media == type
    skin(width=width height=height)&attributes(Object.assign({ }, extra || { }))
      block

mixin longnote(key, x, cur, add, visible)
  // body
  object(key=key pool='8')
    sprite(image=cur.image
          frame=(cur.width + 'x64+' + cur.x + '+' + (22 + add))
          x=(x)
          y=('(y*'+area_height+')+4-12')
          width=(cur.width)
          height=('height*'+area_height)
          visible=visible)
  // tail
  object(key=key pool='8')
    sprite(image=cur.image
          frame=(cur.width + 'x8+' + cur.x + '+' + (104 + add))
          x=(x)
          y='((y+height)*'+area_height+')+4-12'
          visible=visible)
  // head
  object(key=key pool='8')
    sprite(image=cur.image
          frame=(cur.width + 'x8+' + cur.x + '+' + (12 + add))
          x=(x)
          y='(y*'+area_height+')-12'
          visible=visible)

mixin notes(modeObject)
  - var x = 0
  object(key='p1_barlines' pool='8')
    sprite(image='NoteArea/Bar.png' x=0 y='(y*'+area_height+')-1' blend='screen')
  each column in modeObject.columns
    - var cur = styles[column.style]
    - var ch  = column.channel
    sprite(image=modeObject.highlight
            frame=(cur.width + 'x552+' + cur.x + '+0')
            x=(x) y='0' blend='screen' scale-x='1')
      animation
        keyframe(t='0' alpha='0' scale-x='1')
      animation(on='p1_' + ch + '_down')
        keyframe(t='0' alpha='1' scale-x='1')
      animation(on='p1_' + ch + '_up')
        keyframe(t='0' alpha='1' scale-x='1' x=(x))
        keyframe(t='0.18' ease='quadOut' alpha='0' scale-x='0' x=(x + cur.width / 2))
    object(key='p1_note_' + ch pool='24')
      sprite(image=cur.image frame=(cur.width + 'x12+' + cur.x + '+0')
              x=(x) y='(y*'+area_height+')-12')
    +longnote('p1_longnote_' + ch, x, cur, 0, '!active && !missed')
    +longnote('p1_longnote_' + ch, x, cur, 100, '!!active && !missed')
    +longnote('p1_longnote_' + ch, x, cur, 200, '!!missed')
    - x = x + cur.width + 1

mixin explosions(columns)
  - var x = 0
  each column in columns
    - var cur = styles[column.style]
    - var ch  = column.channel
    group(x=(x + cur.width / 2))
      animation
        keyframe(t='0' alpha='0' scale-x='1' scale-y='1')
      animation(on='p1_' + ch + '_explode')
        keyframe(t='0' alpha='1' scale-x='2' scale-y='1')
        keyframe(t='0.18' alpha='0' scale-x='2' scale-y='2')
      sprite(image='Explosion/NoteExplosion.png' x='-25' y='-25' blend='screen')
    - x = x + cur.width + 1

mixin note-hints(modeObject)
  - var x = modeObject.hintStart
  each column in modeObject.columns
    - var cur = hints[column.style]
    - var ch = column.channel
    group(x=(x))
      sprite(image=('NoteHint/Normal/' + cur.image)
              x=(cur.xoffset) y=(cur.yoffset) ref=('p1_' + ch))
      sprite(image=('NoteHint/Active/' + cur.image)
              x=(cur.xoffset - 1) y=(cur.yoffset - 1))
        animation
          keyframe(t='0' alpha='0')
        animation(on='p1_' + ch + '_down')
          keyframe(t='0' alpha='1')
        animation(on='p1_' + ch + '_up')
          keyframe(t='0' alpha='1')
          keyframe(t='0.18' alpha='0')
    - x = x + cur.xadvance

mixin note-area-background(modeObject)
  sprite(image=modeObject.background x='0' y='0')

mixin note-area-covers(modeObject)
  sprite(image=modeObject.cover5k alpha='0.8' x='0' y='0')

mixin note-area(modeObject)
  sprite(image='NoteArea/Flash.png' x='1' y='442' blend='screen'
          alpha='1 - (p1_beat % 1)')
  group(x='1' mask='283x550+1+0')
    +notes(modeObject)
  group(x='1' y='550')
    +explosions(modeObject.columns)

mixin note-area-hints(modeObject)
  group(y='556')
    +note-hints(modeObject)

mixin all-note-area
  group&attributes(attributes)
    #{'if'}(key='p1_scratch' value='left')
      group: +note-area-background(mode.iidx_l)
    #{'if'}(key='p1_scratch' value='right')
      group: +note-area-background(mode.iidx_r)
    #{'if'}(key='p1_scratch' value='off')
      group: +note-area-background(mode.kb)
    group(x='0' mask='284x550+0+0')
      group(x='0' y=('0-p1_lane_lift*'+area_height))
        #{'if'}(key='p1_scratch' value='left')
          group: +note-area(mode.iidx_l)
        #{'if'}(key='p1_scratch' value='right')
          group: +note-area(mode.iidx_r)
        #{'if'}(key='p1_scratch' value='off')
          group: +note-area(mode.kb)
        sprite(image='NoteArea/Stripe.png' x='1' y='537' blend='screen')
        sprite(image='NoteArea/LaneCover.png' x='1' y=(area_height))
      group(x='0' y=('p1_lane_press*'+area_height))
        sprite(image='NoteArea/LaneCover.png' x='1' y=(-area_height))
    #{'if'}(key='p1_scratch' value='left')
      group: +note-area-hints(mode.iidx_l)
    #{'if'}(key='p1_scratch' value='right')
      group: +note-area-hints(mode.iidx_r)
    #{'if'}(key='p1_scratch' value='off')
      group: +note-area-hints(mode.kb)
    #{'if'}(key='p1_key_mode' value='5K')
      group
        #{'if'}(key='p1_scratch' value='left')
          group: +note-area-covers(mode.iidx_l)
        #{'if'}(key='p1_scratch' value='right')
          group: +note-area-covers(mode.iidx_r)
        #{'if'}(key='p1_scratch' value='off')
          group: +note-area-covers(mode.kb)
    group(y=('0-p1_lane_lift*'+area_height))
      +press-start
      group(y='400')
        +judgments
      group(y='440')
        +judgment-deviations
    +hope-gauge

mixin hope-gauge
  group(x='6' y='6')
    sprite(image='Hope/HopeBar.png')
    sprite(image='Hope/HopeA.png' x='3' y='3' width='p1_gauge_secondary*263' height='5')
    sprite(image='Hope/Hope.png' x='3' y='3' width='p1_gauge_primary*263' height='5')
    sprite(image='Hope/HopeSS.png' x='3' y='3' width='p1_gauge_extra*263' height='5')
    animation
      keyframe(t='0' y='-20')
    animation(on='p1_gauge_enter')
      keyframe(t='0' y='-20')
      keyframe(t='0.5' y='-20' ease='quadOut')
      keyframe(t='1' y='6' ease='quadOut')
    animation(on='p1_gauge_exit')
      keyframe(t='0' y='6')
      keyframe(t='0.5' y='-20' ease='quadIn')


mixin press-start
  group(alpha='0.6 + ready*0.4')
    group(x='143' y='400' alpha='1')
      animation
        keyframe(t='0' alpha='1')
      animation(on='gettingStarted')
        keyframe(t='0' alpha='1' scale-x='1' scale-y='1')
        keyframe(t='0.1' alpha='1' scale-x='0.9' scale-y='0.9')
      animation(on='started')
        keyframe(t='0' alpha='0')
      sprite(image='NotePanel/PressStart.png' x='-107' y='-40' ref='start')
    group(x='143' y='400' alpha='0')
      animation(on='started')
        keyframe(t='0' alpha='0.5' scale-x='0.9' scale-y='0.9')
        keyframe(t='0.3' alpha='0' scale-x='1.5' scale-y='1.5')
      sprite(image='NotePanel/PressStart.png' x='-107' y='-40' blend='screen')
    group(x='143' y='400' alpha='0')
      animation(on='started')
        keyframe(t='0' alpha='0.5' scale-x='0.9' scale-y='0.9')
        keyframe(t='0.3' alpha='0' scale-x='0.67' scale-y='0.67')
      sprite(image='NotePanel/PressStart.png' x='-107' y='-40' blend='screen')

mixin judgments
  +judgment('1')
    +judgment-text('Meticulous')(text='*%s' data='p1_combo')
    +judgment-text('MeticulousGlow')(text='*%s' data='p1_combo' alpha='1 - ((t * 10) % 1)' blend='screen')
  +judgment('2')
    +judgment-text('Precise')(text='*%s' data='p1_combo')
  +judgment('3')
    +judgment-text('Good')(text='*%s' data='p1_combo')
  +judgment('4')
    +judgment-text('Other')(text='1')
  +judgment('missed')
    +judgment-text('Other')(text='0')

mixin judgment-text(name)
  text(x='141' align='center' font='BemuseDefault-'+name font-src='Fonts/BemuseDefault-'+name+'.fnt')&attributes(attributes)

mixin judgment(type)
  group(alpha='0')
    +judgment-animation(type)
    block

mixin judgment-animation(type)
  animation(on='p1_judge_1'):       +judgment-keyframes((type == '1'))
  animation(on='p1_judge_2'):       +judgment-keyframes((type == '2'))
  animation(on='p1_judge_3'):       +judgment-keyframes((type == '3'))
  animation(on='p1_judge_4'):       +judgment-keyframes((type == '4'))
  animation(on='p1_judge_missed'):  +judgment-keyframes((type == 'missed'))

mixin judgment-deviations
  +judgment-deviation('late')
    sprite(image='Deviation/Late.png' x='117')
  +judgment-deviation('early')
    sprite(image='Deviation/Early.png' x='111')

mixin judgment-deviation(type)
  group(alpha='0')
    +judgment-deviation-animation(type)
    block

mixin judgment-deviation-animation(type)
  animation(on='p1_judge_deviation_none'):  +judgment-keyframes((type == 'none'))
  animation(on='p1_judge_deviation_late'):  +judgment-keyframes((type == 'late'))
  animation(on='p1_judge_deviation_early'): +judgment-keyframes((type == 'early'))

mixin judgment-keyframes(active)
  if active
    keyframe(t='0' y='-16' alpha='1')
    keyframe(t='0.1' y='0' ease='quadOut')
    keyframe(t='0.6' alpha='1')
    keyframe(t='1' alpha='0')
  else
    keyframe(t='0' alpha='0')

mixin tutorial
  - var cx = attributes.width / 2
  - var time = function(measure) { return measure * 240 / 178 }
  - var touch = !!attributes.touch
  mixin fade(begin, end)
    animation
      keyframe(t=(time(begin)) alpha='0')
      keyframe(t=(time(begin) + 0.2) alpha='1')
      keyframe(t=(time(end) - 0.2) alpha='1')
      keyframe(t=(time(end)) alpha='0')
  mixin ready(begin)
    mixin ready-fade(start)
      animation
        keyframe(t=(time(start))             alpha='0' scale-x='1.2' scale-y='1.2')
        keyframe(t=(time(start) + 0.2)       alpha='1')
        keyframe(t=(time(start + 0.5) - 0.2) alpha='1')
        keyframe(t=(time(start + 0.5))       alpha='0' scale-x='0.8' scale-y='0.8')
    mixin ready-text(start, frame, w, h)
      group(x=(cx) y='360' t='gameTime')
        +ready-fade(start)
        sprite(image='Tutorial/Ready.png' x=(-w / 2) y=(-h / 2) frame=frame)
    +ready-text(begin + 0.0, '661x170+0+0',     661, 170)
    +ready-text(begin + 0.5, '231x248+9+176',   231, 248)
    +ready-text(begin + 1.0, '231x248+228+176', 231, 248)
    +ready-text(begin + 1.5, '133x248+483+176', 133, 248)
  #{'if'}(key='tutorial' value='yes')
    group
      sprite(image='Tutorial/Page0.png' x='64' y='64' t='gameTime')
        +fade(-1, 0)
      sprite(image='Tutorial/Page1.png' x='64' y='64' t='gameTime')
        +fade(0, 3)
      group(t='gameTime')
        +fade(19, 27)
        #{'if'}(key='p1_scratch' value='left')
          sprite(image=(touch ? 'Tutorial/Page2Touch.png' : 'Tutorial/Page2.png') x='64' y='64')
        #{'if'}(key='p1_scratch' value='right')
          sprite(image=(touch ? 'Tutorial/Page2Touch.png' : 'Tutorial/Page2.png') x='64' y='64')
        #{'if'}(key='p1_scratch' value='off')
          sprite(image=(touch ? 'Tutorial/Page2TouchKB.png' : 'Tutorial/Page2KB.png') x='64' y='64')
      sprite(image='Tutorial/Page3.png' x='64' y='64' t='gameTime')
        +fade(27, 33)
      +ready(33)
      sprite(image='Tutorial/Page4.png' x='64' y='64' t='gameTime')
        +fade(43, 49)
      +ready(49)
      sprite(image='Tutorial/Page5.png' x='64' y='64' t='gameTime')
        +fade(55, 57)
      +ready(57)
      sprite(image='Tutorial/Page6.png' x='64' y='64' t='gameTime')
        +fade(67, 73)
      +ready(73)