Skip to content

Instantly share code, notes, and snippets.

module ButtonUtilities exposing (..)
import Html exposing (Html, div, text, button, p)
import Html.Events exposing (onClick)
-- Create an ID type that will but used to tag each
-- button in the model's `buttons` array with a unique id
module Main exposing(..)
import Html exposing (..)
import Html.App as Html
import Html.Events exposing (..)
import Html.Attributes exposing (src, style, class, id, width, height, autoplay, loop)
import Json.Decode as Json
import String
import String.Extra
import List.Extra
port module Main exposing(..)
import Html exposing (..)
import Html.App as Html
import Html.Events exposing (..)
import Html.Attributes exposing (src, style)
import Json.Decode as Json
import String
import String.Extra
import Regex
@kittykatattack
kittykatattack / flatCounterPair.elm
Last active August 22, 2016 16:32
Flat Elm UI Component Architecture Experiment
import Html exposing (Html, button, div, text)
import Html.App as Html
import Html.Events exposing (onClick)
main =
Html.beginnerProgram
{ model = model
, view = view
@kittykatattack
kittykatattack / Main.elm
Created June 12, 2016 20:33
Basic Elm 0.17 Beginner Program starter template
import Html exposing (..)
import Html.App as Html
-- MODEL
type alias Model =
{ value : Int
}
@kittykatattack
kittykatattack / gist:bfc18cef6ad9f91437fbe268c69f3901
Last active November 5, 2018 20:06
Standard Elm boilerplate
import Html exposing (..)
import Html.App as Html
import Html.Events exposing (..)
-- MODEL
type alias Model =
{ content : String
}
@kittykatattack
kittykatattack / rectangleCollision
Created November 12, 2014 21:10
A collision function two prevent two rectangular sprites from overlapping. Optionally, bounce them apart
/*
#### rectangleCollision
Use it to prevent two rectangular sprites from overlapping.
Optionally, make the first retangle bounceoff the second rectangle.
Parameters:
a. A sprite object with `x`, `y` `center.x`, `center.y`, `halfWidth` and `halfHeight` properties.
b. A sprite object with `x`, `y` `center.x`, `center.y`, `halfWidth` and `halfHeight` properties.
c. Optional: true or false to indicate whether or not the first sprite
should bounce off the second sprite.
@kittykatattack
kittykatattack / webAudioWrapper
Last active August 29, 2015 14:06
Load and play sounds easily. A lightweight high level wrapper for WebAudio API.
<!doctype html>
<meta charset="utf-8">
<title>Basic WebAudio API sound sprite</title>
<p>Press 1 to play the sound</p>
<script>
//Define the audio context
window.AudioContext = window.AudioContext || window.webkitAudioContext;
@kittykatattack
kittykatattack / movingCircleCollision
Created August 27, 2014 17:04
A function that bounces apart two moving circles
/*
# movingCircleCollision
Use it to make two moving circles bounce off each other.
Parameters:
a. A sprite object with `x`, `y` `centerX`, `centerY` and `radius` properties.
b. A sprite object with `x`, `y` `centerX`, `centerY` and `radius` properties.
The sprites can contain an optional mass property that should be greater than 1.
*/
/*
makeIsoTiledWorld
=================
An interpreter for isometric Tiled Editor JSON output.
Important: To work it requires to custom map properties:
`cartTilewidth` and `cartTileheight`. These are the Cartesian
(flat 2D) dimensions of the tile map array. These are needed
because it's common to have a 32x32 tile map array that displays
64x64 sprites.