mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 02:42: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
|
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 {
|
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")
|
path := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "hajimehoshi", "ebiten", "example", e.Name, "main.go")
|
||||||
b, err := ioutil.ReadFile(path)
|
b, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
str := regexp.MustCompile("(?s)^.*?\n\n").ReplaceAllString(string(b), "")
|
str := regexp.MustCompile("(?s)^.*?\n\n").ReplaceAllString(string(b), "")
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
@ -86,6 +103,7 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
examples := []example{
|
examples := []example{
|
||||||
|
{Name: "blocks"},
|
||||||
{Name: "hue"},
|
{Name: "hue"},
|
||||||
{Name: "mosaic"},
|
{Name: "mosaic"},
|
||||||
{Name: "perspective"},
|
{Name: "perspective"},
|
||||||
|
@ -48,7 +48,7 @@ table.examples td.code pre {
|
|||||||
<td class="code"><pre><code>// <b>{{.Name}}</b>
|
<td class="code"><pre><code>// <b>{{.Name}}</b>
|
||||||
|
|
||||||
{{.Source}}</code></pre></td>
|
{{.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>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</table>
|
</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>
|
<h2>Example</h2>
|
||||||
<table class="examples">
|
<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>
|
<tr>
|
||||||
<td class="code"><pre><code>// <b>hue</b>
|
<td class="code"><pre><code>// <b>hue</b>
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
game := blocks.NewGame()
|
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 {
|
if err := ebiten.Run(update, blocks.ScreenWidth, blocks.ScreenHeight, 2, "Blocks (Ebiten Demo)"); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
* example/blocks - Puzzle game you know
|
||||||
* example/hue - Changes the hue of an image
|
* example/hue - Changes the hue of an image
|
||||||
* example/mosaic - Mosaics an image
|
* example/mosaic - Mosaics an image
|
||||||
* example/perspective - See an image in a perspective view
|
* example/perspective - See an image in a perspective view
|
||||||
|
Loading…
Reference in New Issue
Block a user