doc.go (3090B)
1 // Copyright 2014 Hajime Hoshi 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package ebiten provides graphics and input API to develop a 2D game. 16 // 17 // You can start the game by calling the function RunGame. 18 // 19 // // Game implements ebiten.Game interface. 20 // type Game struct{} 21 // 22 // // Update proceeds the game state. 23 // // Update is called every tick (1/60 [s] by default). 24 // func (g *Game) Update() error { 25 // // Write your game's logical update. 26 // return nil 27 // } 28 // 29 // // Draw draws the game screen. 30 // // Draw is called every frame (typically 1/60[s] for 60Hz display). 31 // func (g *Game) Draw(screen *ebiten.Image) { 32 // // Write your game's rendering. 33 // } 34 // 35 // // Layout takes the outside size (e.g., the window size) and returns the (logical) screen size. 36 // // If you don't have to adjust the screen size with the outside size, just return a fixed size. 37 // func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) { 38 // return 320, 240 39 // } 40 // 41 // func main() { 42 // game := &Game{} 43 // // Sepcify the window size as you like. Here, a doulbed size is specified. 44 // ebiten.SetWindowSize(640, 480) 45 // ebiten.SetWindowTitle("Your game's title") 46 // // Call ebiten.RunGame to start your game loop. 47 // if err := ebiten.RunGame(game); err != nil { 48 // log.Fatal(err) 49 // } 50 // } 51 // 52 // In the API document, 'the main thread' means the goroutine in init(), main() and their callees without 'go' 53 // statement. It is assured that 'the main thread' runs on the OS main thread. There are some Ebiten functions that 54 // must be called on the main thread under some conditions (typically, before ebiten.RunGame is called). 55 // 56 // Environment variables 57 // 58 // `EBITEN_SCREENSHOT_KEY` environment variable specifies the key 59 // to take a screenshot. For example, if you run your game with 60 // `EBITEN_SCREENSHOT_KEY=q`, you can take a game screen's screenshot 61 // by pressing Q key. This works only on desktops. 62 // 63 // `EBITEN_INTERNAL_IMAGES_KEY` environment variable specifies the key 64 // to dump all the internal images. This is valid only when the build tag 65 // 'ebitendebug' is specified. This works only on desktops. 66 // 67 // Build tags 68 // 69 // `ebitendebug` outputs a log of graphics commands. This is useful to know what happens in Ebiten. In general, the 70 // number of graphics commands affects the performance of your game. 71 // 72 // `ebitengl` forces to use OpenGL in any environments. 73 package ebiten