Skip to content

Commit

Permalink
eat note, rebalance ui
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Apr 19, 2015
1 parent feb69b2 commit d94529c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 14 deletions.
2 changes: 1 addition & 1 deletion conf.moon
Expand Up @@ -16,7 +16,7 @@ export GAME_CONFIG = {

love.conf = (t) ->
t.window.width = 200 * GAME_CONFIG.scale
t.window.height = 230 * GAME_CONFIG.scale
t.window.height = 280 * GAME_CONFIG.scale

t.title = "the game"
t.author = "leafo"
4 changes: 2 additions & 2 deletions emitters.moon
Expand Up @@ -17,7 +17,7 @@ class ThreshEmitter extends TextEmitter
p.accel = @accel
p.color = @colors[@str]

class HitEmitter extends Emitter
class BreakEmitter extends Emitter
accel: Vec2d 0, 300
count: 5

Expand Down Expand Up @@ -51,4 +51,4 @@ class SparkEmitter extends Emitter
.vel = Vec2d(0, rand(-120, -150))\random_heading 40
.size = rand 2,6

{ :HitEmitter, :SparkEmitter, :ThreshEmitter }
{ :BreakEmitter, :SparkEmitter, :ThreshEmitter }
43 changes: 36 additions & 7 deletions game.moon
Expand Up @@ -5,13 +5,13 @@ import Bin, HList, VList, Label, Border from require "lovekit.ui"

import Metronome, VisibilityMeter from require "ui"
import Track from require "track"
import HitEmitter, SparkEmitter, ThreshEmitter from require "emitters"
import BreakEmitter, SparkEmitter, ThreshEmitter from require "emitters"

import Face, Tongue from require "face"

class TrackField extends Box
w: 200
h: 200
w: 140
h: 240

min_delta: 120

Expand Down Expand Up @@ -40,21 +40,50 @@ class TrackField extends Box

nx, ny = @note_position note

@particles\add HitEmitter note, @, nx, ny
@particles\add SparkEmitter @, nx, ny
@eat_note note

thresh = @threshold_for_delta note.hit_delta
@particles\add ThreshEmitter thresh, @, nx,ny

@game\on_hit_note note

eat_note: (note) =>
nx, ny = @note_position note

spark = @particles\add SparkEmitter @, nx, ny

local sprite
seq = Sequence ->
tween sprite, 0.2, x: @face.tongue.x, y: @face.tongue.y
tween sprite, 0.1, a: 0

sprite = {
a: 1
x: nx, y: ny

update: (dt) =>
with seq\update dt
spark.x = @x
spark.y = @y

draw: =>
COLOR\pusha 255 * @a
note.sprite\draw note.quad, @x + note.ox, @y + note.oy
COLOR\pop!

}
@particles\add sprite

-- note might be nil if it was a mis-press
on_miss_note: (note, from_hit) =>
@chain = 0

if from_hit and note
if note
nx, ny = @note_position note
@particles\add ThreshEmitter "miss", @, nx,ny
@particles\add BreakEmitter note, @, nx,ny

if from_hit
@particles\add ThreshEmitter "miss", @, nx,ny

@shake!

Expand Down
7 changes: 4 additions & 3 deletions notes.moon
Expand Up @@ -17,9 +17,10 @@ class Note

@sprite\draw @quad, @x + @ox, @y + @oy

g.rectangle "line",
@x - @w/2, @y - @h/2,
@w, @h
if DEBUG
g.rectangle "line",
@x - @w/2, @y - @h/2,
@w, @h


class Note1 extends Note
Expand Down
3 changes: 2 additions & 1 deletion ui.moon
Expand Up @@ -52,9 +52,10 @@ class Bar extends Box

class VisibilityMeter extends VList
p: 0.5
w: 140

new: =>
@bar = Bar 0,0, 200, 10
@bar = Bar 0,0, 140, 10

super {
Label "visibility"
Expand Down

0 comments on commit d94529c

Please sign in to comment.