doc.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. // Package ebiten provides graphics and input API to develop a 2D game.
  15. //
  16. // You can start the game by calling the function RunGame.
  17. //
  18. // // Game implements ebiten.Game interface.
  19. // type Game struct{}
  20. //
  21. // // Update proceeds the game state.
  22. // // Update is called every tick (1/60 [s] by default).
  23. // func (g *Game) Update() error {
  24. // // Write your game's logical update.
  25. // return nil
  26. // }
  27. //
  28. // // Draw draws the game screen.
  29. // // Draw is called every frame (typically 1/60[s] for 60Hz display).
  30. // func (g *Game) Draw(screen *ebiten.Image) {
  31. // // Write your game's rendering.
  32. // }
  33. //
  34. // // Layout takes the outside size (e.g., the window size) and returns the (logical) screen size.
  35. // // If you don't have to adjust the screen size with the outside size, just return a fixed size.
  36. // func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
  37. // return 320, 240
  38. // }
  39. //
  40. // func main() {
  41. // game := &Game{}
  42. // // Specify the window size as you like. Here, a doubled size is specified.
  43. // ebiten.SetWindowSize(640, 480)
  44. // ebiten.SetWindowTitle("Your game's title")
  45. // // Call ebiten.RunGame to start your game loop.
  46. // if err := ebiten.RunGame(game); err != nil {
  47. // log.Fatal(err)
  48. // }
  49. // }
  50. //
  51. // In the API document, 'the main thread' means the goroutine in init(), main() and their callees without 'go'
  52. // statement. It is assured that 'the main thread' runs on the OS main thread. There are some Ebiten functions (e.g.,
  53. // DeviceScaleFactor) that must be called on the main thread under some conditions (typically, before ebiten.RunGame
  54. // 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. //
  74. // `ebitenwebgl1` forces to use WebGL 1 on browsers.
  75. //
  76. // `ebitensinglethread` disables Ebiten's thread safety to unlock maximum performance. If you use this you will have
  77. // to manage threads yourself. Functions like IsKeyPressed will no longer be concurrent-safe with this build tag.
  78. // They must be called from the main thread or the same goroutine as the given game's callback functions like Update
  79. // to RunGame.
  80. package ebiten