Skip to content

Instantly share code, notes, and snippets.

Avatar

kittykatattack

  • UK
View GitHub Profile
@kittykatattack
kittykatattack / movingCircleCollision
Created Aug 27, 2014
A function that bounces apart two moving circles
View movingCircleCollision
/*
# 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.
*/
@kittykatattack
kittykatattack / webAudioWrapper
Last active Aug 29, 2015
Load and play sounds easily. A lightweight high level wrapper for WebAudio API.
View webAudioWrapper
<!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 / rectangleCollision
Created Nov 12, 2014
A collision function two prevent two rectangular sprites from overlapping. Optionally, bounce them apart
View rectangleCollision
/*
#### 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.
View gist:e3e2505a50686bbdeef9
/*
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.
@kittykatattack
kittykatattack / flatCounterPair.elm
Last active Aug 22, 2016
Flat Elm UI Component Architecture Experiment
View flatCounterPair.elm
import Html exposing (Html, button, div, text)
import Html.App as Html
import Html.Events exposing (onClick)
main =
Html.beginnerProgram
{ model = model
, view = view
View gist:f05b42efc6ecf09ddf244bbafd18edb3
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
View addStatePlayer
/*
An advanced frame and state manager for Pixi MovieClip sprites.
Use it like this:
Add the advanced state player to a PIXI.MovieClip
addStatePlayer(movieClipSprite);
Set the frame rate
View chatBot.elm
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
View ButtonUtilities.elm
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
View gist:bfc18cef6ad9f91437fbe268c69f3901
import Html exposing (..)
import Html.App as Html
import Html.Events exposing (..)
-- MODEL
type alias Model =
{ content : String
}
You can’t perform that action at this time.