mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +01:00
Create packages for games
This commit is contained in:
parent
04ecb15be2
commit
99f17c418b
@ -1,4 +1,4 @@
|
|||||||
package game
|
package rotating
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||||
@ -14,7 +14,7 @@ type RotatingImage struct {
|
|||||||
x int
|
x int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRotatingImage() *RotatingImage {
|
func New() *RotatingImage {
|
||||||
return &RotatingImage{}
|
return &RotatingImage{}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package game
|
package sprites
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||||
@ -63,7 +63,7 @@ type Sprites struct {
|
|||||||
sprites []*Sprite
|
sprites []*Sprite
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSprites() *Sprites {
|
func New() *Sprites {
|
||||||
return &Sprites{}
|
return &Sprites{}
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +16,8 @@ package main
|
|||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/go.ebiten"
|
"github.com/hajimehoshi/go.ebiten"
|
||||||
"github.com/hajimehoshi/go.ebiten/example/game"
|
"github.com/hajimehoshi/go.ebiten/example/game/rotating"
|
||||||
|
"github.com/hajimehoshi/go.ebiten/example/game/sprites"
|
||||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -81,9 +82,11 @@ func main() {
|
|||||||
var gm ebiten.Game
|
var gm ebiten.Game
|
||||||
switch gameName {
|
switch gameName {
|
||||||
case "sprites":
|
case "sprites":
|
||||||
gm = game.NewSprites()
|
gm = sprites.New()
|
||||||
|
case "rotating":
|
||||||
|
gm = rotating.New()
|
||||||
default:
|
default:
|
||||||
gm = game.NewRotatingImage()
|
gm = rotating.New()
|
||||||
}
|
}
|
||||||
|
|
||||||
screenScale := 2
|
screenScale := 2
|
||||||
|
@ -225,7 +225,7 @@ func (context *GraphicsContext) setOffscreenFramebuffer(framebuffer C.GLuint,
|
|||||||
e11 = float32(2) / float32(textureWidth)
|
e11 = float32(2) / float32(textureWidth)
|
||||||
e22 = -1 * float32(2) / float32(textureHeight)
|
e22 = -1 * float32(2) / float32(textureHeight)
|
||||||
e41 = -1
|
e41 = -1
|
||||||
e42 = -1 + height / float32(textureHeight) * 2
|
e42 = -1 + height/float32(textureHeight)*2
|
||||||
}
|
}
|
||||||
|
|
||||||
context.projectionMatrix = [...]float32{
|
context.projectionMatrix = [...]float32{
|
||||||
|
Loading…
Reference in New Issue
Block a user