fun: puttin dat hoe to werk

This commit is contained in:
cha0s 2019-05-28 16:55:55 -05:00
parent ced4a1bedd
commit aa28b72625
4 changed files with 55 additions and 139 deletions

View File

@ -1,110 +1,5 @@
{ {
"imageUri": "/tileset.png", "imageUri": "/tileset.png",
"tileSize": [16, 16], "tileSize": [16, 16],
"geometry": { "geometry": {}
"5": {
"type": "polygon",
"vertices": [
[5, 8],
[8, 2],
[8, 8]
]
},
"6": {
"type": "polygon",
"vertices": [
[-8, 2],
[8, 2],
[8, 8],
[-8, 8]
]
},
"7": {
"type": "polygon",
"vertices": [
[-8, 2],
[8, 2],
[8, 8],
[-8, 8]
]
},
"8": {
"type": "polygon",
"vertices": [
[-8, 2],
[-4, 8],
[-8, 8]
]
},
"21": {
"type": "polygon",
"vertices": [
[-3, 8],
[5, -8],
[8, -8],
[8, 8]
]
},
"24": {
"type": "polygon",
"vertices": [
[-8, -8],
[-4, -8],
[5, 8],
[-8, 8]
]
},
"261": {
"type": "polygon",
"vertices": [
[-3, -8],
[8, -8],
[8, 8],
[5, 8]
]
},
"264": {
"type": "polygon",
"vertices": [
[-8, -8],
[5, -8],
[-4, 8],
[-8, 8]
]
},
"277": {
"type": "polygon",
"vertices": [
[5, -8],
[8, -8],
[8, -2]
]
},
"278": {
"type": "polygon",
"vertices": [
[-8, -8],
[8, -8],
[8, -2],
[-8, -2]
]
},
"279": {
"type": "polygon",
"vertices": [
[-8, -8],
[8, -8],
[8, -2],
[-8, -2]
]
},
"280": {
"type": "polygon",
"vertices": [
[-8, -8],
[-4, -8],
[-8, -2]
]
}
}
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 190 KiB

View File

@ -1,10 +1,26 @@
import {buildInvoke, buildTraversal, buildCondition} from '@avocado/behavior';
// Hoe. // Hoe.
export function hoeJSON() { export function hoeJSON() {
const tillTile = buildInvoke(
['user', 'layer', 'setTileAt'],
[
buildTraversal(['target']),
// 6 === dirt
6,
]
)
return { return {
traits: { traits: {
existent: {}, existent: {},
item: { item: {
params: { params: {
itemActions: {
type: 'actions',
traversals: [
buildInvoke(['item', 'useTool']),
],
},
slotImages: { slotImages: {
default: '/hoe.png', default: '/hoe.png',
}, },
@ -12,10 +28,30 @@ export function hoeJSON() {
}, },
tool: { tool: {
params: { params: {
condition: buildCondition(
'or',
[
buildCondition('contains', [
[1, 2, 3, 4],
buildInvoke(
['user', 'layer', 'tileAt'],
[
buildTraversal(['target']),
],
),
]),
],
),
actions: {
type: 'actions',
traversals: [
tillTile,
],
},
target: { target: {
type: 'projection', type: 'projection',
distance: 1, distance: 1,
length: 3, length: 1,
width: 1, width: 1,
}, },
}, },

View File

@ -1,5 +1,21 @@
import {Vector} from '@avocado/math'; import {Vector} from '@avocado/math';
function tileData(size) {
const tileCount = Vector.area(size);
const tileData = [];
for (let i = 0; i < tileCount; ++i) {
// 75% chance it's grass.
if (Math.random() > 0.25) {
tileData.push(Math.floor(Math.random() * 4) + 1);
}
else {
// Otherwise, 50/50 between stone and dirt.
tileData.push(Math.floor(Math.random() * 2) + 5);
}
}
return tileData;
}
// Room. // Room.
export function kittyFireJSON() { export function kittyFireJSON() {
@ -12,38 +28,7 @@ export function kittyFireJSON() {
entities: [], entities: [],
tiles: { tiles: {
size: roomTileSize, size: roomTileSize,
data: [ data: tileData(roomTileSize),
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4,
1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 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