Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Elm 0.18 #3

Merged
merged 1 commit into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ $(PICO_8_FONT_ELM): Makefile $(CONVERTER) $(PICO_8_FONT_PNG)

documentation.json: $(SOURCES)
elm make --docs=documentation.json --warn

.PHONY: format
format:
elm format --upgrade --yes src/ examples/

.PHONY: upgrade
upgrade:
elm upgrade
14 changes: 7 additions & 7 deletions elm-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"Elmo8.Pico8"
],
"dependencies": {
"elm-community/elm-linear-algebra": "2.0.3 <= v < 3.0.0",
"elm-community/elm-webgl": "3.0.3 <= v < 4.0.0",
"elm-lang/animation-frame": "1.0.0 <= v < 2.0.0",
"elm-lang/core": "4.0.5 <= v < 5.0.0",
"elm-lang/html": "1.1.0 <= v < 2.0.0",
"elm-lang/window": "1.0.0 <= v < 2.0.0"
"elm-community/linear-algebra": "1.0.0 <= v < 2.0.0",
"elm-community/webgl": "1.0.0 <= v < 2.0.0",
"elm-lang/animation-frame": "1.0.1 <= v < 2.0.0",
"elm-lang/core": "5.0.0 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/window": "1.0.1 <= v < 2.0.0"
},
"elm-version": "0.17.0 <= v < 0.18.0"
"elm-version": "0.18.0 <= v < 0.19.0"
}
15 changes: 11 additions & 4 deletions examples/Basic.elm
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
module Main exposing (..)

import Elmo8.Console as Console
import Elmo8.Pico8 as Pico8

type alias Model = {}

draw : Model -> List Console.Command
type alias Model =
{}


draw : Model -> List Console.Command
draw model =
[ Console.putPixel 10 10 Pico8.peach
, Console.print "Hello World" 10 50 Pico8.orange
, Console.sprite 0 60 90
]


update : Model -> Model
update model = model
update model =
model


main : Program Never
main =
Console.boot
{ draw = draw
Expand Down
29 changes: 18 additions & 11 deletions examples/HelloPico8.elm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module Main exposing (..)

{-| PICO-8 style hello world

Draws pixels in the corners, writes a message and then shows a sprite.
Expand All @@ -9,27 +11,32 @@ This uses the full PICO-8 API for all functions, which can be a little unwieldy
import Elmo8.Console as Console
import Elmo8.Pico8 as Pico8

type alias Model = {}

draw : Model -> List Console.Command
type alias Model =
{}


draw : Model -> List Console.Command
draw model =
[ Pico8.pset 0 0 Pico8.red
, Pico8.pset 127 0 Pico8.yellow
, Pico8.pset 0 127 Pico8.green
, Pico8.pset 127 127 Pico8.blue
, Pico8.print "Hello" 20 20 Pico8.orange
-- Note that Elmo8.Console's sprite is simpler
-- Note that Elmo8.Console's sprite is simpler
, Pico8.spr 0 60 30 1 1 False False
]


update : Model -> Model
update model = model
update model =
model


main : Program Never
main =
Console.boot
{ draw = draw
, init = {}
, update = update
, spritesUrl = "birdwatching.png"
}
Console.boot
{ draw = draw
, init = {}
, update = update
, spritesUrl = "birdwatching.png"
}
64 changes: 41 additions & 23 deletions examples/HelloWorld.elm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module Main exposing (..)

{-| PICO-8's Hello.lua redone in ELMO-8

Couple of differences:
Expand All @@ -7,50 +9,66 @@ Couple of differences:

import Elmo8.Console as Console

type alias Model = {
t : Int
}

type alias Model =
{ t : Int
}


init : Model
init = { t = 0 }
init =
{ t = 0 }


update : Model -> Model
update model =
{ model | t = model.t + 1 }


draw_letter : Int -> Int -> Int -> List Console.Command
draw_letter t i j0 =
let
j = 7 - j0
col = 7 + j
t1 = t + i*4 - j*2
j =
7 - j0

col =
7 + j

t1 =
t + i * 4 - j * 2

-- x = cos(t) * 5
-- PICO-8 example: cos(nil) * 5 -> 1 * 5
x = 5
y = 38 + j + cos(t1/3.5) * 5
x =
5

y =
38.0 + toFloat (j) + cos (toFloat (t1) / 3.5) * 5.0
in
[ Console.sprite (16+i) (8+i*8 + x + 2) (round y + 2)
, Console.sprite (32+i) (8+i*8 + x + 1) (round y + 1)
, Console.sprite (48+i) (8+i*8 + x) (round y)
[ Console.sprite (16 + i) (8 + i * 8 + x + 2) (round y + 2)
, Console.sprite (32 + i) (8 + i * 8 + x + 1) (round y + 1)
, Console.sprite (48 + i) (8 + i * 8 + x) (round y)
]

draw : Model -> List Console.Command

draw : Model -> List Console.Command
draw model =
[ List.map2 (\i j -> draw_letter model.t i j) [1..11] [0..10] |> List.concat
, List.map (\i -> Console.putPixel i 0 i) [0..15]
[ List.map2 (\i j -> draw_letter model.t i j) (List.range 1 11) (List.range 0 10) |> List.concat
, List.map (\i -> Console.putPixel i 0 i) (List.range 0 15)
, [ Console.sprite 1 60 100
, Console.putPixel 9 79 10
, Console.print "Welcome to ELMO-8!" 10 80 9
, Console.print "Hello World" 0 1 6
, Console.print "Ö" 60 120 5
]
] |> List.concat
]
|> List.concat


main : Program Never
main =
Console.boot
{ draw = draw
, init = init
, update = update
, spritesUrl = "hello_world.png"
}
Console.boot
{ draw = draw
, init = init
, update = update
, spritesUrl = "hello_world.png"
}
Loading