mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
examples/triangles: Fix terms
This commit is contained in:
parent
1b8cad4e1d
commit
7807488cc7
@ -43,8 +43,8 @@ func init() {
|
|||||||
var (
|
var (
|
||||||
vertices []ebiten.Vertex
|
vertices []ebiten.Vertex
|
||||||
|
|
||||||
numVerticesToDraw = 10
|
ngon = 10
|
||||||
prevNumVerticesToDraw = 0
|
prevNgon = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
func genVertices(num int) []ebiten.Vertex {
|
func genVertices(num int) []ebiten.Vertex {
|
||||||
@ -106,21 +106,21 @@ func genVertices(num int) []ebiten.Vertex {
|
|||||||
|
|
||||||
func update(screen *ebiten.Image) error {
|
func update(screen *ebiten.Image) error {
|
||||||
if inpututil.IsKeyJustPressed(ebiten.KeyLeft) {
|
if inpututil.IsKeyJustPressed(ebiten.KeyLeft) {
|
||||||
numVerticesToDraw--
|
ngon--
|
||||||
if numVerticesToDraw < 1 {
|
if ngon < 1 {
|
||||||
numVerticesToDraw = 1
|
ngon = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if inpututil.IsKeyJustPressed(ebiten.KeyRight) {
|
if inpututil.IsKeyJustPressed(ebiten.KeyRight) {
|
||||||
numVerticesToDraw++
|
ngon++
|
||||||
if numVerticesToDraw > 120 {
|
if ngon > 120 {
|
||||||
numVerticesToDraw = 120
|
ngon = 120
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if prevNumVerticesToDraw != numVerticesToDraw || len(vertices) == 0 {
|
if prevNgon != ngon || len(vertices) == 0 {
|
||||||
vertices = genVertices(numVerticesToDraw)
|
vertices = genVertices(ngon)
|
||||||
prevNumVerticesToDraw = numVerticesToDraw
|
prevNgon = ngon
|
||||||
}
|
}
|
||||||
|
|
||||||
if ebiten.IsDrawingSkipped() {
|
if ebiten.IsDrawingSkipped() {
|
||||||
@ -129,12 +129,12 @@ func update(screen *ebiten.Image) error {
|
|||||||
|
|
||||||
op := &ebiten.DrawTrianglesOptions{}
|
op := &ebiten.DrawTrianglesOptions{}
|
||||||
indices := []uint16{}
|
indices := []uint16{}
|
||||||
for i := 0; i < numVerticesToDraw; i++ {
|
for i := 0; i < ngon; i++ {
|
||||||
indices = append(indices, uint16(i), uint16(i+1)%uint16(numVerticesToDraw), uint16(numVerticesToDraw))
|
indices = append(indices, uint16(i), uint16(i+1)%uint16(ngon), uint16(ngon))
|
||||||
}
|
}
|
||||||
screen.DrawTriangles(vertices, indices, emptyImage, op)
|
screen.DrawTriangles(vertices, indices, emptyImage, op)
|
||||||
|
|
||||||
msg := fmt.Sprintf("TPS: %0.2f\nVertices: %d\nPress <- or -> to change the number of the vertices", ebiten.CurrentTPS(), numVerticesToDraw)
|
msg := fmt.Sprintf("TPS: %0.2f\n%d-gon\nPress <- or -> to change the number of the vertices", ebiten.CurrentTPS(), ngon)
|
||||||
ebitenutil.DebugPrint(screen, msg)
|
ebitenutil.DebugPrint(screen, msg)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user