Skip to content

Nimfire is GUI/game framework built on top of gl*FB and GLFW. It serves for learning purposes, but may become something bigger someday.

Notifications You must be signed in to change notification settings

Toma400/Nimfire

Repository files navigation

Nimfire (Nim Campfire) is small Nim GUI/game library inspired by PyGame and Nigui, trying to be what I haven't found yet in Nim's gamedev ecosystem.
While it is mostly my learning project, I'd love to see it becoming something bigger in the future - I will try to update is regularly, so it should not be abandoned anytime soon.

Nimfire aim is to:

  • empower control
    • you are given as much manual control as possible, including contents of main loop (inspired by PyGame)
  • minimise abstractions
    • you are not forced into any OOP system and relations, there's no object that you need inherit from or use to control your custom elements
  • have no dependencies
    • one of huge issues with Nim gamelibs is their requirement to install and/or compile many C libraries and other dependencies - Nimfire uses only static Nim libraries which makes it work out of the box
  • be simple and user-friendly
    • no unnecessary verbosity of code, we are coding Nim after all
    • well documented code, examples and possibility to learn from short examples
    • being batteries-included in terms of having GUI elements, so you don't need to write your own (it's totally possible though!)

Installation

To install the library, simply run such command in terminal:

nimble install https://github.com/Toma400/Nimfire

Usage

Initialising basic window is done using initWindow procedure. After that, you will be able to control program loop and window closing:

import nimfire

var w = initWindow((800, 600), "Nimfire")

while w.tick():
  w.update()

w.finish()

You can also draw on canvas easily:

import nimfire/colors
import nimfire/draw
import nimfire

var w = initWindow((800, 600), "Nimfire")

while w.tick():
  w.drawRect((0, 0), (250, 250), PURPLE)
  w.update()

w.finish()

You can look at examples/drawing and examples/rect_management for more detailed documentation on how you can use drawing with the library.

Aside of drawing shapes, Nimfire allows you also to use PNG images, further explained in examples/images file:

import nimfire/image
import nimfire

var w = initWindow((800, 600), "Nimfire")
var i = newImage("nimfire.png")

while w.tick():
  w.drawImage(i, (10, 10))
  w.update()
  
w.finish()

And you can also handle user input:

import nimfire/input
import nimfire

var w = initWindow((800, 600), "Nimfire")

while w.tick():
  if w.getKeyPressed(KEY.SPACE):
    echo "Space just got used!"
  w.update()
  
  if w.getMousePressed(LEFT):
    echo "Mouse coordinates are: " & w.getMousePos()
  
w.finish()

For more code examples, visit examples folder. You can also look at examples/apps for tutorial apps done step by step to showcase more abstract use of Nimfire.
Additionally, module functions are slowly documented in this Markdown file.


Features

Currently, this is Nimfire's scope:

  • Creating app and controlling window
    • Setting basic data (res, title)
    • Drawing shapes
      • Exporting shapes into graphical files
  • Input control mostly
    • Keyboard control
      • Getting keyboard key being pressed
    • Mouse control
      • Recognising mouse input
      • Getting mouse position on screen
    • Saving user input as data (listening to sequence of keys)
  • Image management simple
    • Render image on screen
    • Save images
    • JPG/SVG/BMP formats
    • More Image manipulation features
      • Resize images
      • Nesting Image type into each other
  • Text management
    • Drawing text on screen
      • Size properties
      • More advanced features (multiline text)
    • Font support
  • QoL
    • Holders for images/rects/sounds that let you access them by ID from Window
  • Sound management
    • Playing & stopping sound
    • WAV/FLAC/OGG/MP3 formats
    • Managing multiple channels (parallel sounds playing)
  • UI
    • Buttons
    • Progress bars
    • Sliders (vertical/horizontal)
    • Scrolling slider (vertical/horizontal)
    • Text fields
      • Single-row box
      • Multi-row box
    • Lists
      • Comboboxes
      • Bulletboxes
      • Listboxes
  • QoL abstractions
    • Delta clock object
    • Optional Event system

Look at changelog if you want to see details.


Note

Nimfire is learning project, and as such, may contain more bugs, performance issues and problems overall than matured library.
It is by no means stable or ready for development of games or software, and I hold no promise to maintain it if I lose my motivation and will.

That said, I really want to do as much as I can with Nimfire, so it's not like this lib will disappear soon. Just take in mind that until it becomes important utility for my own gamedev, I do it as fun side-project, with all good and bad coming with such status.


Socials

Licensing

While library code is All Rights Reserved for now (I'm quite lazy for licenses), it will be changed soon. For now you are allowed to use the library for any personal project that is not commercial in any way.

Library fonts use Open Font License which permits their use. They can be used in project of any kind, but please refer to license or your lawyer if you want to be sure.

Project made using Nimfire

🎨 Drawfire - simple drawing app

About

Nimfire is GUI/game framework built on top of gl*FB and GLFW. It serves for learning purposes, but may become something bigger someday.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages