Skip to content

Commit

Permalink
Update elm-tiled to 0.19
Browse files Browse the repository at this point in the history
  • Loading branch information
justgook committed May 7, 2019
1 parent fb51f5a commit d00e368
Show file tree
Hide file tree
Showing 19 changed files with 2,189 additions and 1,286 deletions.
52 changes: 9 additions & 43 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,12 @@
sudo: false
language: bash
cache:
directories:
- test/elm-stuff/build-artifacts
- sysconfcpus

os:
- osx
- linux
sudo: required

env:
matrix:
- ELM_VERSION=0.18.0 TARGET_NODE_VERSION=node
# - ELM_VERSION=0.18.0 TARGET_NODE_VERSION=4.0
language: elm
node_js: '10' # latest 10.x

before_install:
- if [ ${TRAVIS_OS_NAME} == "osx" ];
then brew update; brew install nvm; mkdir ~/.nvm; export NVM_DIR=~/.nvm; source $(brew --prefix nvm)/nvm.sh;
fi
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- | # epic build time improvement - see https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142
if [ ! -d sysconfcpus/bin ];
then
git clone https://github.com/obmarg/libsysconfcpus.git;
cd libsysconfcpus;
./configure --prefix=$TRAVIS_BUILD_DIR/sysconfcpus;
make && make install;
cd ..;
fi
elm-test: 0.19.0-rev6
elm-format: 0.8.1

install:
- nvm install $TARGET_NODE_VERSION
- nvm use $TARGET_NODE_VERSION
- node --version
- npm --version
- cd tests
- npm install -g elm@$ELM_VERSION elm-test
- mv $(npm config get prefix)/bin/elm-make $(npm config get prefix)/bin/elm-make-old
- printf '%s\n\n' '#!/bin/bash' 'echo "Running elm-make with sysconfcpus -n 2"' '$TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 elm-make-old "$@"' > $(npm config get prefix)/bin/elm-make
- chmod +x $(npm config get prefix)/bin/elm-make
- elm package install --yes
- cd ..

script:
- elm-test
cache:
yarn: true
directories:
- node_modules
18 changes: 0 additions & 18 deletions elm-package.json

This file was deleted.

25 changes: 25 additions & 0 deletions elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "package",
"name": "justgook/elm-tiled",
"summary": "A library for building decoders for Tiled levels.",
"license": "BSD-3-Clause",
"version": "1.0.0",
"exposed-modules": [
"Tiled",
"Tiled.Level",
"Tiled.Layer",
"Tiled.Tileset",
"Tiled.Object",
"Tiled.Properties"
],
"elm-version": "0.19.0 <= v < 0.20.0",
"dependencies": {
"NoRedInk/elm-json-decode-pipeline": "1.0.0 <= v < 2.0.0",
"elm/core": "1.0.0 <= v < 2.0.0",
"elm/json": "1.1.2 <= v < 2.0.0",
"elm-community/json-extra": "4.0.0 <= v < 5.0.0"
},
"test-dependencies": {
"elm-explorations/test": "1.2.1 <= v < 2.0.0"
}
}
84 changes: 84 additions & 0 deletions src/Tiled.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
module Tiled exposing
( decode, encode
, GidInfo, gidInfo
)

{-| Use the [`decode`](#decode) to get [`Level`](Tiled-Level)
# Default Decoding
@docs decode, encode
-}

import Bitwise
import Json.Decode as Json exposing (Decoder)
import Tiled.Level as Level exposing (Level)


{-| Alias to [`Level.encode`](Tiled.Level#encode)
-}
encode : Level -> Json.Value
encode =
Level.encode


{-| Alias to [`Level.decode`](Tiled.Level#decode)
-}
decode : Decoder Level
decode =
Level.decode



-- http://doc.mapeditor.org/en/latest/reference/tmx-map-format/#tile-flipping


type alias GidInfo =
{ gid : Int, fh : Bool, fv : Bool, fd : Bool }


gidInfo : Int -> GidInfo
gidInfo gid =
{ gid = cleanGid gid
, fh = flippedHorizontally gid
, fv = flippedVertically gid
, fd = flippedDiagonally gid
}


flippedHorizontally : Int -> Bool
flippedHorizontally globalTileId =
Bitwise.and globalTileId flippedHorizontalFlag /= 0


flippedVertically : Int -> Bool
flippedVertically globalTileId =
Bitwise.and globalTileId flippedVerticalFlag /= 0


flippedDiagonally : Int -> Bool
flippedDiagonally globalTileId =
Bitwise.and globalTileId flippedDiagonalFlag /= 0


cleanGid : Int -> Int
cleanGid globalTileId =
flippedHorizontalFlag
|> Bitwise.or flippedVerticalFlag
|> Bitwise.or flippedDiagonalFlag
|> Bitwise.complement
|> Bitwise.and globalTileId


flippedHorizontalFlag =
0x80000000


flippedVerticalFlag =
0x40000000


flippedDiagonalFlag =
0x20000000
Loading

0 comments on commit d00e368

Please sign in to comment.