test cartridge for lua and js
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import {do_init_gfx, print_orange} from "./my_gfx";
|
||||
import {do_pad, do_touch} from "./my_input";
|
||||
import {do_fs} from "./my_fs";
|
||||
|
||||
export function frame(): void {
|
||||
do_init_gfx();
|
||||
do_pad();
|
||||
do_touch();
|
||||
do_fs();
|
||||
print_orange();
|
||||
|
||||
{
|
||||
const x = 10;
|
||||
gfx.drawText(120, 100, "1. value of " + x, color.white);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
export function do_fs(): void {
|
||||
let h: number = fs.open("test.txt");
|
||||
if (h >= 0) {
|
||||
fs.write(h, "Hello Prometeu!");
|
||||
let content: string = fs.read(h);
|
||||
if (content) log.writeTag(2, 101, content);
|
||||
fs.close(h);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
export function do_init_gfx(): void {
|
||||
gfx.clear(color.indigo);
|
||||
gfx.fillRect(10, 10, 50, 50, color.red);
|
||||
gfx.drawLine(0, 0, 128, 128, color.white);
|
||||
gfx.drawCircle(64, 64, 20, color.blue);
|
||||
gfx.drawDisc(100, 100, 10, color.green, color.yellow);
|
||||
gfx.drawSquare(20, 100, 30, 30, color.cyan, color.color_key);
|
||||
}
|
||||
|
||||
export function print_orange(): void {
|
||||
let c = color.rgb(255, 128, 0);
|
||||
gfx.fillRect(0, 0, 5, 5, c);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
export function do_pad(): void {
|
||||
if (pad.up.down) {
|
||||
log.write(2, "Up is down");
|
||||
}
|
||||
|
||||
if (pad.a.pressed) {
|
||||
audio.play("bgm_music", 0, 0, 128, 127, 1.0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
export function do_touch(): void {
|
||||
gfx.setSprite("mouse_cursor", 0, touch.x, touch.y, 0, 0, true, false, false, 4);
|
||||
if (touch.button.down) {
|
||||
gfx.drawCircle(touch.x, touch.y, 10, color.white);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user