[oden] Docs and stuff
This commit is contained in:
parent
f232f095f5
commit
75fcc427ac
2 changed files with 34 additions and 7 deletions
|
|
@ -1,17 +1,42 @@
|
|||
import * as core from "graphics-core";
|
||||
|
||||
// Clear the screen to the specified color. r, g, and b should vary from 0 to
|
||||
// 1.
|
||||
/**
|
||||
* Clear the screen.
|
||||
*
|
||||
* @param r - The red component of the color to clear to, from 0 to 1.
|
||||
* @param g - The green component of the color to clear to, from 0 to 1.
|
||||
* @param b - The blue component of the color to clear to, from 0 to 1.
|
||||
*/
|
||||
export function cls(r: number, g: number, b: number) {
|
||||
core.cls(r, g, b);
|
||||
}
|
||||
|
||||
// Print a message to the console.
|
||||
/**
|
||||
* Print a message to the console.
|
||||
*
|
||||
* @remarks
|
||||
* The specified arguments will be printed to the console, one at a time,
|
||||
* separated by spaces. If you want them separated by something else,
|
||||
* format the string yourself.
|
||||
*
|
||||
* @param args - Arguments to print to the console.
|
||||
*/
|
||||
export function print(...args: unknown[]) {
|
||||
core.print(args.join(" "));
|
||||
}
|
||||
|
||||
// Draw a sprite in the rectangle from x,y to
|
||||
/**
|
||||
* Draw a sprite.
|
||||
*
|
||||
* @param x - The x coordinate of the upper-left pixel of the sprite.
|
||||
* @param y - The y coordinate of the upper-left pixel of the sprite.
|
||||
* @param w - The width of the target rectangle, in pixels.
|
||||
* @param h - The height of the target rectangle, in pixels.
|
||||
* @param sx - The x offset of the upper-left pixel of the sprite in the current sheet, in pixels.
|
||||
* @param sy - The y offset of the upper-left pixel of the sprite in the current sheet, in pixels.
|
||||
* @param sw - The width of the sprite, in pixels. If null or not specified, defaults to the width of the target rectangle.
|
||||
* @param sh - The height of the sprite, in pixels. If null or not specified, defaults to the height of the target rectangle.
|
||||
*/
|
||||
export function spr(
|
||||
x: number,
|
||||
y: number,
|
||||
|
|
@ -19,8 +44,10 @@ export function spr(
|
|||
h: number,
|
||||
sx: number,
|
||||
sy: number,
|
||||
sw: number,
|
||||
sh: number
|
||||
sw: number | null = null,
|
||||
sh: number | null = null
|
||||
) {
|
||||
sw = sw || w;
|
||||
sh = sh || h;
|
||||
core.spr(x, y, w, h, sx, sy, sw, sh);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,5 +8,5 @@ export function update() {}
|
|||
|
||||
export function draw() {
|
||||
cls(0.1, 0.2, 0.3);
|
||||
spr(0, 0, 320, 240, 0, 0, 256, 256);
|
||||
spr((320 - 256) / 2, 0, 256, 240, 0, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue