Cursor types
type Cursor* = enum {
system = 0 // Default system cursor
arrow // Normal cursor; Arrow cursor
iBeam // 'I' text cursor; I-Beam
crosshair // '+' cursor; Select region cursor
finger // Index finger pointing cursor; Click cursor
sizeEW // '<->' cursor; Resize width cursor; Resize horizontally cursor; East-West resize cursor
sizeNS // Resize height cursor; Resize vertically cursor; North-South resize cursor
sizeNWSE // Resize width and height from the right side cursor; Northwest-Southeast resize cursor
sizeSWNE // Resize width and height from the left side cursor; Southwest-Northeast resize cursor
sizeAll // Resize all cursor; Move cursor
no // '(/)' cursor; Disabled cursor; Disallowed cursor
count_
}
Window dimensions
var (
w*, h*: int32
)
Viewport size
var wp*: th::Vf2
signal OnFrame
var onFrame*: signal::Signal
signal OnDestroy
var onDestroy*: signal::Signal
fn setViewport
fn setViewport*(dm: th::Vf2) {
Sets the dimensions of the viewport. The dimensions are saved in the wp
variable.
dm
: dimension of the viewport
fn isDpiEnabled
fn isDpiEnabled*(): bool {
Returns true if DPI awareness was enabled
fn getDpiScaleFactor
fn getDpiScaleFactor*(): th::fu {
Returns the DPI scaling of the current window.
If dpiAware
was not enabled in window setup, this function will return 1.0 (default scaling).
fn setup
fn setup*(title: str = "tophat game", width: int = 400, height: int32 = 400) {
Sets up the engine and opens a window.
fn setFullscreen
fn setFullscreen*(fullscreen: bool) {
Makes window go full screen
fn isFullscreen
fn isFullscreen*(): bool {
Returns true if window is fullscreen
fn getDims
fn getDims*(): th::Vf2 {
Returns dimensions of the window in screen pixels.
fn setTargetFps
fn setTargetFps*(fps: int) {
Sets the fps limit.
fps
: amount of fps the limit should be set to
fn setTitle
fn setTitle*(title: str) {
Sets the title of the window.
fn setDims
fn setDims*(dm: th::Vf2) {
Sets the dimensions of the window.
dm
: the target dimensions in screen pixels
fn setIcon
fn setIcon*(img: image::Image) {
Sets the window icon.
fn showCursor
fn showCursor*(show: bool) {
Show or hide the cursor, linux only.
fn freezeCursor
fn freezeCursor*(freeze: bool) {
Freezes the cursor in place. input.getMouseDelta
will still report mouse
movements. The cursor will be automatically hidden.
fn setCursor
fn setCursor*(cursor: Cursor) {
Allows you to set the displaying cursor. Refer to the cursors section for available cursors.
fn requestExit
fn requestExit*() {
Requests the window to close.
fn setClipboard
fn setClipboard*(s: str) {
Puts a string to the system clipboard.
fn getClipboard
fn getClipboard*(): str {
Gets a string from the system clipboard.
fn setViewportOffset
fn setViewportOffset*(s: th::Vf2) {
Sets the offset of the viewport.
fn getViewportOffset
fn getViewportOffset*(): th::Vf2 {
Gets the offset of the viewport (as set by setViewportOffset
)