- Added new methods for event polling and handling in the Event module, including `pollName` for retrieving message names. - Introduced new graphics functions for clearing the screen and drawing solid rectangles with RGBA support. - Updated the Window module to expose new settings and graphics functionalities. - Refactored the main script to utilize the new graphics and event features, improving the example game structure.
19 lines
448 B
Plaintext
19 lines
448 B
Plaintext
// example game callbacks — overrides defaults from load.nut
|
|
|
|
box <- { x = 100.0, y = 100.0, vx = 60.0 };
|
|
|
|
eve_init = function() {
|
|
gfx.setBackgroundColor(0.12, 0.14, 0.22, 1.0);
|
|
};
|
|
|
|
eve_update = function(dt) {
|
|
box.x = box.x + box.vx * dt;
|
|
if (box.x < 0.0 || box.x + 100.0 > config.width)
|
|
box.vx = -box.vx;
|
|
};
|
|
|
|
eve_render = function() {
|
|
gfx.clear();
|
|
gfx.drawSolidRect(box.x, box.y, 100.0, 60.0, 0.2, 0.8, 0.4, 1.0);
|
|
};
|