example room

This commit is contained in:
Synthasmagoria 2026-11-11 15:02:00 +01:00
commit 9ea0da6831
2 changed files with 174 additions and 44 deletions

View file

@ -338,6 +338,51 @@ JmapObjectInstance :: struct {
x, y, object_index: int, x, y, object_index: int,
} }
jmap_object_list_from_text :: proc(text: string, allocator: mem.Allocator, temp_allocator: mem.Allocator) -> (_object_list: []JmapObjectInstance, _error: JmapObjectListError) {
object_start_marker := "objects: (x, y, type)\n"
object_start_marker_index := strings.index(text, object_start_marker)
if object_start_marker_index == -1 {
return {}, .NoStartMarker
}
object_start_index := object_start_marker_index + len(object_start_marker)
object_end_marker := "version:"
object_end_index := strings.index(text, object_end_marker)
if object_end_index == -1 {
return {}, .NoEndMarker
}
object_list_string := text[object_start_index:object_end_index]
object_list_split := strings.split(object_list_string, sep = " ", allocator = temp_allocator)
if len(object_list_split) % 3 != 0 {
return {}, .BadListLength
}
object_list := make([]JmapObjectInstance, len(object_list_split) / 3, allocator)
for i := 0; i < len(object_list); i += 1 {
x, x_ok := strconv.parse_int(strings.trim_space(object_list_split[i * 3 + 0]), 10)
if !x_ok {
fmt.println("ERROR: Couldn't parse x of object '", object_list_split[i * 3 + 0], "'", sep = "")
return {}, .BadObject
}
y, y_ok := strconv.parse_int(strings.trim_space(object_list_split[i * 3 + 1]), 10)
if !y_ok {
fmt.println("ERROR: Couldn't parse y of object '", object_list_split[i * 3 + 1], "'", sep = "")
return {}, .BadObject
}
object_index, object_index_ok := strconv.parse_int(strings.trim_space(object_list_split[i * 3 + 2]), 10)
if !object_index_ok {
fmt.println("ERROR: Couldn't parse object_index of object '", object_list_split[i * 3 + 2], "'", sep = "")
return {}, .BadObject
}
object_list[i] = {x, y, object_index}
}
return object_list, .None
}
jmap_object_map := map[int]string { jmap_object_map := map[int]string {
1 = "block", 1 = "block",
2 = "miniBlock", 2 = "miniBlock",
@ -386,47 +431,4 @@ jmap_object_map := map[int]string {
47 = "miniLineBlockVertical", 47 = "miniLineBlockVertical",
} }
jmap_object_list_from_text :: proc(text: string, allocator: mem.Allocator, temp_allocator: mem.Allocator) -> (_object_list: []JmapObjectInstance, _error: JmapObjectListError) { jmap_object_map_reverse: map[string]int
object_start_marker := "objects: (x, y, type)\n"
object_start_marker_index := strings.index(text, object_start_marker)
if object_start_marker_index == -1 {
return {}, .NoStartMarker
}
object_start_index := object_start_marker_index + len(object_start_marker)
object_end_marker := "version:"
object_end_index := strings.index(text, object_end_marker)
if object_end_index == -1 {
return {}, .NoEndMarker
}
object_list_string := text[object_start_index:object_end_index]
object_list_split := strings.split(object_list_string, sep = " ", allocator = temp_allocator)
if len(object_list_split) % 3 != 0 {
return {}, .BadListLength
}
object_list := make([]JmapObjectInstance, len(object_list_split) / 3, allocator)
for i := 0; i < len(object_list); i += 1 {
x, x_ok := strconv.parse_int(strings.trim_space(object_list_split[i * 3 + 0]), 10)
if !x_ok {
fmt.println("ERROR: Couldn't parse x of object '", object_list_split[i * 3 + 0], "'", sep = "")
return {}, .BadObject
}
y, y_ok := strconv.parse_int(strings.trim_space(object_list_split[i * 3 + 1]), 10)
if !y_ok {
fmt.println("ERROR: Couldn't parse y of object '", object_list_split[i * 3 + 1], "'", sep = "")
return {}, .BadObject
}
object_index, object_index_ok := strconv.parse_int(strings.trim_space(object_list_split[i * 3 + 2]), 10)
if !object_index_ok {
fmt.println("ERROR: Couldn't parse object_index of object '", object_list_split[i * 3 + 2], "'", sep = "")
return {}, .BadObject
}
object_list[i] = {x, y, object_index}
}
return object_list, .None
}

128
rSatoru.yy Normal file
View file

@ -0,0 +1,128 @@
{
"$GMRoom":"v1",
"%Name":"rSatoru",
"creationCodeFile":"",
"inheritCode":false,
"inheritCreationOrder":false,
"inheritLayers":false,
"instanceCreationOrder":[
{"name":"inst_1B57A8DE","path":"rooms/rSatoru/rSatoru.yy",},
{"name":"inst_24A5E355","path":"rooms/rSatoru/rSatoru.yy",},
],
"isDnd":false,
"layers":[
{"$GMRInstanceLayer":"","%Name":"Instances","depth":0,"effectEnabled":true,"effectType":null,"gridX":32,"gridY":32,"hierarchyFrozen":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"inheritSubLayers":true,"inheritVisibility":true,"instances":[
{"$GMRInstance":"v4","%Name":"inst_1B57A8DE","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_1B57A8DE","objectId":{"name":"objSave","path":"objects/objSave/objSave.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":896.0,"y":1984.0,},
{"$GMRInstance":"v4","%Name":"inst_24A5E355","colour":4294967295,"frozen":false,"hasCreationCode":false,"ignore":false,"imageIndex":0,"imageSpeed":1.0,"inheritCode":false,"inheritedItemId":null,"inheritItemSettings":false,"isDnd":false,"name":"inst_24A5E355","objectId":{"name":"objPlayerStart","path":"objects/objPlayerStart/objPlayerStart.yy",},"properties":[],"resourceType":"GMRInstance","resourceVersion":"2.0","rotation":0.0,"scaleX":1.0,"scaleY":1.0,"x":928.0,"y":1312.0,},
],"layers":[],"name":"Instances","properties":[],"resourceType":"GMRInstanceLayer","resourceVersion":"2.0","userdefinedDepth":false,"visible":true,},
{"$GMRTileLayer":"","%Name":"Tiles","depth":100,"effectEnabled":true,"effectType":null,"gridX":32,"gridY":32,"hierarchyFrozen":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"inheritSubLayers":true,"inheritVisibility":true,"layers":[],"name":"Tiles","properties":[],"resourceType":"GMRTileLayer","resourceVersion":"2.0","tiles":{"SerialiseHeight":190,"SerialiseWidth":150,"TileCompressedData":[
-54,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,-3,0,2,18,
19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,-3,0,2,
18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,-3,
0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,5,2,3,0,0,-2147483648,-3,0,2,2,3,-140,-2147483648,5,18,19,0,0,-2147483648,
-3,0,2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,4,18,19,0,0,-4,-2147483648,
2,18,19,-140,-2147483648,4,2,3,0,0,-4,-2147483648,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,
2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,
2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,
2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,
2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,
2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,
2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,
2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,
2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,
2,18,19,-6,0,2,18,19,-140,-2147483648,2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-140,-2147483648,
2,2,3,-6,0,2,2,3,-140,-2147483648,2,18,19,-6,0,2,18,19,-136,-2147483648,6,2,3,2,3,2,3,-6,0,2,2,3,-136,
-2147483648,6,18,19,18,19,18,19,-6,0,2,18,19,-136,-2147483648,-2,0,-4,-2147483648,-6,0,2,2,3,-4,-2147483648,
2,2,3,-8,-2147483648,2,2,3,-8,-2147483648,4,2,3,2,3,-108,-2147483648,-2,0,-6,-2147483648,-4,0,2,18,19,
-4,-2147483648,2,18,19,-8,-2147483648,2,18,19,-8,-2147483648,4,18,19,18,19,-108,-2147483648,-2,0,-6,
-2147483648,-4,0,2,2,3,-4,-2147483648,4,2,3,2,3,-4,-2147483648,4,2,3,2,3,-8,-2147483648,2,2,3,-110,-2147483648,
-2,0,-6,-2147483648,-4,0,2,18,19,-4,-2147483648,4,18,19,18,19,-4,-2147483648,4,18,19,18,19,-8,-2147483648,
2,18,19,-110,-2147483648,-2,0,-10,-2147483648,4,2,3,2,3,-10,-2147483648,2,2,3,-122,-2147483648,-2,0,
-10,-2147483648,4,18,19,18,19,-10,-2147483648,2,18,19,-122,-2147483648,-2,0,-148,-2147483648,-2,0,-34,
-2147483648,2,2,3,-112,-2147483648,-2,0,-25,-2147483648,5,0,2,3,2,3,-4,-2147483648,2,18,19,-112,-2147483648,
-2,0,-25,-2147483648,5,0,18,19,18,19,-118,-2147483648,-2,0,-15,-2147483648,4,2,3,2,3,-129,-2147483648,
-2,0,-15,-2147483648,4,18,19,18,19,-129,-2147483648,-2,0,10,2,3,2,3,2,3,2,3,2,3,-7,-2147483648,6,2,3,
2,3,2,3,-125,-2147483648,-2,0,10,18,19,18,19,18,19,18,19,18,19,-7,-2147483648,6,18,19,18,19,18,19,-125,
-2147483648,12,2,3,2,3,2,3,2,3,2,3,2,3,-138,-2147483648,12,18,19,18,19,18,19,18,19,18,19,18,19,-138,
-2147483648,8,2,3,2,3,2,3,2,3,-142,-2147483648,8,18,19,18,19,18,19,18,19,-142,-2147483648,6,2,3,2,3,
2,3,-144,-2147483648,6,18,19,18,19,18,19,-144,-2147483648,6,2,3,2,3,2,3,-144,-2147483648,6,18,19,18,
19,18,19,-144,-2147483648,4,2,3,2,3,-146,-2147483648,4,18,19,18,19,-146,-2147483648,4,2,3,2,3,-44,-2147483648,
2,2,3,-100,-2147483648,4,18,19,18,19,-44,-2147483648,2,18,19,-100,-2147483648,4,2,3,2,3,-146,-2147483648,
4,18,19,18,19,-146,-2147483648,4,2,3,2,3,-146,-2147483648,4,18,19,18,19,-146,-2147483648,4,2,3,2,3,-146,
-2147483648,4,18,19,18,19,-146,-2147483648,4,2,3,2,3,-44,-2147483648,2,2,3,-100,-2147483648,4,18,19,
18,19,-44,-2147483648,2,18,19,-100,-2147483648,4,2,3,2,3,-146,-2147483648,4,18,19,18,19,-146,-2147483648,
4,2,3,2,3,-146,-2147483648,4,18,19,18,19,-5796,-2147483648,
],"TileDataFormat":1,},"tilesetId":{"name":"tilSatoru","path":"tilesets/tilSatoru/tilSatoru.yy",},"userdefinedDepth":false,"visible":true,"x":0,"y":0,},
{"$GMRBackgroundLayer":"","%Name":"Background","animationFPS":15.0,"animationSpeedType":0,"colour":4278190080,"depth":200,"effectEnabled":true,"effectType":null,"gridX":32,"gridY":32,"hierarchyFrozen":false,"hspeed":0.0,"htiled":false,"inheritLayerDepth":false,"inheritLayerSettings":false,"inheritSubLayers":true,"inheritVisibility":true,"layers":[],"name":"Background","properties":[],"resourceType":"GMRBackgroundLayer","resourceVersion":"2.0","spriteId":null,"stretch":false,"userdefinedAnimFPS":false,"userdefinedDepth":false,"visible":true,"vspeed":0.0,"vtiled":false,"x":0,"y":0,},
],
"name":"rSatoru",
"parent":{
"name":"Satoru",
"path":"folders/Game/Rooms/Satoru.yy",
},
"parentRoom":null,
"physicsSettings":{
"inheritPhysicsSettings":false,
"PhysicsWorld":false,
"PhysicsWorldGravityX":0.0,
"PhysicsWorldGravityY":10.0,
"PhysicsWorldPixToMetres":0.1,
},
"resourceType":"GMRoom",
"resourceVersion":"2.0",
"roomSettings":{
"Height":3040,
"inheritRoomSettings":false,
"persistent":false,
"Width":2400,
},
"sequenceId":null,
"views":[
{"hborder":32,"hport":608,"hspeed":-1,"hview":608,"inherit":false,"objectId":null,"vborder":32,"visible":true,"vspeed":-1,"wport":800,"wview":800,"xport":0,"xview":800,"yport":0,"yview":1824,},
{"hborder":32,"hport":608,"hspeed":-1,"hview":608,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":800,"wview":800,"xport":0,"xview":0,"yport":0,"yview":0,},
{"hborder":32,"hport":608,"hspeed":-1,"hview":608,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":800,"wview":800,"xport":0,"xview":0,"yport":0,"yview":0,},
{"hborder":32,"hport":608,"hspeed":-1,"hview":608,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":800,"wview":800,"xport":0,"xview":0,"yport":0,"yview":0,},
{"hborder":32,"hport":608,"hspeed":-1,"hview":608,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":800,"wview":800,"xport":0,"xview":0,"yport":0,"yview":0,},
{"hborder":32,"hport":608,"hspeed":-1,"hview":608,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":800,"wview":800,"xport":0,"xview":0,"yport":0,"yview":0,},
{"hborder":32,"hport":608,"hspeed":-1,"hview":608,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":800,"wview":800,"xport":0,"xview":0,"yport":0,"yview":0,},
{"hborder":32,"hport":608,"hspeed":-1,"hview":608,"inherit":false,"objectId":null,"vborder":32,"visible":false,"vspeed":-1,"wport":800,"wview":800,"xport":0,"xview":0,"yport":0,"yview":0,},
],
"viewSettings":{
"clearDisplayBuffer":true,
"clearViewBackground":false,
"enableViews":true,
"inheritViewSettings":false,
},
"volume":1.0,
}