Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ecad8c5
code cleanup
trotha01 Sep 18, 2016
0799e33
WIP: adding mouse
trotha01 Sep 26, 2016
48e170c
starting from scratch
trotha01 Apr 23, 2017
12e87c1
initial commit. Mouse movement, madre and padre with sound
trotha01 Apr 23, 2017
c08589c
refactored bee into its own module
trotha01 Apr 24, 2017
c8cc514
started adding map
trotha01 Apr 24, 2017
4223bc1
added town and some color
trotha01 Apr 26, 2017
af6d511
updated grocery store
trotha01 Apr 26, 2017
55d161d
new formatting plus better animation
trotha01 May 24, 2017
fc3e074
fix wall bouncing bug
trotha01 May 25, 2017
a51fa80
colors collide
trotha01 May 25, 2017
7c95897
some cleanup
trotha01 May 25, 2017
3f31a5c
restructuring
trotha01 May 25, 2017
dbe9af5
remove color on click
trotha01 May 25, 2017
8db37a6
change colors every 2 seconds
trotha01 May 26, 2017
a107896
add puff sound
trotha01 May 26, 2017
e4b68da
added color images, randomly generate color balls
trotha01 May 27, 2017
0ee9be6
add win state and a little cleanup
trotha01 May 27, 2017
f0a2d46
mousedown, not onclick
trotha01 May 27, 2017
0809df2
do not allow 0 velocity
trotha01 May 27, 2017
6402488
using spanish dict. play sound on color change
trotha01 May 27, 2017
2877f17
refactoring out the stores
trotha01 May 28, 2017
f95ff17
added french
trotha01 May 28, 2017
811f15b
added header
trotha01 May 28, 2017
450b0bc
exit art store working
trotha01 May 28, 2017
ab6e793
move header out of map to top level
trotha01 May 28, 2017
4d75a86
introduce one color at a time
trotha01 May 28, 2017
e71bbe6
add color splat
trotha01 May 28, 2017
0afaa55
play color audio on start
trotha01 May 28, 2017
9ebbb55
at least one of each color
trotha01 May 28, 2017
eaea1c4
within window
trotha01 May 29, 2017
b4ffbd3
modulate home. add family translations
trotha01 May 29, 2017
20cb80d
modulate grocery store
trotha01 May 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Audio.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
port module Audio exposing (play)

-- PORTS


port play : String -> Cmd msg
169 changes: 169 additions & 0 deletions Bee.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
module Bee exposing (..)

import Animation exposing (Animation, animation, from, speed, to)
import Dictionary.Translator exposing (Translator)
import Html exposing (Html, div, img)
import Html.Attributes exposing (height, src, style, width)
import Html.Events exposing (onClick)
import Time exposing (Time)


-- MODEL


type alias Bee =
{ x : Int
, y : Int
, animX : Animation
, animY : Animation
, src : String
, audio : Maybe String
}



-- VIEW


view : Maybe (String -> msg) -> Bee -> Html msg
view clickAction bee =
let
attributes =
[ src bee.src
, height <| scaleBee beeHeight
, width <| scaleBee beeWidth
]

attributesWithEvents =
case ( clickAction, bee.audio ) of
( Just click, Just audio ) ->
onClick (click audio) :: attributes

_ ->
attributes

wrapper =
div
[ style
[ -- ( "box-shadow", "3px 3px 1px #ccc" )
( "position", "absolute" )
, ( "user-select", "none" )
, ( "left", toString bee.x ++ "px" )
, ( "top", toString bee.y ++ "px" )
]
]
in
wrapper
[ img attributesWithEvents []
]



-- Bees


player =
{ x = 0
, y = 0
, animX = animation 0
, animY = animation 0
, src = "imgs/bee-left.png"
, audio = Nothing
}


mama : Translator -> Bee
mama translator =
{ x = 100
, y = 100
, animX = animation 0
, animY = animation 0
, src = "imgs/mama-bee.png"
, audio = Just (translator.audio "mom")
}


papa : Translator -> Bee
papa translator =
{ x = 600
, y = 100
, animX = animation 0
, animY = animation 0
, src = "imgs/papa-bee.png"
, audio = Just (translator.audio "dad")
}



-- ANIMATION


beeVelocity =
0.5


type alias Position =
{ x : Int
, y : Int
}


animate : Time -> Bee -> Bee
animate time bee =
let
newX =
Animation.animate time bee.animX

newY =
Animation.animate time bee.animY
in
{ bee | x = round newX, y = round newY }


animateStart : Time -> Position -> Bee -> Bee
animateStart startTime toPosition bee =
let
animX =
animation startTime
|> from (toFloat bee.x)
|> to (toFloat toPosition.x)
|> speed beeVelocity

animY =
animation startTime
|> from (toFloat bee.y)
|> to (toFloat toPosition.y)
|> speed beeVelocity
in
{ bee
| animX = animX
, animY = animY
}


retarget : Time -> Position -> Bee -> Bee
retarget time toPosition bee =
let
animX =
bee.animX |> Animation.retarget time (toFloat toPosition.x)

animY =
bee.animY |> Animation.retarget time (toFloat toPosition.y)
in
{ bee
| animX = animX
, animY = animY
}



-- HELPERS


( beeHeight, beeWidth ) =
( 456, 640 )


scaleBee : Float -> Int
scaleBee dimension =
dimension / 8 |> round
Loading