summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-06-11 04:41:25 +0200
committerkdx <kikoodx@paranoici.org>2023-06-11 04:41:25 +0200
commit855a958590c35c23d01cf6aeac95edf3f830f34a (patch)
treef02c537457fe4851df74fac33316339f5fc030bb
parentf5131c24008913591c42dbb8612128172b0ca0f9 (diff)
downloadgolem-855a958590c35c23d01cf6aeac95edf3f830f34a.tar.gz
move sample
-rw-r--r--samples/move.golem65
1 files changed, 62 insertions, 3 deletions
diff --git a/samples/move.golem b/samples/move.golem
index 2efbe80..407b6e1 100644
--- a/samples/move.golem
+++ b/samples/move.golem
@@ -1,9 +1,68 @@
-define input = 0xbffe;
-define screen = 0xbfff;
+define INPUT = 0xbffe;
+define SCREEN = 0xbfff;
+define TRUE = 1;
+define FALSE = 0;
-main()
+main() {
loop {
slp;
+ erase();
update();
draw();
}
+}
+
+
+update() {
+ input_update();
+ player_update();
+}
+
+
+erase() {
+ player_erase();
+}
+
+
+draw() {
+ player_draw();
+}
+
+
+global input_left;
+global input_right;
+global input_up;
+global input_down;
+
+input_update() {
+ local input;
+ input = [INPUT];
+ input_up = (input & 0x10) != 0;
+ input_down = (input & 0x20) != 0;
+ input_left = (input & 0x40) != 0;
+ input_right = (input & 0x80) != 0;
+}
+
+
+global player_x = 64;
+global player_y = 64;
+
+player_update() {
+ player_x = player_x + input_right - input_left;
+ player_y = player_y + input_down - input_up;
+}
+
+
+player_erase() {
+ pset(player_x, player_y, 0x1111);
+}
+
+
+player_draw() {
+ pset(player_x, player_y, 0xffff);
+}
+
+
+pset(x, y, c) {
+ [SCREEN + (x & 127) + (y & 127) * 128] = c;
+}