mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
doc: Update docs for Safari (#293)
This commit is contained in:
parent
a1e868b822
commit
8eba9cfc7f
@ -6,13 +6,15 @@
|
|||||||
|
|
||||||
A simple SNES-like 2D game library in Go
|
A simple SNES-like 2D game library in Go
|
||||||
|
|
||||||
* [Web browsers (Chrome and Firefox on desktops)](https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers) (powered by [GopherJS](http://gopherjs.org/))
|
* [Web browsers (Chrome, Firefox and Safari on desktops)](https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers) (powered by [GopherJS](http://gopherjs.org/))
|
||||||
* [Windows](https://github.com/hajimehoshi/ebiten/wiki/Windows)
|
* [Windows](https://github.com/hajimehoshi/ebiten/wiki/Windows)
|
||||||
* [Mac OS X](https://github.com/hajimehoshi/ebiten/wiki/Mac-OS-X)
|
* [Mac OS X](https://github.com/hajimehoshi/ebiten/wiki/Mac-OS-X)
|
||||||
* [Linux](https://github.com/hajimehoshi/ebiten/wiki/Linux)
|
* [Linux](https://github.com/hajimehoshi/ebiten/wiki/Linux)
|
||||||
* [Android](https://github.com/hajimehoshi/ebiten/wiki/Android)
|
* [Android](https://github.com/hajimehoshi/ebiten/wiki/Android)
|
||||||
* [iOS](https://github.com/hajimehoshi/ebiten/wiki/iOS)
|
* [iOS](https://github.com/hajimehoshi/ebiten/wiki/iOS)
|
||||||
|
|
||||||
|
Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* 2D Graphics (Geometry/Color matrix transformation, Various composition modes, Offscreen rendering)
|
* 2D Graphics (Geometry/Color matrix transformation, Various composition modes, Offscreen rendering)
|
||||||
|
@ -40,8 +40,9 @@
|
|||||||
<dt>Mobiles</dt>
|
<dt>Mobiles</dt>
|
||||||
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Android">Android</a>, <a href="https://github.com/hajimehoshi/ebiten/wiki/iOS">iOS</a></dd>
|
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Android">Android</a>, <a href="https://github.com/hajimehoshi/ebiten/wiki/iOS">iOS</a></dd>
|
||||||
<dt>Web browsers</dt>
|
<dt>Web browsers</dt>
|
||||||
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome and Firefox on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
|
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome, Firefox and Safari on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
<p><small>Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.</small></p>
|
||||||
|
|
||||||
<h2 id="features">Features</h2>
|
<h2 id="features">Features</h2>
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
|
@ -51,6 +51,8 @@ func (s *Stream) Size() int64 {
|
|||||||
// Decode decodes Ogg/Vorbis data to playable stream.
|
// Decode decodes Ogg/Vorbis data to playable stream.
|
||||||
//
|
//
|
||||||
// The sample rate must be same as that of audio context.
|
// The sample rate must be same as that of audio context.
|
||||||
|
//
|
||||||
|
// This function returns error on Safari.
|
||||||
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
func Decode(context *audio.Context, src audio.ReadSeekCloser) (*Stream, error) {
|
||||||
decoded, channelNum, sampleRate, err := decode(src)
|
decoded, channelNum, sampleRate, err := decode(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
BIN
docs/examples/_resources/audio/game.ogg
Normal file
BIN
docs/examples/_resources/audio/game.ogg
Normal file
Binary file not shown.
Binary file not shown.
@ -9,6 +9,14 @@ Recorded by Mike Koenig
|
|||||||
Attribution 3.0: https://creativecommons.org/licenses/by/3.0/
|
Attribution 3.0: https://creativecommons.org/licenses/by/3.0/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## game.ogg
|
||||||
|
|
||||||
|
```
|
||||||
|
http://mart.kitunebi.com/music_act.html
|
||||||
|
|
||||||
|
Harpie's Feather (ハルピュイアの羽) by Napi
|
||||||
|
```
|
||||||
|
|
||||||
## ragtime.ogg
|
## ragtime.ogg
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -257,11 +257,11 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
oggF, err := ebitenutil.OpenFile("_resources/audio/ragtime.ogg")
|
oggF, err := ebitenutil.OpenFile("_resources/audio/game.ogg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
const sampleRate = 22050
|
const sampleRate = 44100
|
||||||
const bytesPerSample = 4 // TODO: This should be defined in audio package
|
const bytesPerSample = 4 // TODO: This should be defined in audio package
|
||||||
audioContext, err = audio.NewContext(sampleRate)
|
audioContext, err = audio.NewContext(sampleRate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -51,11 +51,12 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Sprite struct {
|
type Sprite struct {
|
||||||
image *ebiten.Image
|
imageWidth int
|
||||||
x int
|
imageHeight int
|
||||||
y int
|
x int
|
||||||
vx int
|
y int
|
||||||
vy int
|
vx int
|
||||||
|
vy int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sprite) Update() {
|
func (s *Sprite) Update() {
|
||||||
@ -64,18 +65,15 @@ func (s *Sprite) Update() {
|
|||||||
if s.x < 0 {
|
if s.x < 0 {
|
||||||
s.x = -s.x
|
s.x = -s.x
|
||||||
s.vx = -s.vx
|
s.vx = -s.vx
|
||||||
|
} else if screenWidth <= s.x+s.imageWidth {
|
||||||
|
s.x = 2*(screenWidth-s.imageWidth) - s.x
|
||||||
|
s.vx = -s.vx
|
||||||
}
|
}
|
||||||
if s.y < 0 {
|
if s.y < 0 {
|
||||||
s.y = -s.y
|
s.y = -s.y
|
||||||
s.vy = -s.vy
|
s.vy = -s.vy
|
||||||
}
|
} else if screenHeight <= s.y+s.imageHeight {
|
||||||
w, h := s.image.Size()
|
s.y = 2*(screenHeight-s.imageHeight) - s.y
|
||||||
if screenWidth <= s.x+w {
|
|
||||||
s.x = 2*(screenWidth-w) - s.x
|
|
||||||
s.vx = -s.vx
|
|
||||||
}
|
|
||||||
if screenHeight <= s.y+h {
|
|
||||||
s.y = 2*(screenHeight-h) - s.y
|
|
||||||
s.vy = -s.vy
|
s.vy = -s.vy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,17 +83,17 @@ type Sprites struct {
|
|||||||
num int
|
num int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Sprites) Update() {
|
func (s *Sprites) Update() {
|
||||||
for _, sprite := range s.sprites {
|
for _, sprite := range s.sprites {
|
||||||
sprite.Update()
|
sprite.Update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Sprites) Len() int {
|
func (s *Sprites) Len() int {
|
||||||
return s.num
|
return s.num
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Sprites) Dst(i int) (x0, y0, x1, y1 int) {
|
func (s *Sprites) Dst(i int) (x0, y0, x1, y1 int) {
|
||||||
if s.num <= i {
|
if s.num <= i {
|
||||||
return 0, 0, 0, 0
|
return 0, 0, 0, 0
|
||||||
}
|
}
|
||||||
@ -103,7 +101,7 @@ func (s Sprites) Dst(i int) (x0, y0, x1, y1 int) {
|
|||||||
return ss.x, ss.y, ss.x + ebitenImageWidth, ss.y + ebitenImageHeight
|
return ss.x, ss.y, ss.x + ebitenImageWidth, ss.y + ebitenImageHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s Sprites) Src(i int) (x0, y0, x1, y1 int) {
|
func (s *Sprites) Src(i int) (x0, y0, x1, y1 int) {
|
||||||
if s.num <= i {
|
if s.num <= i {
|
||||||
return 0, 0, 0, 0
|
return 0, 0, 0, 0
|
||||||
}
|
}
|
||||||
@ -163,11 +161,12 @@ func main() {
|
|||||||
x, y := rand.Intn(screenWidth-w), rand.Intn(screenHeight-h)
|
x, y := rand.Intn(screenWidth-w), rand.Intn(screenHeight-h)
|
||||||
vx, vy := 2*rand.Intn(2)-1, 2*rand.Intn(2)-1
|
vx, vy := 2*rand.Intn(2)-1, 2*rand.Intn(2)-1
|
||||||
sprites.sprites[i] = &Sprite{
|
sprites.sprites[i] = &Sprite{
|
||||||
image: ebitenImage,
|
imageWidth: w,
|
||||||
x: x,
|
imageHeight: h,
|
||||||
y: y,
|
x: x,
|
||||||
vx: vx,
|
y: y,
|
||||||
vy: vy,
|
vx: vx,
|
||||||
|
vy: vy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Sprites (Ebiten Demo)"); err != nil {
|
if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Sprites (Ebiten Demo)"); err != nil {
|
||||||
|
@ -40,8 +40,9 @@
|
|||||||
<dt>Mobiles</dt>
|
<dt>Mobiles</dt>
|
||||||
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Android">Android</a>, <a href="https://github.com/hajimehoshi/ebiten/wiki/iOS">iOS</a></dd>
|
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Android">Android</a>, <a href="https://github.com/hajimehoshi/ebiten/wiki/iOS">iOS</a></dd>
|
||||||
<dt>Web browsers</dt>
|
<dt>Web browsers</dt>
|
||||||
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome and Firefox on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
|
<dd><a href="https://github.com/hajimehoshi/ebiten/wiki/Web-Browsers">Chrome, Firefox and Safari on desktops</a> (powered by <a href="http://gopherjs.org/">GopherJS</a>)</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
<p><small>Note: Decoding Ogg/Vorbis and gamepads aren't available on Safari.</small></p>
|
||||||
|
|
||||||
<h2 id="features">Features</h2>
|
<h2 id="features">Features</h2>
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
|
Loading…
Reference in New Issue
Block a user