start text displaying
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
dcd924cec0
commit
f06bdefbe3
208
maps/RPGmap.json
208
maps/RPGmap.json
|
@ -11,7 +11,7 @@
|
||||||
"infinite":false,
|
"infinite":false,
|
||||||
"layers":[
|
"layers":[
|
||||||
{
|
{
|
||||||
"data":[1, 1, 1, 1, 1, 19, 20, 21, 1, 1, 1, 1, 1, 1, 1, 36, 53, 38, 1, 1, 1, 1, 1, 1, 86, 88, 104, 1, 1, 17, 1, 1, 1, 1, 105, 1, 1, 1, 1, 1, 1, 1, 1, 1, 105, 1, 1, 1, 81, 1, 1, 1, 1, 1, 105, 67, 66, 97, 98, 99, 1, 68, 1, 1, 105, 66, 67, 114, 115, 116, 1, 103, 88, 88, 106, 1, 1, 100, 118, 101, 1, 1, 1, 1, 103, 88, 88, 88, 107, 88, 11, 13, 1, 12, 1, 1, 1, 1, 1, 1],
|
"data":[1, 1, 1, 1, 1, 19, 20, 21, 1, 1, 69, 1, 1, 1, 1, 36, 53, 38, 1, 1, 1, 1, 1, 1, 86, 88, 104, 1, 1, 17, 1, 1, 1, 1, 105, 1, 1, 1, 1, 1, 1, 69, 1, 1, 105, 1, 1, 1, 81, 1, 1, 1, 1, 1, 105, 67, 66, 97, 98, 99, 1, 68, 1, 1, 105, 66, 67, 114, 115, 116, 1, 103, 88, 88, 106, 1, 1, 100, 118, 101, 1, 1, 1, 1, 103, 88, 88, 88, 107, 88, 11, 13, 1, 12, 1, 1, 1, 1, 1, 1],
|
||||||
"height":10,
|
"height":10,
|
||||||
"id":1,
|
"id":1,
|
||||||
"name":"map",
|
"name":"map",
|
||||||
|
@ -38,28 +38,6 @@
|
||||||
"x":80.301333604805,
|
"x":80.301333604805,
|
||||||
"y":-0.325766059248702
|
"y":-0.325766059248702
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"height":15.4738878143134,
|
|
||||||
"id":4,
|
|
||||||
"name":"",
|
|
||||||
"rotation":0,
|
|
||||||
"type":"",
|
|
||||||
"visible":true,
|
|
||||||
"width":15.6367708439377,
|
|
||||||
"x":15.9625369031864,
|
|
||||||
"y":95.7752214191184
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"height":32.0879568359971,
|
|
||||||
"id":5,
|
|
||||||
"name":"",
|
|
||||||
"rotation":0,
|
|
||||||
"type":"",
|
|
||||||
"visible":true,
|
|
||||||
"width":80.1384505751807,
|
|
||||||
"x":80.1384505751807,
|
|
||||||
"y":79.812684515932
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"height":9.44721571821236,
|
"height":9.44721571821236,
|
||||||
"id":6,
|
"id":6,
|
||||||
|
@ -72,59 +50,191 @@
|
||||||
"y":70.3654687977196
|
"y":70.3654687977196
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"height":16.1254199328107,
|
"height":15.8181818181818,
|
||||||
"id":8,
|
"id":16,
|
||||||
"name":"",
|
"name":"",
|
||||||
"rotation":0,
|
"rotation":0,
|
||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":15.6367708439377,
|
"width":11.4545454545455,
|
||||||
"x":143.988598187926,
|
"x":146.181818181818,
|
||||||
"y":31.7621907767484
|
"y":32
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"height":15.5,
|
"height":12.7272727272727,
|
||||||
"id":10,
|
"id":17,
|
||||||
"name":"",
|
"name":"",
|
||||||
"rotation":0,
|
"rotation":0,
|
||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":14.875,
|
"width":11.8181818181818,
|
||||||
|
"x":18,
|
||||||
|
"y":97.8181818181818
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":13.4545454545455,
|
||||||
|
"id":18,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":12,
|
||||||
|
"x":113.818181818182,
|
||||||
|
"y":16.3636363636364
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":14.5454545454545,
|
||||||
|
"id":19,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":13.0909090909091,
|
||||||
|
"x":81.2727272727273,
|
||||||
|
"y":16.3636363636364
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":26.7272727272727,
|
||||||
|
"id":20,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":26,
|
||||||
|
"x":82.9090909090909,
|
||||||
|
"y":85.2727272727273
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":4.54545454545455,
|
||||||
|
"id":21,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":8.18181818181819,
|
||||||
|
"x":99.6363636363636,
|
||||||
|
"y":80.9090909090909
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":17.2727272727273,
|
||||||
|
"id":22,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":47.6363636363637,
|
||||||
"x":112,
|
"x":112,
|
||||||
"y":112
|
"y":94.1818181818182
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"height":16.125,
|
"height":7.27272727272728,
|
||||||
"id":11,
|
"id":23,
|
||||||
"name":"",
|
"name":"",
|
||||||
"rotation":0,
|
"rotation":0,
|
||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":15.25,
|
"width":30.3636363636364,
|
||||||
"x":144.875,
|
"x":120.727272727273,
|
||||||
"y":111.625
|
"y":86.9090909090909
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"height":15.375,
|
"height":7.09090909090909,
|
||||||
"id":13,
|
"id":24,
|
||||||
"name":"",
|
"name":"",
|
||||||
"rotation":0,
|
"rotation":0,
|
||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":15,
|
"width":16.3636363636364,
|
||||||
"x":79.875,
|
"x":127.636363636364,
|
||||||
"y":16.125
|
"y":80
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"height":15.625,
|
"height":12.5454545454545,
|
||||||
"id":14,
|
"id":25,
|
||||||
"name":"",
|
"name":"",
|
||||||
"rotation":0,
|
"rotation":0,
|
||||||
"type":"",
|
"type":"",
|
||||||
"visible":true,
|
"visible":true,
|
||||||
"width":13.875,
|
"width":11.4545454545455,
|
||||||
"x":113.875,
|
"x":114.363636363636,
|
||||||
"y":16.375
|
"y":111.818181818182
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":12.5454545454545,
|
||||||
|
"id":26,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":12.1818181818182,
|
||||||
|
"x":145.090909090909,
|
||||||
|
"y":111.272727272727
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":6.54545454545453,
|
||||||
|
"id":27,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":31.0909090909091,
|
||||||
|
"x":0.363636363636364,
|
||||||
|
"y":153.272727272727
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":7.09090909090909,
|
||||||
|
"id":28,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":8.90909090909091,
|
||||||
|
"x":11.2727272727273,
|
||||||
|
"y":146.181818181818
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"height":5.81818181818181,
|
||||||
|
"id":29,
|
||||||
|
"name":"",
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":8,
|
||||||
|
"x":51.8181818181818,
|
||||||
|
"y":154
|
||||||
|
}],
|
||||||
|
"opacity":1,
|
||||||
|
"type":"objectgroup",
|
||||||
|
"visible":true,
|
||||||
|
"x":0,
|
||||||
|
"y":0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"draworder":"topdown",
|
||||||
|
"id":3,
|
||||||
|
"name":"act",
|
||||||
|
"objects":[
|
||||||
|
{
|
||||||
|
"height":20,
|
||||||
|
"id":30,
|
||||||
|
"name":"",
|
||||||
|
"properties":[
|
||||||
|
{
|
||||||
|
"name":"act_face",
|
||||||
|
"type":"string",
|
||||||
|
"value":"Up"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"dialogue",
|
||||||
|
"type":"string",
|
||||||
|
"value":"Test message!"
|
||||||
|
}],
|
||||||
|
"rotation":0,
|
||||||
|
"type":"",
|
||||||
|
"visible":true,
|
||||||
|
"width":16,
|
||||||
|
"x":16,
|
||||||
|
"y":96
|
||||||
}],
|
}],
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"type":"objectgroup",
|
"type":"objectgroup",
|
||||||
|
@ -132,8 +242,8 @@
|
||||||
"x":0,
|
"x":0,
|
||||||
"y":0
|
"y":0
|
||||||
}],
|
}],
|
||||||
"nextlayerid":3,
|
"nextlayerid":4,
|
||||||
"nextobjectid":15,
|
"nextobjectid":31,
|
||||||
"orientation":"orthogonal",
|
"orientation":"orthogonal",
|
||||||
"renderorder":"right-down",
|
"renderorder":"right-down",
|
||||||
"tiledversion":"1.4.3",
|
"tiledversion":"1.4.3",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="15">
|
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="16" tileheight="16" infinite="0" nextlayerid="4" nextobjectid="31">
|
||||||
<editorsettings>
|
<editorsettings>
|
||||||
<export target="RPGmap.json" format="json"/>
|
<export target="RPGmap.json" format="json"/>
|
||||||
</editorsettings>
|
</editorsettings>
|
||||||
|
@ -7,10 +7,10 @@
|
||||||
<layer id="1" name="map" width="10" height="10">
|
<layer id="1" name="map" width="10" height="10">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
1,1,1,1,1,19,20,21,1,1,
|
1,1,1,1,1,19,20,21,1,1,
|
||||||
1,1,1,1,1,36,53,38,1,1,
|
69,1,1,1,1,36,53,38,1,1,
|
||||||
1,1,1,1,86,88,104,1,1,17,
|
1,1,1,1,86,88,104,1,1,17,
|
||||||
1,1,1,1,105,1,1,1,1,1,
|
1,1,1,1,105,1,1,1,1,1,
|
||||||
1,1,1,1,105,1,1,1,81,1,
|
1,69,1,1,105,1,1,1,81,1,
|
||||||
1,1,1,1,105,67,66,97,98,99,
|
1,1,1,1,105,67,66,97,98,99,
|
||||||
1,68,1,1,105,66,67,114,115,116,
|
1,68,1,1,105,66,67,114,115,116,
|
||||||
1,103,88,88,106,1,1,100,118,101,
|
1,103,88,88,106,1,1,100,118,101,
|
||||||
|
@ -20,13 +20,28 @@
|
||||||
</layer>
|
</layer>
|
||||||
<objectgroup id="2" name="coll">
|
<objectgroup id="2" name="coll">
|
||||||
<object id="1" x="80.3013" y="-0.325766" width="47.399" height="16.4512"/>
|
<object id="1" x="80.3013" y="-0.325766" width="47.399" height="16.4512"/>
|
||||||
<object id="4" x="15.9625" y="95.7752" width="15.6368" height="15.4739"/>
|
|
||||||
<object id="5" x="80.1385" y="79.8127" width="80.1385" height="32.088"/>
|
|
||||||
<object id="6" x="127.863" y="70.3655" width="16.2883" height="9.44722"/>
|
<object id="6" x="127.863" y="70.3655" width="16.2883" height="9.44722"/>
|
||||||
<object id="8" x="143.989" y="31.7622" width="15.6368" height="16.1254"/>
|
<object id="16" x="146.182" y="32" width="11.4545" height="15.8182"/>
|
||||||
<object id="10" x="112" y="112" width="14.875" height="15.5"/>
|
<object id="17" x="18" y="97.8182" width="11.8182" height="12.7273"/>
|
||||||
<object id="11" x="144.875" y="111.625" width="15.25" height="16.125"/>
|
<object id="18" x="113.818" y="16.3636" width="12" height="13.4545"/>
|
||||||
<object id="13" x="79.875" y="16.125" width="15" height="15.375"/>
|
<object id="19" x="81.2727" y="16.3636" width="13.0909" height="14.5455"/>
|
||||||
<object id="14" x="113.875" y="16.375" width="13.875" height="15.625"/>
|
<object id="20" x="82.9091" y="85.2727" width="26" height="26.7273"/>
|
||||||
|
<object id="21" x="99.6364" y="80.9091" width="8.18182" height="4.54545"/>
|
||||||
|
<object id="22" x="112" y="94.1818" width="47.6364" height="17.2727"/>
|
||||||
|
<object id="23" x="120.727" y="86.9091" width="30.3636" height="7.27273"/>
|
||||||
|
<object id="24" x="127.636" y="80" width="16.3636" height="7.09091"/>
|
||||||
|
<object id="25" x="114.364" y="111.818" width="11.4545" height="12.5455"/>
|
||||||
|
<object id="26" x="145.091" y="111.273" width="12.1818" height="12.5455"/>
|
||||||
|
<object id="27" x="0.363636" y="153.273" width="31.0909" height="6.54545"/>
|
||||||
|
<object id="28" x="11.2727" y="146.182" width="8.90909" height="7.09091"/>
|
||||||
|
<object id="29" x="51.8182" y="154" width="8" height="5.81818"/>
|
||||||
|
</objectgroup>
|
||||||
|
<objectgroup id="3" name="act">
|
||||||
|
<object id="30" x="16" y="96" width="16" height="20">
|
||||||
|
<properties>
|
||||||
|
<property name="act_face" value="Direction.Up"/>
|
||||||
|
<property name="dialogue" value="Test message!"/>
|
||||||
|
</properties>
|
||||||
|
</object>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
</map>
|
</map>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<export target="TestMap.json" format="json"/>
|
<export target="TestMap.json" format="json"/>
|
||||||
</editorsettings>
|
</editorsettings>
|
||||||
<tileset firstgid="1" source="../sprites/Cave.tsx"/>
|
<tileset firstgid="1" source="../sprites/Cave.tsx"/>
|
||||||
<layer id="1" name="Tile Layer 1" width="10" height="10">
|
<layer id="1" name="map" width="10" height="10">
|
||||||
<data encoding="csv">
|
<data encoding="csv">
|
||||||
29,29,29,29,29,29,29,29,29,29,
|
29,29,29,29,29,29,29,29,29,29,
|
||||||
29,29,29,29,29,29,29,29,29,29,
|
29,29,29,29,29,29,29,29,29,29,
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
104
src/main.zig
104
src/main.zig
|
@ -2,6 +2,10 @@ const w4 = @import("wasm4.zig");
|
||||||
const sh0rk = @import("sh0rk.zig");
|
const sh0rk = @import("sh0rk.zig");
|
||||||
const sprites = @import("sprites.zig");
|
const sprites = @import("sprites.zig");
|
||||||
const palette = @import("palette.zig");
|
const palette = @import("palette.zig");
|
||||||
|
const tframe = @import("tframe.zig");
|
||||||
|
|
||||||
|
const std = @import("std");
|
||||||
|
const fmt = std.fmt;
|
||||||
|
|
||||||
const Direction = sh0rk.Direction;
|
const Direction = sh0rk.Direction;
|
||||||
const Point = sh0rk.Point;
|
const Point = sh0rk.Point;
|
||||||
|
@ -17,6 +21,12 @@ var screen = Rect{.base = Point{.x = 0, .y = 0}, .width = 160, .height = 160};
|
||||||
var sound_timer: u8 = 0;
|
var sound_timer: u8 = 0;
|
||||||
|
|
||||||
var textBuf: [160]u8 = undefined;
|
var textBuf: [160]u8 = undefined;
|
||||||
|
var done: bool = true;
|
||||||
|
|
||||||
|
var text_frame: bool = false;
|
||||||
|
var curr_text: []const u8 = undefined;
|
||||||
|
var text_index: usize = 0;
|
||||||
|
var text_counter: u4 = 0;
|
||||||
|
|
||||||
export fn start() void {
|
export fn start() void {
|
||||||
palette.mist();
|
palette.mist();
|
||||||
|
@ -43,39 +53,54 @@ fn bonk() void {
|
||||||
},
|
},
|
||||||
w4.Tone.Flags{
|
w4.Tone.Flags{
|
||||||
.channel = .triangle,
|
.channel = .triangle,
|
||||||
.pulse_duty = .@"1/2",
|
.pulse_duty = .@"1/4",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
sound_timer = 12;
|
sound_timer = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const screen_width = 10;
|
||||||
|
const screen_height = 10;
|
||||||
|
|
||||||
fn drawMap() !void {
|
fn drawMap() !void {
|
||||||
w4.m.colors.* = .{
|
w4.m.colors.* = .{
|
||||||
._0 = .p0,
|
._0 = .p3,
|
||||||
._1 = .p1,
|
._1 = .p2,
|
||||||
._2 = .p2,
|
._2 = .p1,
|
||||||
._3 = .p3,
|
._3 = .p0,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (map.data) |tile, i| {
|
var col: u32 = 0;
|
||||||
const width = sprites.kenney_rpg_width / 16;
|
while (col < screen_width) {
|
||||||
const height = sprites.kenney_rpg_width / 16;
|
var row: u32 = 0;
|
||||||
var x: u32 = (i % width) * 16;
|
defer col += 1;
|
||||||
var y: u32 = (i / height) * 16;
|
|
||||||
|
while (row < screen_height) {
|
||||||
|
defer row += 1;
|
||||||
|
|
||||||
|
var tile = map.data[col * map.width + row];
|
||||||
|
var tileX = tile % map.ts_width;
|
||||||
|
var tileY = tile / map.ts_width;
|
||||||
|
|
||||||
|
if (!done) {
|
||||||
|
var buf = fmt.bufPrint(&textBuf, "{},{}: {}: {},{}", .{col, row, tile, tileX, tileY}) catch unreachable;
|
||||||
|
w4.trace(buf);
|
||||||
|
}
|
||||||
|
|
||||||
w4.blitSub(
|
w4.blitSub(
|
||||||
&sprites.kenney_rpg,
|
&sprites.kenney_rpg,
|
||||||
x,
|
row * 16,
|
||||||
y,
|
col * 16,
|
||||||
16,
|
16,
|
||||||
16,
|
16,
|
||||||
@intCast(u32, tile.x) * 16,
|
@intCast(u32, tileX) * 16,
|
||||||
@intCast(u32, tile.y) * 16,
|
@intCast(u32, tileY) * 16,
|
||||||
sprites.kenney_rpg_width,
|
sprites.kenney_rpg_width,
|
||||||
w4.BlitFlags{.two_bits = true},
|
w4.BlitFlags{.two_bits = true},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_mara(gamepad: w4.GamePad) void {
|
fn move_mara(gamepad: w4.GamePad) void {
|
||||||
|
@ -113,21 +138,58 @@ fn move_mara(gamepad: w4.GamePad) void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn title() void {
|
||||||
|
w4.m.colors._0 = .p3;
|
||||||
|
w4.m.colors._1 = .p0;
|
||||||
|
w4.text("Mara 2:\nTamamo's Fury", 10, 10);
|
||||||
|
}
|
||||||
|
|
||||||
export fn update() void {
|
export fn update() void {
|
||||||
|
defer done = true;
|
||||||
if (sound_timer != 0) {
|
if (sound_timer != 0) {
|
||||||
sound_timer -= 1;
|
sound_timer -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawMap() catch unreachable;
|
drawMap() catch unreachable;
|
||||||
|
|
||||||
// w4.m.colors._0 = .p3;
|
|
||||||
// w4.m.colors._1 = .p0;
|
|
||||||
// w4.text("Mara 2:\nTamamo's Fury", 10, 10);
|
|
||||||
|
|
||||||
const gamepad = w4.m.gamepads[0];
|
const gamepad = w4.m.gamepads[0];
|
||||||
const old_speed = mara_speed;
|
const old_speed = mara_speed;
|
||||||
move_mara(gamepad);
|
move_mara(gamepad);
|
||||||
|
|
||||||
|
if (gamepad.b) {
|
||||||
|
var buf = fmt.bufPrint(&textBuf, "{},{}", .{mara_box.base.x, mara_box.base.y}) catch unreachable;
|
||||||
|
w4.trace(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gamepad.b and !text_frame and mara_direction == Direction.Up and mara_box.base.equals(Point{.x = 16, .y = 112})) {
|
||||||
|
text_frame = true;
|
||||||
|
curr_text = "Test message!";
|
||||||
|
text_index = 0;
|
||||||
|
text_counter = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (text_frame) {
|
||||||
|
tframe.draw();
|
||||||
|
|
||||||
|
w4.m.colors._0 = .p3;
|
||||||
|
w4.m.colors._1 = .p0;
|
||||||
|
w4.text(curr_text[0..text_index], 12, 140);
|
||||||
|
|
||||||
|
if (gamepad.a) {
|
||||||
|
w4.trace("dismissing");
|
||||||
|
text_frame = false;
|
||||||
|
text_index = 0;
|
||||||
|
curr_text = "";
|
||||||
|
}
|
||||||
|
if (text_index < curr_text.len) {
|
||||||
|
text_counter -= 1;
|
||||||
|
if (text_counter == 0) {
|
||||||
|
text_index += 1;
|
||||||
|
text_counter = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (map.coll) |box| {
|
for (map.coll) |box| {
|
||||||
if (mara_box.collides(box)) {
|
if (mara_box.collides(box)) {
|
||||||
switch (mara_direction) {
|
switch (mara_direction) {
|
||||||
|
@ -151,13 +213,17 @@ export fn update() void {
|
||||||
|
|
||||||
if (mara_box.base.x < 0) {
|
if (mara_box.base.x < 0) {
|
||||||
mara_box.base.x = 0;
|
mara_box.base.x = 0;
|
||||||
|
bonk();
|
||||||
} else if (mara_box.base.x > 160 - mara_box.width) {
|
} else if (mara_box.base.x > 160 - mara_box.width) {
|
||||||
mara_box.base.x = 160 - mara_box.width;
|
mara_box.base.x = 160 - mara_box.width;
|
||||||
|
bonk();
|
||||||
}
|
}
|
||||||
if (mara_box.base.y < 0) {
|
if (mara_box.base.y < 0) {
|
||||||
mara_box.base.y = 0;
|
mara_box.base.y = 0;
|
||||||
|
bonk();
|
||||||
} else if (mara_box.base.y > 160 - mara_box.height) {
|
} else if (mara_box.base.y > 160 - mara_box.height) {
|
||||||
mara_box.base.y = 160 - mara_box.height;
|
mara_box.base.y = 160 - mara_box.height;
|
||||||
|
bonk();
|
||||||
}
|
}
|
||||||
|
|
||||||
var flags: w4.BlitFlags = w4.BlitFlags {
|
var flags: w4.BlitFlags = w4.BlitFlags {
|
||||||
|
@ -176,7 +242,7 @@ export fn update() void {
|
||||||
// w4.m.colors._2 = .p3;
|
// w4.m.colors._2 = .p3;
|
||||||
// w4.m.colors._3 = .transparent;
|
// w4.m.colors._3 = .transparent;
|
||||||
|
|
||||||
// w4.blit(&sprites.glaceon, 100, 128, sprites.glaceon_width, sprites.glaceon_height, flags);
|
// w4.blit(&sprites.glaceon, 0, 0, sprites.glaceon_width, sprites.glaceon_height, flags);
|
||||||
|
|
||||||
w4.m.colors.* = .{
|
w4.m.colors.* = .{
|
||||||
._0 = .transparent,
|
._0 = .transparent,
|
||||||
|
|
|
@ -1,32 +1,44 @@
|
||||||
// Generated by genmap.js, DO NOT EDIT
|
// Generated by ./src/tools/genmap.js ./maps/RPGmap.json, DO NOT EDIT
|
||||||
|
|
||||||
const sh0rk = @import("../sh0rk.zig");
|
const sh0rk = @import("../sh0rk.zig");
|
||||||
const Point = sh0rk.Point;
|
const Point = sh0rk.Point;
|
||||||
const Rect = sh0rk.Rect;
|
const Rect = sh0rk.Rect;
|
||||||
const Tile = sh0rk.Tile;
|
|
||||||
|
|
||||||
pub const data = [100]Tile{
|
pub const width = 10;
|
||||||
Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 8, .y = 1}, Tile{.x = 9, .y = 1}, Tile{.x = 0, .y = 2}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0},
|
pub const height = 10;
|
||||||
Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 5, .y = 3}, Tile{.x = 2, .y = 5}, Tile{.x = 7, .y = 3}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0},
|
|
||||||
Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 5, .y = 8}, Tile{.x = 7, .y = 8}, Tile{.x = 3, .y = 10}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 6, .y = 1}, Tile{.x = 0, .y = 0},
|
pub const ts_width = 17;
|
||||||
Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 4, .y = 10}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0},
|
pub const ts_height = 8;
|
||||||
Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 4, .y = 10}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 8}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0},
|
|
||||||
Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 4, .y = 10}, Tile{.x = 6, .y = 6}, Tile{.x = 5, .y = 6}, Tile{.x = 6, .y = 9}, Tile{.x = 7, .y = 9}, Tile{.x = 8, .y = 9}, Tile{.x = 0, .y = 0},
|
pub const data = [100]u8{
|
||||||
Tile{.x = 7, .y = 6}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 4, .y = 10}, Tile{.x = 5, .y = 6}, Tile{.x = 6, .y = 6}, Tile{.x = 3, .y = 11}, Tile{.x = 4, .y = 11}, Tile{.x = 5, .y = 11}, Tile{.x = 0, .y = 0},
|
0, 0, 0, 0, 0, 18, 19, 20, 0, 0, 68,
|
||||||
Tile{.x = 2, .y = 10}, Tile{.x = 7, .y = 8}, Tile{.x = 7, .y = 8}, Tile{.x = 5, .y = 10}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 9, .y = 9}, Tile{.x = 7, .y = 11}, Tile{.x = 0, .y = 10}, Tile{.x = 0, .y = 0},
|
0, 0, 0, 0, 35, 52, 37, 0, 0, 0,
|
||||||
Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 2, .y = 10}, Tile{.x = 7, .y = 8}, Tile{.x = 7, .y = 8}, Tile{.x = 7, .y = 8}, Tile{.x = 6, .y = 10}, Tile{.x = 7, .y = 8}, Tile{.x = 0, .y = 1},
|
0, 0, 0, 85, 87, 103, 0, 0, 16, 0,
|
||||||
Tile{.x = 2, .y = 1}, Tile{.x = 0, .y = 0}, Tile{.x = 1, .y = 1}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0}, Tile{.x = 0, .y = 0},
|
0, 0, 0, 104, 0, 0, 0, 0, 0, 0,
|
||||||
|
68, 0, 0, 104, 0, 0, 0, 80, 0, 0,
|
||||||
|
0, 0, 0, 104, 66, 65, 96, 97, 98, 0,
|
||||||
|
67, 0, 0, 104, 65, 66, 113, 114, 115, 0,
|
||||||
|
102, 87, 87, 105, 0, 0, 99, 117, 100, 0,
|
||||||
|
0, 0, 0, 102, 87, 87, 87, 106, 87, 10,
|
||||||
|
12, 0, 11, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const coll = [9]Rect{
|
pub const coll = [_]Rect{
|
||||||
Rect{.base = Point{.x = 80, .y = 0}, .width = 47, .height = 16},
|
Rect{.base = Point{.x = 80, .y = 0}, .width = 47, .height = 16},
|
||||||
Rect{.base = Point{.x = 16, .y = 96}, .width = 16, .height = 15},
|
|
||||||
Rect{.base = Point{.x = 80, .y = 80}, .width = 80, .height = 32},
|
|
||||||
Rect{.base = Point{.x = 128, .y = 70}, .width = 16, .height = 9},
|
Rect{.base = Point{.x = 128, .y = 70}, .width = 16, .height = 9},
|
||||||
Rect{.base = Point{.x = 144, .y = 32}, .width = 16, .height = 16},
|
Rect{.base = Point{.x = 146, .y = 32}, .width = 11, .height = 16},
|
||||||
Rect{.base = Point{.x = 112, .y = 112}, .width = 15, .height = 16},
|
Rect{.base = Point{.x = 18, .y = 98}, .width = 12, .height = 13},
|
||||||
Rect{.base = Point{.x = 145, .y = 112}, .width = 15, .height = 16},
|
Rect{.base = Point{.x = 114, .y = 16}, .width = 12, .height = 13},
|
||||||
Rect{.base = Point{.x = 80, .y = 16}, .width = 15, .height = 15},
|
Rect{.base = Point{.x = 81, .y = 16}, .width = 13, .height = 15},
|
||||||
Rect{.base = Point{.x = 114, .y = 16}, .width = 14, .height = 16},
|
Rect{.base = Point{.x = 83, .y = 85}, .width = 26, .height = 27},
|
||||||
|
Rect{.base = Point{.x = 100, .y = 81}, .width = 8, .height = 5},
|
||||||
|
Rect{.base = Point{.x = 112, .y = 94}, .width = 48, .height = 17},
|
||||||
|
Rect{.base = Point{.x = 121, .y = 87}, .width = 30, .height = 7},
|
||||||
|
Rect{.base = Point{.x = 128, .y = 80}, .width = 16, .height = 7},
|
||||||
|
Rect{.base = Point{.x = 114, .y = 112}, .width = 11, .height = 13},
|
||||||
|
Rect{.base = Point{.x = 145, .y = 111}, .width = 12, .height = 13},
|
||||||
|
Rect{.base = Point{.x = 0, .y = 153}, .width = 31, .height = 7},
|
||||||
|
Rect{.base = Point{.x = 11, .y = 146}, .width = 9, .height = 7},
|
||||||
|
Rect{.base = Point{.x = 52, .y = 154}, .width = 8, .height = 6},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,29 @@
|
||||||
// Generated by genmap.js, DO NOT EDIT
|
// Generated by ./src/tools/genmap.js ./maps/TestMap.json, DO NOT EDIT
|
||||||
|
|
||||||
const sh0rk = @import("../sh0rk.zig");
|
const sh0rk = @import("../sh0rk.zig");
|
||||||
const Point = sh0rk.Point;
|
const Point = sh0rk.Point;
|
||||||
const Rect = sh0rk.Rect;
|
const Rect = sh0rk.Rect;
|
||||||
const Tile = sh0rk.Tile;
|
|
||||||
|
|
||||||
pub const data = [100]Tile{
|
pub const width = 10;
|
||||||
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2},
|
pub const height = 10;
|
||||||
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2},
|
|
||||||
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2},
|
pub const ts_width = 10;
|
||||||
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 7, .y = 1}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2},
|
pub const ts_height = 5;
|
||||||
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 7, .y = 3}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 0, .y = 0},
|
|
||||||
Tile{.x = 1, .y = 0}, Tile{.x = 2, .y = 0}, Tile{.x = 3, .y = 0}, Tile{.x = 1, .y = 0}, Tile{.x = 7, .y = 4}, Tile{.x = 3, .y = 0}, Tile{.x = 1, .y = 0}, Tile{.x = 2, .y = 0}, Tile{.x = 3, .y = 0}, Tile{.x = 5, .y = 0},
|
pub const data = [100]u8{
|
||||||
Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 1, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 2, .y = 2}, Tile{.x = 5, .y = 1},
|
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||||
Tile{.x = 1, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 2, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 2, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 5, .y = 2},
|
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||||
Tile{.x = 0, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 1, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 5, .y = 0},
|
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||||
Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 1, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 1, .y = 4}, Tile{.x = 9, .y = 4},
|
28, 28, 28, 28, 17, 28, 28, 28, 28, 28,
|
||||||
|
28, 28, 28, 28, 37, 28, 28, 28, 28, 0,
|
||||||
|
1, 2, 3, 1, 47, 3, 1, 2, 3, 5,
|
||||||
|
49, 49, 49, 49, 49, 49, 21, 49, 22, 15,
|
||||||
|
21, 49, 22, 49, 42, 49, 49, 49, 49, 25,
|
||||||
|
40, 49, 49, 49, 49, 49, 21, 49, 49, 5,
|
||||||
|
49, 49, 49, 21, 49, 49, 49, 41, 49,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const coll = [2]Rect{
|
pub const coll = [_]Rect{
|
||||||
Rect{.base = Point{.x = 0, .y = 80}, .width = 160, .height = 80},
|
Rect{.base = Point{.x = 0, .y = 80}, .width = 160, .height = 80},
|
||||||
Rect{.base = Point{.x = 80, .y = 48}, .width = 16, .height = 32},
|
Rect{.base = Point{.x = 80, .y = 48}, .width = 16, .height = 32},
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,161 @@
|
||||||
|
const sh0rk = @import("./sh0rk.zig");
|
||||||
|
const w4 = @import("./wasm4.zig");
|
||||||
|
const sprites = @import("./sprites.zig");
|
||||||
|
|
||||||
|
pub fn draw() void {
|
||||||
|
w4.m.colors.* = .{
|
||||||
|
._0 = .p0,
|
||||||
|
._1 = .p1,
|
||||||
|
._2 = .p2,
|
||||||
|
._3 = .p3,
|
||||||
|
};
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
0,
|
||||||
|
128,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
152,
|
||||||
|
128,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
16,
|
||||||
|
0,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
0,
|
||||||
|
136,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
0,
|
||||||
|
8,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
152,
|
||||||
|
144,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
16,
|
||||||
|
8,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
152,
|
||||||
|
136,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
16,
|
||||||
|
8,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
0,
|
||||||
|
144,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
0,
|
||||||
|
8,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
0,
|
||||||
|
152,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
0,
|
||||||
|
16,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
152,
|
||||||
|
152,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
16,
|
||||||
|
16,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
var i: u8 = 0;
|
||||||
|
while (i < 18) {
|
||||||
|
defer i += 1;
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
(i * 8) + 8,
|
||||||
|
128,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
0,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
(i * 8) + 8,
|
||||||
|
136,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
(i * 8) + 8,
|
||||||
|
144,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
|
||||||
|
w4.blitSub(
|
||||||
|
&sprites.frame,
|
||||||
|
(i * 8) + 8,
|
||||||
|
152,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
16,
|
||||||
|
sprites.frame_width,
|
||||||
|
w4.BlitFlags{.two_bits = true},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,22 +11,48 @@ var out = "";
|
||||||
const data = await Deno.readTextFile(mapFile);
|
const data = await Deno.readTextFile(mapFile);
|
||||||
const map = JSON.parse(data);
|
const map = JSON.parse(data);
|
||||||
|
|
||||||
out += `// Generated by genmap.js, DO NOT EDIT\n\n`;
|
out += `// Generated by ./src/tools/genmap.js ${mapFile}, DO NOT EDIT\n\n`;
|
||||||
|
|
||||||
out += `const sh0rk = @import("../sh0rk.zig");\n`;
|
out += `const sh0rk = @import("../sh0rk.zig");\n`;
|
||||||
|
|
||||||
|
out += `const Direction = sh0rk.Direction;\n`;
|
||||||
out += `const Point = sh0rk.Point;\n`;
|
out += `const Point = sh0rk.Point;\n`;
|
||||||
out += `const Rect = sh0rk.Rect;\n`;
|
out += `const Rect = sh0rk.Rect;\n\n`;
|
||||||
out += `const Tile = sh0rk.Tile;\n\n`;
|
|
||||||
|
out += `pub const width = ${map.width};\n`;
|
||||||
|
out += `pub const height = ${map.height};\n\n`;
|
||||||
|
|
||||||
let tiles = map.layers[0];
|
let tiles = map.layers[0];
|
||||||
out += `pub const data = [${tiles.data.length}]Tile{\n `;
|
|
||||||
|
let tilesheet = {
|
||||||
|
width: 10,
|
||||||
|
height: 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
map.tilesets.forEach(tset => {
|
||||||
|
if (tset.source.includes("kenney")) {
|
||||||
|
tilesheet = {
|
||||||
|
width: 17,
|
||||||
|
height: 8,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tset.source.includes("Cave")) {
|
||||||
|
tilesheet = {
|
||||||
|
width: 10,
|
||||||
|
height: 5,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
out += `pub const ts_width = ${tilesheet.width};\n`;
|
||||||
|
out += `pub const ts_height = ${tilesheet.height};\n\n`;
|
||||||
|
|
||||||
|
out += `pub const data = [${tiles.data.length}]u8{\n `;
|
||||||
|
|
||||||
tiles.data.forEach((tile, index) => {
|
tiles.data.forEach((tile, index) => {
|
||||||
tile -= 1;
|
tile -= 1;
|
||||||
const tileY = Math.trunc(tile / tiles.height);
|
out += `${tile},`;
|
||||||
const tileX = tile % tiles.width;
|
|
||||||
out += `Tile{.x = ${tileX}, .y = ${tileY}},`;
|
|
||||||
if (index !== 0 && index % 10 === 0) {
|
if (index !== 0 && index % 10 === 0) {
|
||||||
out += "\n ";
|
out += "\n ";
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,7 +65,7 @@ out += "\n};\n\n";
|
||||||
if (map.layers.length >= 2) {
|
if (map.layers.length >= 2) {
|
||||||
let coll = map.layers[1];
|
let coll = map.layers[1];
|
||||||
|
|
||||||
out += `pub const coll = [${coll.objects.length}]Rect{\n`;
|
out += `pub const coll = [_]Rect{\n`;
|
||||||
|
|
||||||
coll.objects.forEach(obj => {
|
coll.objects.forEach(obj => {
|
||||||
const x = Math.round(obj.x);
|
const x = Math.round(obj.x);
|
||||||
|
|
Loading…
Reference in New Issue