mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02:02 +01:00
Add blocks example to index.html
This commit is contained in:
parent
1c4a652a6d
commit
1e6f51ed23
20
_docs/gen.go
20
_docs/gen.go
@ -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"},
|
||||
|
@ -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
BIN
_docs/public/blocks.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 424 KiB |
@ -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>
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user