About
Sdlging facilities in the Mys programming language.
Project: https://github.com/mys-lang/package-sdl
Based on https://github.com/nsauzede/vsdl2.
Installation
Install SDL2 library:
$ sudo apt install libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev libsdl2-image-dev
API
enum KeyCode(i64):
Space
L
X
Z
Right
Left
Down
Up
trait Event:
class Rect:
x: i64
y: i64
w: i64
h: i64
class Color:
r: u8
g: u8
b: u8
a: u8
class SdlError(Error):
message: string
class Window:
title: bytes
func __init__(self):
func set_title(self, title: string):
class Renderer:
func create_texture(self, width: i64, height: i64) -> Texture:
func create_texture_from_surface(self, surface: Surface) -> Texture:
func clear(self):
func copy(self, texture: Texture, dst_rect: Rect?):
func present(self):
class Surface:
func map_rgb(self, r: u8, g: u8, b: u8) -> u32:
func fill_rect(self, rect: Rect, color: u32):
class Texture:
func query(self) -> (i64, i64):
func update(self, surface: Surface):
class QuitEvent(Event):
class KeyDownEvent(Event):
keysym: KeySym
class KeySym:
sym: KeyCode
class Font:
func __init__(self, path: Path, size: i64):
func render_solid(self, text: string, color: Color) -> Surface:
class Music:
func __init__(self, path: Path):
func play(self, loops: i64):
class Wav:
func __init__(self, path: Path):
func play(self, channel: i64, loops: i64):
func sdl_init():
func ttf_init():
func mix_init():
func open_audio(frequency: i64, channels: i64, chunksize: i64):
func create_window_and_renderer(width: i64, height: i64, flags: u32) -> (Window, Renderer):
func create_rgb_surface(flags: u32,
width: i64,
height: i64,
bpp: i64,
rmask: u32,
gmask: u32,
bmask: u32,
amask: u32) -> Surface:
func img_init():
func img_load(path: Path) -> Surface:
func poll_event() -> Event?:
func get_performance_counter() -> u64:
func get_performance_frequency() -> u64:
func volume_music():