fix services and add logs
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,48 @@
|
||||
// Injeção pelo hardware
|
||||
declare contract LogHost host {
|
||||
fn write(level: int, msg: string): void;
|
||||
fn writeTag(level: int, tag: int, msg: string): void;
|
||||
}
|
||||
|
||||
// exposicao do modulo, com sugar sintatico, nada injetado aqui
|
||||
pub service Log {
|
||||
fn trace(msg: string): void {
|
||||
LogHost.write(0, msg);
|
||||
}
|
||||
|
||||
fn trace(tag: int, msg: string): void {
|
||||
LogHost.writeTag(0, tag, msg);
|
||||
}
|
||||
|
||||
fn debug(msg: string): void {
|
||||
LogHost.write(1, msg);
|
||||
}
|
||||
|
||||
fn debug(tag: int, msg: string): void {
|
||||
LogHost.writeTag(1, tag, msg);
|
||||
}
|
||||
|
||||
fn info(msg: string): void {
|
||||
LogHost.write(2, msg);
|
||||
}
|
||||
|
||||
fn info(tag: int, msg: string): void {
|
||||
LogHost.writeTag(2, tag, msg);
|
||||
}
|
||||
|
||||
fn warn(msg: string): void {
|
||||
LogHost.write(3, msg);
|
||||
}
|
||||
|
||||
fn warn(tag: int, msg: string): void {
|
||||
LogHost.writeTag(3, tag, msg);
|
||||
}
|
||||
|
||||
fn err(msg: string): void {
|
||||
LogHost.write(4, msg);
|
||||
}
|
||||
|
||||
fn err(tag: int, msg: string): void {
|
||||
LogHost.writeTag(4, tag, msg);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
import { Color, Gfx } from "@sdk:gfx";
|
||||
import { Pad, Touch } from "@sdk:input";
|
||||
import { Log } from "@sdk:log";
|
||||
|
||||
declare struct Vec2(x: int, y: int)
|
||||
[
|
||||
@@ -51,10 +52,14 @@ fn frame(): void {
|
||||
}
|
||||
|
||||
// 4. Input Snapshot & Nested Member Access
|
||||
let pad = Pad.a();
|
||||
let touch = Touch.finger();
|
||||
let is_pressed = pad.down || touch.down;
|
||||
let pad_a = Pad.a();
|
||||
let touch_f = Touch.finger();
|
||||
let is_pressed = pad_a.down || touch_f.down;
|
||||
if is_pressed {
|
||||
Gfx.clear(Color.BLUE);
|
||||
}
|
||||
|
||||
if Pad.b().pressed {
|
||||
Log.debug("B Pressed");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user