UNLEASH THE OBJECT FOLDER MOTHERFUCKERS
oops i dropped all these OBJECTS that aren't assembled correctly but who gives a shit i don't this is just for my google sheets thing
|
@ -2,7 +2,7 @@ const zlib = require('zlib')
|
|||
const properties = require('../misc/objectProperties.json')
|
||||
const init = require('../misc/initialProperties.json')
|
||||
const colorStuff = require('../misc/colorProperties.json')
|
||||
const ids = require('../misc/notableObjects.json')
|
||||
const ids = require('../misc/objects.json')
|
||||
const blocks = require('../misc/blocks.json')
|
||||
|
||||
module.exports = async (app, req, res, level) => {
|
||||
|
|
|
@ -1,30 +1,25 @@
|
|||
const Jimp = require('jimp');
|
||||
const objects = require('../misc/objects.json')
|
||||
const sprites = require('../misc/sprites.json')
|
||||
|
||||
// pre-load this ONCE to drop loading time
|
||||
let sheets = [1, 2, 3].map(x => `./assets/spritesheets/GJ_GameSheet0${x}.png`)
|
||||
const Jimp = require('jimp')
|
||||
const fs = require('fs')
|
||||
|
||||
module.exports = async (app, req, res) => {
|
||||
|
||||
let objID = req.params.text
|
||||
let objID = (req.params.text || "").split(/[^0-9]/)[0]
|
||||
let objPath = './assets/ids/' + objID + '.png'
|
||||
if (!fs.existsSync(objPath + objID)) objPath = './assets/ids/1607.png'
|
||||
|
||||
if (!objects[objID] || !sprites[objects[objID]]) objID = 1607 // question mark
|
||||
let sprite = sprites[objects[objID]]
|
||||
let flipX = req.query.hasOwnProperty("flipX") || req.query.hasOwnProperty("flipx") || req.query.hasOwnProperty("fx")
|
||||
let flipY = req.query.hasOwnProperty("flipY") || req.query.hasOwnProperty("flipy") || req.query.hasOwnProperty("fy")
|
||||
|
||||
let rotateParams = req.query.rotation || req.query.rotate || req.query.r
|
||||
let rotation = sprite.rotation - (+rotateParams || 0)
|
||||
let spritesheet = sheets[sprite.spritesheet - 1]
|
||||
let rotation = Number(req.query.rotation || req.query.rotate || req.query.r)
|
||||
|
||||
let crop = [sprite.x, sprite.y, sprite.width, sprite.height]
|
||||
if (sprite.rotation == 90) [crop[2], crop[3]] = [crop[3], crop[2]]
|
||||
|
||||
Jimp.read(spritesheet).then(sheet => {
|
||||
if (typeof spritesheet == "string") sheets[sprite.spritesheet - 1] = new Jimp(sheet)
|
||||
sheet.crop(...crop)
|
||||
if (rotation) sheet.rotate(rotation)
|
||||
sheet.mirror(req.query.hasOwnProperty("flipX"), req.query.hasOwnProperty("flipY"))
|
||||
sheet.getBuffer(Jimp.AUTO, (err, buffer) => {
|
||||
Jimp.read(objPath).then(obj => {
|
||||
obj.mirror(flipX, flipY)
|
||||
if (rotation) {
|
||||
obj.invert() // fix transparency, jimp is dumb
|
||||
obj.rotate(-rotation)
|
||||
obj.invert()
|
||||
}
|
||||
obj.getBuffer(Jimp.AUTO, (err, buffer) => {
|
||||
return res.contentType('image/png').end(buffer, 'base64')
|
||||
})
|
||||
})
|
||||
|
|
BIN
assets/ids/1.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
assets/ids/10.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
assets/ids/1000.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/ids/1001.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/ids/1002.png
Normal file
After Width: | Height: | Size: 661 B |
BIN
assets/ids/1003.png
Normal file
After Width: | Height: | Size: 311 B |
BIN
assets/ids/1004.png
Normal file
After Width: | Height: | Size: 152 B |
BIN
assets/ids/1005.png
Normal file
After Width: | Height: | Size: 162 B |
BIN
assets/ids/1006.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
assets/ids/1007.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
assets/ids/1009.png
Normal file
After Width: | Height: | Size: 738 B |
BIN
assets/ids/101.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
assets/ids/1010.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/ids/1011.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
assets/ids/1012.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
assets/ids/1013.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
assets/ids/1014.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/ids/1015.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
assets/ids/1016.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
assets/ids/1017.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
assets/ids/1018.png
Normal file
After Width: | Height: | Size: 1,015 B |
BIN
assets/ids/1019.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
assets/ids/1020.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
assets/ids/1021.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/ids/1022.png
Normal file
After Width: | Height: | Size: 6 KiB |
BIN
assets/ids/1024.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/ids/1025.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
assets/ids/1026.png
Normal file
After Width: | Height: | Size: 102 B |
BIN
assets/ids/1027.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/ids/1028.png
Normal file
After Width: | Height: | Size: 878 B |
BIN
assets/ids/1029.png
Normal file
After Width: | Height: | Size: 502 B |
BIN
assets/ids/103.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
assets/ids/1030.png
Normal file
After Width: | Height: | Size: 675 B |
BIN
assets/ids/1031.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
assets/ids/1032.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/ids/1033.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
assets/ids/1034.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/ids/1035.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
assets/ids/1036.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
assets/ids/1037.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/ids/1038.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/ids/1039.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
assets/ids/1040.png
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
assets/ids/1041.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/ids/1042.png
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
assets/ids/1043.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
assets/ids/1044.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
assets/ids/1045.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
assets/ids/1046.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/ids/1047.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
assets/ids/1048.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
assets/ids/1049.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/ids/105.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/ids/1050.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
assets/ids/1051.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
assets/ids/1052.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
assets/ids/1053.png
Normal file
After Width: | Height: | Size: 679 B |
BIN
assets/ids/1054.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/ids/1055.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/ids/1056.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/ids/1057.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/ids/1058.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
assets/ids/1059.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
assets/ids/106.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
assets/ids/1060.png
Normal file
After Width: | Height: | Size: 4 KiB |
BIN
assets/ids/1061.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
assets/ids/1062.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
assets/ids/1063.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/ids/1064.png
Normal file
After Width: | Height: | Size: 109 B |
BIN
assets/ids/1065.png
Normal file
After Width: | Height: | Size: 102 B |
BIN
assets/ids/1066.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/ids/1067.png
Normal file
After Width: | Height: | Size: 878 B |
BIN
assets/ids/1068.png
Normal file
After Width: | Height: | Size: 502 B |
BIN
assets/ids/1069.png
Normal file
After Width: | Height: | Size: 675 B |
BIN
assets/ids/107.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/ids/1070.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
assets/ids/1071.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/ids/1075.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/ids/1076.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/ids/1077.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/ids/1078.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/ids/1079.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
assets/ids/1080.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
assets/ids/1081.png
Normal file
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/ids/1082.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
assets/ids/1083.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
assets/ids/1084.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
assets/ids/1085.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
assets/ids/1086.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
assets/ids/1087.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
assets/ids/1088.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
assets/ids/1089.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
assets/ids/1090.png
Normal file
After Width: | Height: | Size: 4.3 KiB |
BIN
assets/ids/1091.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
assets/ids/1092.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
BIN
assets/ids/1093.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
assets/ids/1094.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
assets/ids/1095.png
Normal file
After Width: | Height: | Size: 2.3 KiB |