tophat
Tophat is a friendly game library for making 2d games with umka.
screenshots
examples
Rectangle you can control with arrows:
import ("th.um"; "rect.um"; "input.um"; "canvas.um"; "window.um")
fn main() {
const speed = 100
window.setup("my game", 400, 400)
window.setViewport(th.Vf2{200, 200})
pos := th.Vf2{100, 100}
for window.cycle(cam) {
var change: th.Vf2
// Handle input
if input.isPressed(input.key_left) { change.x -= 1 }
if input.isPressed(input.key_right) { change.x += 1 }
if input.isPressed(input.key_up) { change.y -= 1 }
if input.isPressed(input.key_down) { change.y += 1 }
// Apply movement
pos = pos.add(change.norm().mulf(speed * th.delta / 1000.0))
// Draw!
canvas.drawRect(th.green, rect.mk(pos.x, pos.y, 10, 10))
}
}
Draw image:
import ("window.um"; "image.um"; "th.um")
fn main() {
window.setup("image drawing", 400, 400)
img := image.load("my-image.png")
for window.cycle() {
img.draw(th.mkTransform(th.Vf2{ 0, 0 }))
}
}
You can browse more examples in the examples/ directory.
acknowledgements
People who made a library used by tophat:
- Vasiliy Tereshkov for creating umka
- Charles Lohr for creating the CHEW opengl loader
- Sean Barrett for creating the stb libraries (image and ttf)
- David Reid for creating miniaudio
I would also like to thank Aviv Beeri, the creator of the dome engine, which inspired me to make tophat.