zorldo

Goofing around with Ebiten
git clone git://bsandro.tech/zorldo
Log | Files | Refs | README

doc.go (3541B)


      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 //         // Specify the window size as you like. Here, a doubled 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 (e.g.,
     54 // DeviceScaleFactor) that must be called on the main thread under some conditions (typically, before ebiten.RunGame
     55 // is called).
     56 //
     57 // Environment variables
     58 //
     59 // `EBITEN_SCREENSHOT_KEY` environment variable specifies the key
     60 // to take a screenshot. For example, if you run your game with
     61 // `EBITEN_SCREENSHOT_KEY=q`, you can take a game screen's screenshot
     62 // by pressing Q key. This works only on desktops.
     63 //
     64 // `EBITEN_INTERNAL_IMAGES_KEY` environment variable specifies the key
     65 // to dump all the internal images. This is valid only when the build tag
     66 // 'ebitendebug' is specified. This works only on desktops.
     67 //
     68 // Build tags
     69 //
     70 // `ebitendebug` outputs a log of graphics commands. This is useful to know what happens in Ebiten. In general, the
     71 // number of graphics commands affects the performance of your game.
     72 //
     73 // `ebitengl` forces to use OpenGL in any environments.
     74 //
     75 // `ebitenwebgl1` forces to use WebGL 1 on browsers.
     76 //
     77 // `ebitensinglethread` disables Ebiten's thread safety to unlock maximum performance. If you use this you will have
     78 // to manage threads yourself. Functions like IsKeyPressed will no longer be concurrent-safe with this build tag.
     79 // They must be called from the main thread or the same goroutine as the given game's callback functions like Update
     80 // to RunGame.
     81 package ebiten