Add blocks example to index.html

This commit is contained in:
Hajime Hoshi 2014-12-29 18:43:35 +09:00
parent 1c4a652a6d
commit 1e6f51ed23
6 changed files with 29 additions and 3 deletions

View File

@ -58,13 +58,30 @@ type example struct {
Name string
}
func (e *example) Width() int {
if e.Name == "blocks" {
return 256
}
return 320
}
func (e *example) Height() int {
if e.Name == "blocks" {
return 240
}
return 240
}
func (e *example) Source() string {
if e.Name == "blocks" {
return "// Please read example/blocks/main.go and example/blocks/blocks/*.go"
}
path := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "hajimehoshi", "ebiten", "example", e.Name, "main.go")
b, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
str := regexp.MustCompile("(?s)^.*?\n\n").ReplaceAllString(string(b), "")
return str
}
@ -86,6 +103,7 @@ func main() {
log.Fatal(err)
}
examples := []example{
{Name: "blocks"},
{Name: "hue"},
{Name: "mosaic"},
{Name: "perspective"},

View File

@ -48,7 +48,7 @@ table.examples td.code pre {
<td class="code"><pre><code>// <b>{{.Name}}</b>
{{.Source}}</code></pre></td>
<td><img src="{{.Name}}.gif" width="320" height="240"></td>
<td><img src="{{.Name}}.gif" width="{{.Width}}" height="{{.Height}}"></td>
</tr>
{{end}}
</table>

BIN
_docs/public/blocks.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 KiB

View File

@ -56,6 +56,13 @@ table.examples td.code pre {
<h2>Example</h2>
<table class="examples">
<tr>
<td class="code"><pre><code>// <b>blocks</b>
// Please read example/blocks/main.go and example/blocks/blocks/*.go</code></pre></td>
<td><img src="blocks.gif" width="256" height="240"></td>
</tr>
<tr>
<td class="code"><pre><code>// <b>hue</b>

View File

@ -42,7 +42,7 @@ func main() {
}
game := blocks.NewGame()
update := game.Update
update = ebitenutil.RecordScreenAsGIF(update, f, 360)
if err := ebiten.Run(update, blocks.ScreenWidth, blocks.ScreenHeight, 2, "Blocks (Ebiten Demo)"); err != nil {
log.Fatal(err)
}

View File

@ -16,6 +16,7 @@
## Example
* example/blocks - Puzzle game you know
* example/hue - Changes the hue of an image
* example/mosaic - Mosaics an image
* example/perspective - See an image in a perspective view