game

Crystal game wrapper library for Cray (RayLib bindings to Crystal)

game

Game wrapper library internally using cray (RayLib bindings to Crystal).

Installation

  1. Add the dependency to your shard.yml:
dependencies:
  game:
    github: mswieboda/game
  1. Run shards install

Usage

For now this is basically just an object-oriented wrapper around Cray/RayLib functionality.

Eventually will include more concepts such as a Viewport, basic Player or Player Controllers, UI messages, loading/saving, and other miscelleneous concepts to assist developing a game.

See the examples examples/hello_world.cr and examples/shapes.cr on how to use the provided classes.

Inherit your main game project class from Game to enable the RayLib setup and game loop.

require "game"

class FooGame < Game
  def initialize
    super(
      name: "FooGame",
      screen_width: 1024,
      screen_height: 768
    )
  end

  def update(frame_time)
  end

  def draw
  end
end

FooGame.new.run

Game#run will initialize RayLib, and begin the game loop, calling Game#update and Game#draw which are meant to be overriden with your game and drawing logic. Use the built-in classes to draw with using #draw or call drawing methods directly with LibRay (available via the cray shard dependency).

def draw
  # use built-in classes created in `initialize` or elsewhere to draw, such as `Rectangle`
  @rectangle.draw

  # or call LibRay draw methods directly
  LibRay.draw_rectangle(x: 30, y: 30, width: 100, height: 25, color: Color::Red.to_struct)
end

Note: Since many features are currently WIP, interacting with LibRay directly is a valid option.

Development

  • API docs
  • Game (core)
    • basic window: title, size, fullscreen (moving to Window)
    • basic setup: FPS, audio
    • basic game loop: running? frame time, update, draw wrapper, draw
    • set drawing mode 2D/3D
    • specific sprite pre loading Game#load_sprites method to override
    • specific sound pre loading Game#load_sounds method to override
  • Window
    • Monitor
    • Clipboard
    • Cursor
  • Input
    • Keys
    • Mouse
    • Gamepad
    • Touch
  • Camera for 2D
    • Viewport
  • Color
  • Vectors
    • Vector
    • Vector3
  • Shapes
    • Shape parent class
      • collision detection
    • Pixel
    • Line
    • Circle
    • Ellipse
    • Ring
    • Rectangle
    • Square
    • Triangle
    • Polygon
  • Textures
    • Loading images from files
    • Loading images from code, data,
    • Loading Texture (into GPU memory) from file or image
    • Sprites
    • Animated Sprites
      • TODO:
        • reverse
        • pause/stop
  • Text
    • Loading Fonts
    • Drawing Text with Fonts
  • Sound
    • Loading Wave
    • Loading Sounds
    • Play, stop, pause, resume
    • [ ]
  • Entity (for inheriting game objects with functionality)
    • implement children/parent, generic containers
    • SpriteEntity
    • ShapeEntity
  • 3D
    • Camera
    • Model
    • Mesh
    • Shaders

Contributing

  1. Fork it (https://github.com/mswieboda/game/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

game

Owner
Statistic
  • 4
  • 0
  • 0
  • 3
  • 1
  • almost 4 years ago
  • March 18, 2020
License

MIT License

Links
Synced at

Sat, 21 Dec 2024 18:01:14 GMT

Languages