Files
prometeu-studio/test-projects/main/src/main.pbs
T
bquarkz 13c0ababbb
Test / Build occurred while executing withChecks step.
Intrepid/Prometeu/Studio/pipeline/pr-master There was a failure building this commit
Intrepid/Prometeu/Studio/pipeline/head There was a failure building this commit
feat(pbs): align typed values and Pad input facade
2026-10-15 15:48:50 +01:00

120 lines
2.9 KiB
Plaintext

import { Log } from @sdk:log;
import { Pad, Button, Touch } from @sdk:input;
import { Composer } from @sdk:composer;
import { Gfx } from @sdk:gfx;
import { Assets } from @sdk:asset;
declare global loading_handle: int = -1;
declare global loading_status: int = -1;
declare global frame_counter: int = 0;
declare global tile_id: int = 0;
declare global camera_x: int = 0;
declare global camera_mult: int = 1;
declare const MAX_FRAMES: int = 4;
declare const CAMERA_SPEED: int = 1;
declare struct Bla (a: int) {}
[Init]
fn init() -> void
{
loading_handle= -1;
loading_status = -1;
frame_counter = 0;
tile_id = 0;
camera_x = 0;
camera_mult = 1;
Composer.bind_scene(0);
let bla: Bla = new Bla(1);
}
[Frame]
fn frame() -> void
{
if (loading_handle == -1) {
let t : (status: int, loading_handle: int) = Assets.load(assets.ui.atlas2, 3);
if (t.status != 0) {
Log.failure("load failed");
} else {
loading_handle = t.loading_handle;
Log.info("state: loading");
}
} else {
let s : int = Assets.status(loading_handle);
if (s == 2) {
let commit_status : int = Assets.commit(loading_handle);
if (commit_status != 0) {
Log.failure("commit failed");
}
} else if (s == 3) {
let sprite_status : int = Composer.emit_sprite(0, 0, 150, 150, 1, 3, false, false, 1);
if (sprite_status != 0) {
Log.failure("emit_sprite failed");
}
} else {
Log.info("state: waiting");
}
}
if (Touch.released())
{
frame_counter = 0;
tile_id = 0;
}
if (Touch.down())
{
frame_counter = frame_counter + 1;
if (frame_counter > MAX_FRAMES)
{
frame_counter = 0;
tile_id = tile_id + 1;
if (tile_id > 7)
{
tile_id = 0;
}
}
}
camera_x = camera_x + (camera_mult * CAMERA_SPEED);
if (camera_x >= 240 || camera_x <= 0)
{
camera_mult = -1 * camera_mult;
}
Log.info("camera_x:" + camera_x);
Composer.set_camera(camera_x, 0);
Composer.emit_sprite(tile_id, 0, (Touch.x() as int) - 16, (Touch.y() as int) + 8, 2, 0, true, false, 0);
let a : int = 10;
let b : int = 15;
let total : int = a + b;
if (Pad.pressed(Button.A))
{
total += 25;
}
else if (Pad.pressed(Button.B))
{
total += 5;
}
else if (Pad.pressed(Button.X))
{
total -= 10;
}
if (total == 30)
{
Log.info("30 is the magic number!");
}
else if (total == 50)
{
Log.failure("50 is the magic number!");
}
else if (total == 15)
{
Log.warn("The magic number is neither 30 nor 50!");
}
}