examples/sprites: Slower increasing num of sprites

This commit is contained in:
Hajime Hoshi 2016-07-16 19:34:36 +09:00
parent 66f262c80e
commit d7c2682c53
2 changed files with 5 additions and 2 deletions

View File

@ -105,13 +105,13 @@ var sprites = &Sprites{make([]*Sprite, MaxSprites), 500}
func update(screen *ebiten.Image) error {
if ebiten.IsKeyPressed(ebiten.KeyLeft) {
sprites.num -= 100
sprites.num -= 20
if sprites.num < MinSprites {
sprites.num = MinSprites
}
}
if ebiten.IsKeyPressed(ebiten.KeyRight) {
sprites.num += 100
sprites.num += 20
if MaxSprites < sprites.num {
sprites.num = MaxSprites
}

View File

@ -58,6 +58,9 @@ func (q *commandQueue) Enqueue(command command) {
q.commands = append(q.commands, command)
}
// commandGroups separates q.commands into some groups.
// The number of quads of drawImageCommand in one groups must be equal to or less than
// its limit (maxQuads).
func (q *commandQueue) commandGroups() [][]command {
cs := make([]command, len(q.commands))
copy(cs, q.commands)