Update docs
@ -1,3 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
{{comment .License}}
|
||||
<script src="{{.Example.Name}}.js"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
iframe {
|
||||
border-color: #999;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 1em;
|
||||
}
|
||||
</style>
|
||||
<nav><a href="..">Ebiten</a></nav>
|
||||
{{with .Example}}
|
||||
<h1>{{.Name}}</h1>
|
||||
<iframe src="{{.Name}}.content.html" width="{{.Width}}" height="{{.Height}}"></iframe>
|
||||
<pre><code>{{.Source}}</code></pre>
|
||||
{{end}}
|
||||
|
||||
<footer>{{.Copyright}}</footer>
|
||||
|
3
_docs/examplecontent.tmpl.html
Normal file
@ -0,0 +1,3 @@
|
||||
<!DOCTYPE html>
|
||||
{{comment .License}}
|
||||
<script src="{{.Example.Name}}.js"></script>
|
104
_docs/gen.go
@ -26,6 +26,7 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var license = ""
|
||||
@ -40,6 +41,12 @@ func init() {
|
||||
// TODO: Year check
|
||||
}
|
||||
|
||||
var copyright = ""
|
||||
|
||||
func init() {
|
||||
copyright = fmt.Sprintf("© %d Hajime Hoshi", time.Now().Year())
|
||||
}
|
||||
|
||||
var stableVersion = ""
|
||||
|
||||
var devVersion = ""
|
||||
@ -73,20 +80,28 @@ type example struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func (e *example) Width() int {
|
||||
func (e *example) ThumbWidth() int {
|
||||
if e.Name == "blocks" {
|
||||
return 256
|
||||
}
|
||||
return 320
|
||||
}
|
||||
|
||||
func (e *example) Height() int {
|
||||
func (e *example) ThumbHeight() int {
|
||||
if e.Name == "blocks" {
|
||||
return 240
|
||||
}
|
||||
return 240
|
||||
}
|
||||
|
||||
func (e *example) Width() int {
|
||||
return e.ThumbWidth() * 2
|
||||
}
|
||||
|
||||
func (e *example) Height() int {
|
||||
return e.ThumbHeight() * 2
|
||||
}
|
||||
|
||||
func (e *example) Source() string {
|
||||
if e.Name == "blocks" {
|
||||
return "// Please read example/blocks/main.go and example/blocks/blocks/*.go"
|
||||
@ -107,15 +122,39 @@ func versions() string {
|
||||
}
|
||||
|
||||
var examples = []example{
|
||||
{Name: "blocks"},
|
||||
{Name: "hue"},
|
||||
{Name: "keyboard"},
|
||||
{Name: "mosaic"},
|
||||
{Name: "perspective"},
|
||||
{Name: "rotate"},
|
||||
{Name: "blocks"},
|
||||
}
|
||||
|
||||
func clear() error {
|
||||
// TODO: favicon?
|
||||
if err := filepath.Walk("public", func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Remove auto-generated html files.
|
||||
m, err := regexp.MatchString(".html$", path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !m {
|
||||
return nil
|
||||
}
|
||||
// Remove example resources that are copied.
|
||||
m, err = regexp.MatchString("public/example/images", path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !m {
|
||||
return nil
|
||||
}
|
||||
return os.Remove(path)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -139,6 +178,7 @@ func outputMain() error {
|
||||
|
||||
data := map[string]interface{}{
|
||||
"License": license,
|
||||
"Copyright": copyright,
|
||||
"StableVersion": stableVersion,
|
||||
"DevVersion": devVersion,
|
||||
"Examples": examples,
|
||||
@ -146,6 +186,46 @@ func outputMain() error {
|
||||
return t.Funcs(funcs).Execute(f, data)
|
||||
}
|
||||
|
||||
func outputExampleContent(e *example) error {
|
||||
const dir = "public/example"
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
f, err := os.Create(filepath.Join(dir, e.Name+".content.html"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
funcs := template.FuncMap{
|
||||
"comment": comment,
|
||||
"safeHTML": safeHTML,
|
||||
}
|
||||
const templatePath = "examplecontent.tmpl.html"
|
||||
name := filepath.Base(templatePath)
|
||||
t, err := template.New(name).Funcs(funcs).ParseFiles(templatePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"License": license,
|
||||
"Copyright": copyright,
|
||||
"Example": e,
|
||||
}
|
||||
if err := t.Funcs(funcs).Execute(f, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out := filepath.Join(dir, e.Name+".js")
|
||||
path := "github.com/hajimehoshi/ebiten/example/" + e.Name
|
||||
if err := exec.Command("gopherjs", "build", "-m", "-o", out, path).Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func outputExample(e *example) error {
|
||||
const dir = "public/example"
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
@ -170,19 +250,10 @@ func outputExample(e *example) error {
|
||||
|
||||
data := map[string]interface{}{
|
||||
"License": license,
|
||||
"Copyright": copyright,
|
||||
"Example": e,
|
||||
}
|
||||
if err := t.Funcs(funcs).Execute(f, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out := filepath.Join(dir, e.Name+".js")
|
||||
path := "github.com/hajimehoshi/ebiten/example/" + e.Name
|
||||
if err := exec.Command("gopherjs", "build", "-m", "-o", out, path).Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return t.Funcs(funcs).Execute(f, data)
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -193,6 +264,9 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
for _, e := range examples {
|
||||
if err := outputExampleContent(&e); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := outputExample(&e); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -7,27 +7,11 @@
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table.examples {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 1em;
|
||||
}
|
||||
table.examples td {
|
||||
padding: 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
table.examples td.code pre {
|
||||
height: 240px;
|
||||
margin: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
table.examples td.screen {
|
||||
padding-left: 1em;
|
||||
}
|
||||
table.examples iframe, table.examples img {
|
||||
img.example {
|
||||
background-color: #000;
|
||||
border-color: #999;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
pre {
|
||||
background: #eee;
|
||||
@ -61,20 +45,11 @@ pre {
|
||||
</ul>
|
||||
|
||||
<h2>Example</h2>
|
||||
<table class="examples">
|
||||
<p>
|
||||
{{range .Examples}}
|
||||
<tr>
|
||||
<td class="code"><pre><code>// <b>{{.Name}}</b>
|
||||
|
||||
{{.Source}}</code></pre></td>
|
||||
{{if eq .Name "blocks"}}
|
||||
<td class="screen">Click to play!<br><a href="example/blocks.html"><img src="blocks.png" width="{{.Width}}" height="{{.Height}}"></a></td>
|
||||
{{else}}
|
||||
<td class="screen"><iframe src="example/{{.Name}}.html" width="{{.Width}}" height="{{.Height}}"></iframe></td>
|
||||
<a href="example/{{.Name}}.html"><img src="images/example/{{.Name}}.png" width="{{.ThumbWidth}}" height="{{.ThumbHeight}}" alt="Ebiten example: {{.Name}}" class="example"></a>
|
||||
{{end}}
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<h2>Install on Mac OS X</h2>
|
||||
<pre><code>:; brew install glew
|
||||
@ -88,19 +63,16 @@ pre {
|
||||
<pre><code>:; cd $GOHOME/src/github.com/hajimehoshi/ebiten/example
|
||||
:; go run rotate/main.go</code></pre>
|
||||
|
||||
<h2>Execute the example on a web browser</h2>
|
||||
<p>If you can the example screens above, Ebiten is working on your browser! Each example above works as an independent html in an iframe. If you want to execute the examples apart from this site, execute this:</p>
|
||||
<pre><code>:; go run $GOPATH/src/github.com/hajimehoshi/ebiten/example/server/main.go</code></pre>
|
||||
<p>Then, open <code>localhost:8000</code> on your browser.</p>
|
||||
<p><code>localhost:8000/?EXAMPLE_NAME</code> shows other examples (e.g. <code>localhost:8000/?rotate</code>).</p>
|
||||
<p>Of cource, you can execute gopherjs yourself. Please see <a href="http://gopherjs.org/">GopherJS site</a> for more detail.</p>
|
||||
<h2>Run your game on a desktop</h2>
|
||||
<p>Just execute your Go program. That's it!</p>
|
||||
|
||||
<h2>Run your game on a web browser</h2>
|
||||
<p>Compile your game with GopherJS:</p>
|
||||
<p>Compile your game with <a href="http://gopherjs.org/">GopherJS</a>:</p>
|
||||
<pre><code>:; gopherjs build -o yourgame.js path/to/yourgame</code></pre>
|
||||
<p>Then, open the below HTML on your HTTP server:</p>
|
||||
<pre><code><!DOCTYPE html>
|
||||
<script src="yourgame.js"></script></code></pre>
|
||||
<p>NOTE: <code>file://</code> URL may not work with Ebiten. Execute your game on a HTTP server.</p>
|
||||
|
||||
<h2>Change Log</h2>
|
||||
<h3>2015-??-??</h3>
|
||||
@ -137,3 +109,5 @@ pre {
|
||||
<pre>{{.License}}</pre>
|
||||
<h3>Go Gopher photograph</h3>
|
||||
<p><a href="http://blog.golang.org/go-programming-language-turns-two">The original photograph of Go gophers by Chris Nokleberg</a> is licensed under the Creative Commons 3.0 Attributions license.</p>
|
||||
|
||||
<footer>{{.Copyright}}</footer>
|
||||
|
18
_docs/public/example/blocks.content.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2015 Hajime Hoshi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="blocks.js"></script>
|
@ -15,4 +15,26 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="blocks.js"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
iframe {
|
||||
border-color: #999;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 1em;
|
||||
}
|
||||
</style>
|
||||
<nav><a href="..">Ebiten</a></nav>
|
||||
|
||||
<h1>blocks</h1>
|
||||
<iframe src="blocks.content.html" width="512" height="480"></iframe>
|
||||
<pre><code>// Please read example/blocks/main.go and example/blocks/blocks/*.go</code></pre>
|
||||
|
||||
|
||||
<footer>© 2015 Hajime Hoshi</footer>
|
||||
|
18
_docs/public/example/hue.content.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2015 Hajime Hoshi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="hue.js"></script>
|
@ -15,4 +15,68 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="hue.js"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
iframe {
|
||||
border-color: #999;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 1em;
|
||||
}
|
||||
</style>
|
||||
<nav><a href="..">Ebiten</a></nav>
|
||||
|
||||
<h1>hue</h1>
|
||||
<iframe src="hue.content.html" width="640" height="480"></iframe>
|
||||
<pre><code>package main
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
"math"
|
||||
)
|
||||
|
||||
const (
|
||||
screenWidth = 320
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
var (
|
||||
count int
|
||||
gophersImage *ebiten.Image
|
||||
)
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
count++
|
||||
w, h := gophersImage.Size()
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(float64(screenWidth-w)/2, float64(screenHeight-h)/2)
|
||||
op.ColorM.Concat(ebiten.RotateHue(float64(count%360) * 2 * math.Pi / 360))
|
||||
if err := screen.DrawImage(gophersImage, op); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Hue (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
<footer>© 2015 Hajime Hoshi</footer>
|
||||
|
18
_docs/public/example/keyboard.content.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2015 Hajime Hoshi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="keyboard.js"></script>
|
113
_docs/public/example/keyboard.html
Normal file
@ -0,0 +1,113 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2015 Hajime Hoshi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
iframe {
|
||||
border-color: #999;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 1em;
|
||||
}
|
||||
</style>
|
||||
<nav><a href="..">Ebiten</a></nav>
|
||||
|
||||
<h1>keyboard</h1>
|
||||
<iframe src="keyboard.content.html" width="640" height="480"></iframe>
|
||||
<pre><code>package main
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
"log"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
screenWidth = 320
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
// TODO: Add Key.String() by stringer
|
||||
|
||||
var keyNames = map[ebiten.Key]string{
|
||||
ebiten.KeyBackspace: "Backspace",
|
||||
ebiten.KeyComma: "','",
|
||||
ebiten.KeyDelete: "Delete",
|
||||
ebiten.KeyEnter: "Enter",
|
||||
ebiten.KeyEscape: "Esc",
|
||||
ebiten.KeyPeriod: "'.'",
|
||||
ebiten.KeySpace: "Space",
|
||||
ebiten.KeyTab: "Tab",
|
||||
|
||||
// Arrows
|
||||
ebiten.KeyDown: "Down",
|
||||
ebiten.KeyLeft: "Left",
|
||||
ebiten.KeyRight: "Right",
|
||||
ebiten.KeyUp: "Up",
|
||||
|
||||
// Mods
|
||||
ebiten.KeyShift: "Shift",
|
||||
ebiten.KeyControl: "Ctrl",
|
||||
ebiten.KeyAlt: "Alt",
|
||||
}
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
pressed := []string{}
|
||||
for i := 0; i <= 9; i++ {
|
||||
if ebiten.IsKeyPressed(ebiten.Key(i) + ebiten.Key0) {
|
||||
pressed = append(pressed, string(i+'0'))
|
||||
}
|
||||
}
|
||||
for c := 'A'; c <= 'Z'; c++ {
|
||||
if ebiten.IsKeyPressed(ebiten.Key(c) - 'A' + ebiten.KeyA) {
|
||||
pressed = append(pressed, string(c))
|
||||
}
|
||||
}
|
||||
for i := 1; i <= 12; i++ {
|
||||
if ebiten.IsKeyPressed(ebiten.Key(i) + ebiten.KeyF1 - 1) {
|
||||
pressed = append(pressed, "F"+strconv.Itoa(i))
|
||||
}
|
||||
}
|
||||
for key, name := range keyNames {
|
||||
if ebiten.IsKeyPressed(key) {
|
||||
pressed = append(pressed, name)
|
||||
}
|
||||
}
|
||||
sort.Strings(pressed)
|
||||
str := "Pressed Keys: " + strings.Join(pressed, ", ")
|
||||
ebitenutil.DebugPrint(screen, str)
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Keyboard (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
<footer>© 2015 Hajime Hoshi</footer>
|
56
_docs/public/example/keyboard.js
Normal file
1
_docs/public/example/keyboard.js.map
Normal file
18
_docs/public/example/mosaic.content.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2015 Hajime Hoshi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="mosaic.js"></script>
|
@ -15,4 +15,72 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="mosaic.js"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
iframe {
|
||||
border-color: #999;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 1em;
|
||||
}
|
||||
</style>
|
||||
<nav><a href="..">Ebiten</a></nav>
|
||||
|
||||
<h1>mosaic</h1>
|
||||
<iframe src="mosaic.content.html" width="640" height="480"></iframe>
|
||||
<pre><code>package main
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
)
|
||||
|
||||
const (
|
||||
screenWidth = 320
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
const mosaicRatio = 16
|
||||
|
||||
var (
|
||||
gophersImage *ebiten.Image
|
||||
gophersRenderTarget *ebiten.Image
|
||||
)
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Scale(1.0/mosaicRatio, 1.0/mosaicRatio)
|
||||
gophersRenderTarget.DrawImage(gophersImage, op)
|
||||
op = &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Scale(mosaicRatio, mosaicRatio)
|
||||
screen.DrawImage(gophersRenderTarget, op)
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
w, h := gophersImage.Size()
|
||||
gophersRenderTarget, err = ebiten.NewImage(w/mosaicRatio, h/mosaicRatio, ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Mosaic (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
<footer>© 2015 Hajime Hoshi</footer>
|
||||
|
18
_docs/public/example/perspective.content.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2015 Hajime Hoshi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="perspective.js"></script>
|
@ -15,4 +15,87 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="perspective.js"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
iframe {
|
||||
border-color: #999;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 1em;
|
||||
}
|
||||
</style>
|
||||
<nav><a href="..">Ebiten</a></nav>
|
||||
|
||||
<h1>perspective</h1>
|
||||
<iframe src="perspective.content.html" width="640" height="480"></iframe>
|
||||
<pre><code>package main
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
)
|
||||
|
||||
const (
|
||||
screenWidth = 320
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
var (
|
||||
gophersImage *ebiten.Image
|
||||
)
|
||||
|
||||
type parts struct {
|
||||
image *ebiten.Image
|
||||
}
|
||||
|
||||
func (p parts) Len() int {
|
||||
_, h := p.image.Size()
|
||||
return h
|
||||
}
|
||||
|
||||
func (p parts) Dst(i int) (x0, y0, x1, y1 int) {
|
||||
w, h := p.image.Size()
|
||||
width := w + i*3/4
|
||||
x := ((h - i) * 3 / 4) / 2
|
||||
return x, i, x + width, i + 1
|
||||
}
|
||||
|
||||
func (p parts) Src(i int) (x0, y0, x1, y1 int) {
|
||||
w, _ := p.image.Size()
|
||||
return 0, i, w, i + 1
|
||||
}
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
op := &ebiten.DrawImageOptions{
|
||||
ImageParts: &parts{gophersImage},
|
||||
}
|
||||
w, h := gophersImage.Size()
|
||||
maxWidth := float64(w) + float64(h)*0.75
|
||||
op.GeoM.Translate(-maxWidth/2, -float64(h)/2)
|
||||
op.GeoM.Translate(screenWidth/2, screenHeight/2)
|
||||
screen.DrawImage(gophersImage, op)
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Perspective (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
<footer>© 2015 Hajime Hoshi</footer>
|
||||
|
18
_docs/public/example/rotate.content.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2015 Hajime Hoshi
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="rotate.js"></script>
|
@ -15,4 +15,69 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
<script src="rotate.js"></script>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
iframe {
|
||||
border-color: #999;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
pre {
|
||||
background: #eee;
|
||||
padding: 1em;
|
||||
}
|
||||
</style>
|
||||
<nav><a href="..">Ebiten</a></nav>
|
||||
|
||||
<h1>rotate</h1>
|
||||
<iframe src="rotate.content.html" width="640" height="480"></iframe>
|
||||
<pre><code>package main
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
"math"
|
||||
)
|
||||
|
||||
const (
|
||||
screenWidth = 320
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
var (
|
||||
count int
|
||||
gophersImage *ebiten.Image
|
||||
)
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
count++
|
||||
w, h := gophersImage.Size()
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(-float64(w)/2, -float64(h)/2)
|
||||
op.GeoM.Rotate(float64(count%360) * 2 * math.Pi / 360)
|
||||
op.GeoM.Translate(screenWidth/2, screenHeight/2)
|
||||
if err := screen.DrawImage(gophersImage, op); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Rotate (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
|
||||
<footer>© 2015 Hajime Hoshi</footer>
|
||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
BIN
_docs/public/images/example/hue.png
Normal file
After Width: | Height: | Size: 76 KiB |
BIN
_docs/public/images/example/keyboard.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
_docs/public/images/example/mosaic.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
_docs/public/images/example/perspective.png
Normal file
After Width: | Height: | Size: 87 KiB |
BIN
_docs/public/images/example/rotate.png
Normal file
After Width: | Height: | Size: 87 KiB |
@ -22,27 +22,11 @@ limitations under the License.
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table.examples {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 1em;
|
||||
}
|
||||
table.examples td {
|
||||
padding: 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
table.examples td.code pre {
|
||||
height: 240px;
|
||||
margin: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
table.examples td.screen {
|
||||
padding-left: 1em;
|
||||
}
|
||||
table.examples iframe, table.examples img {
|
||||
img.example {
|
||||
background-color: #000;
|
||||
border-color: #999;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
pre {
|
||||
background: #eee;
|
||||
@ -56,6 +40,10 @@ pre {
|
||||
<li>Works on
|
||||
<ul>
|
||||
<li>Web browsers (powered by <a href="http://gopherjs.org/">GopherJS</a>)
|
||||
<ul>
|
||||
<li>Supported browsers: Chrome, Firefox, Safari on desktops</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Mac OS X</li>
|
||||
<li>Linux (maybe)</li>
|
||||
<li>Windows (possibly)</li>
|
||||
@ -72,246 +60,21 @@ pre {
|
||||
</ul>
|
||||
|
||||
<h2>Example</h2>
|
||||
<table class="examples">
|
||||
<p>
|
||||
|
||||
<tr>
|
||||
<td class="code"><pre><code>// <b>blocks</b>
|
||||
<a href="example/hue.html"><img src="images/example/hue.png" width="320" height="240" alt="Ebiten example: hue" class="example"></a>
|
||||
|
||||
// Please read example/blocks/main.go and example/blocks/blocks/*.go</code></pre></td>
|
||||
<a href="example/keyboard.html"><img src="images/example/keyboard.png" width="320" height="240" alt="Ebiten example: keyboard" class="example"></a>
|
||||
|
||||
<td class="screen">Click to play!<br><a href="example/blocks.html"><img src="blocks.png" width="256" height="240"></a></td>
|
||||
<a href="example/mosaic.html"><img src="images/example/mosaic.png" width="320" height="240" alt="Ebiten example: mosaic" class="example"></a>
|
||||
|
||||
</tr>
|
||||
<a href="example/perspective.html"><img src="images/example/perspective.png" width="320" height="240" alt="Ebiten example: perspective" class="example"></a>
|
||||
|
||||
<tr>
|
||||
<td class="code"><pre><code>// <b>hue</b>
|
||||
<a href="example/rotate.html"><img src="images/example/rotate.png" width="320" height="240" alt="Ebiten example: rotate" class="example"></a>
|
||||
|
||||
package main
|
||||
<a href="example/blocks.html"><img src="images/example/blocks.png" width="256" height="240" alt="Ebiten example: blocks" class="example"></a>
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
"math"
|
||||
)
|
||||
|
||||
const (
|
||||
screenWidth = 320
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
var (
|
||||
count int
|
||||
gophersImage *ebiten.Image
|
||||
)
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
count++
|
||||
w, h := gophersImage.Size()
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(float64(screenWidth-w)/2, float64(screenHeight-h)/2)
|
||||
op.ColorM.Concat(ebiten.RotateHue(float64(count%360) * 2 * math.Pi / 360))
|
||||
if err := screen.DrawImage(gophersImage, op); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Hue (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
</code></pre></td>
|
||||
|
||||
<td class="screen"><iframe src="example/hue.html" width="320" height="240"></iframe></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="code"><pre><code>// <b>mosaic</b>
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
)
|
||||
|
||||
const (
|
||||
screenWidth = 320
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
const mosaicRatio = 16
|
||||
|
||||
var (
|
||||
gophersImage *ebiten.Image
|
||||
gophersRenderTarget *ebiten.Image
|
||||
)
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Scale(1.0/mosaicRatio, 1.0/mosaicRatio)
|
||||
gophersRenderTarget.DrawImage(gophersImage, op)
|
||||
op = &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Scale(mosaicRatio, mosaicRatio)
|
||||
screen.DrawImage(gophersRenderTarget, op)
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
w, h := gophersImage.Size()
|
||||
gophersRenderTarget, err = ebiten.NewImage(w/mosaicRatio, h/mosaicRatio, ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Mosaic (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
</code></pre></td>
|
||||
|
||||
<td class="screen"><iframe src="example/mosaic.html" width="320" height="240"></iframe></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="code"><pre><code>// <b>perspective</b>
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
)
|
||||
|
||||
const (
|
||||
screenWidth = 320
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
var (
|
||||
gophersImage *ebiten.Image
|
||||
)
|
||||
|
||||
type parts struct {
|
||||
image *ebiten.Image
|
||||
}
|
||||
|
||||
func (p parts) Len() int {
|
||||
_, h := p.image.Size()
|
||||
return h
|
||||
}
|
||||
|
||||
func (p parts) Dst(i int) (x0, y0, x1, y1 int) {
|
||||
w, h := p.image.Size()
|
||||
width := w + i*3/4
|
||||
x := ((h - i) * 3 / 4) / 2
|
||||
return x, i, x + width, i + 1
|
||||
}
|
||||
|
||||
func (p parts) Src(i int) (x0, y0, x1, y1 int) {
|
||||
w, _ := p.image.Size()
|
||||
return 0, i, w, i + 1
|
||||
}
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
op := &ebiten.DrawImageOptions{
|
||||
ImageParts: &parts{gophersImage},
|
||||
}
|
||||
w, h := gophersImage.Size()
|
||||
maxWidth := float64(w) + float64(h)*0.75
|
||||
op.GeoM.Translate(-maxWidth/2, -float64(h)/2)
|
||||
op.GeoM.Translate(screenWidth/2, screenHeight/2)
|
||||
screen.DrawImage(gophersImage, op)
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Perspective (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
</code></pre></td>
|
||||
|
||||
<td class="screen"><iframe src="example/perspective.html" width="320" height="240"></iframe></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="code"><pre><code>// <b>rotate</b>
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
"github.com/hajimehoshi/ebiten/ebitenutil"
|
||||
_ "image/jpeg"
|
||||
"log"
|
||||
"math"
|
||||
)
|
||||
|
||||
const (
|
||||
screenWidth = 320
|
||||
screenHeight = 240
|
||||
)
|
||||
|
||||
var (
|
||||
count int
|
||||
gophersImage *ebiten.Image
|
||||
)
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
count++
|
||||
w, h := gophersImage.Size()
|
||||
op := &ebiten.DrawImageOptions{}
|
||||
op.GeoM.Translate(-float64(w)/2, -float64(h)/2)
|
||||
op.GeoM.Rotate(float64(count%360) * 2 * math.Pi / 360)
|
||||
op.GeoM.Translate(screenWidth/2, screenHeight/2)
|
||||
if err := screen.DrawImage(gophersImage, op); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
gophersImage, _, err = ebitenutil.NewImageFromFile("images/gophers.jpg", ebiten.FilterNearest)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Rotate (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
</code></pre></td>
|
||||
|
||||
<td class="screen"><iframe src="example/rotate.html" width="320" height="240"></iframe></td>
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</p>
|
||||
|
||||
<h2>Install on Mac OS X</h2>
|
||||
<pre><code>:; brew install glew
|
||||
@ -325,19 +88,16 @@ func main() {
|
||||
<pre><code>:; cd $GOHOME/src/github.com/hajimehoshi/ebiten/example
|
||||
:; go run rotate/main.go</code></pre>
|
||||
|
||||
<h2>Execute the example on a web browser</h2>
|
||||
<p>If you can the example screens above, Ebiten is working on your browser! Each example above works as an independent html in an iframe. If you want to execute the examples apart from this site, execute this:</p>
|
||||
<pre><code>:; go run $GOPATH/src/github.com/hajimehoshi/ebiten/example/server/main.go</code></pre>
|
||||
<p>Then, open <code>localhost:8000</code> on your browser.</p>
|
||||
<p><code>localhost:8000/?EXAMPLE_NAME</code> shows other examples (e.g. <code>localhost:8000/?rotate</code>).</p>
|
||||
<p>Of cource, you can execute gopherjs yourself. Please see <a href="http://gopherjs.org/">GopherJS site</a> for more detail.</p>
|
||||
<h2>Run your game on a desktop</h2>
|
||||
<p>Just execute your Go program. That's it!</p>
|
||||
|
||||
<h2>Run your game on a web browser</h2>
|
||||
<p>Compile your game with GopherJS:</p>
|
||||
<p>Compile your game with <a href="http://gopherjs.org/">GopherJS</a>:</p>
|
||||
<pre><code>:; gopherjs build -o yourgame.js path/to/yourgame</code></pre>
|
||||
<p>Then, open the below HTML on your HTTP server:</p>
|
||||
<pre><code><!DOCTYPE html>
|
||||
<script src="yourgame.js"></script></code></pre>
|
||||
<p>NOTE: <code>file://</code> URL may not work with Ebiten. Execute your game on a HTTP server.</p>
|
||||
|
||||
<h2>Change Log</h2>
|
||||
<h3>2015-??-??</h3>
|
||||
@ -352,6 +112,7 @@ func main() {
|
||||
<li>A lot of keyboard keys have been added. KeyMax and MouseButtonMax were removed.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>The game is stopped when the window is not active.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
@ -386,3 +147,5 @@ limitations under the License.
|
||||
</pre>
|
||||
<h3>Go Gopher photograph</h3>
|
||||
<p><a href="http://blog.golang.org/go-programming-language-turns-two">The original photograph of Go gophers by Chris Nokleberg</a> is licensed under the Creative Commons 3.0 Attributions license.</p>
|
||||
|
||||
<footer>© 2015 Hajime Hoshi</footer>
|
||||
|
@ -50,7 +50,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Hue (Ebiten Demo)"); err != nil {
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Hue (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Mosaic (Ebiten Demo)"); err != nil {
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Mosaic (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Perspective (Ebiten Demo)"); err != nil {
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Perspective (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 1, "Rotate (Ebiten Demo)"); err != nil {
|
||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Rotate (Ebiten Demo)"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,7 @@ var canvas js.Object
|
||||
var context *opengl.Context
|
||||
|
||||
func shown() bool {
|
||||
w := js.Global.Get("window").Get("top")
|
||||
return !w.Get("document").Get("hidden").Bool()
|
||||
return !js.Global.Get("document").Get("hidden").Bool()
|
||||
}
|
||||
|
||||
func Use(f func(*opengl.Context)) {
|
||||
|