mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Adds an initial dungeon preset, refactors border code to properly create dungeon walls
This commit is contained in:
parent
80da704d19
commit
598e727500
2 changed files with 33 additions and 17 deletions
|
@ -12,5 +12,5 @@ block modal-body-content
|
||||||
div.preset-size.name-label.capitalize
|
div.preset-size.name-label.capitalize
|
||||||
span(data-i18n="editor."+size) #{size}
|
span(data-i18n="editor."+size) #{size}
|
||||||
div.preset-name.capitalize
|
div.preset-name.capitalize
|
||||||
span(data-i18n="editor.grassy") #{preset.type}
|
span(data-i18n="editor."+preset.type) #{preset.type}
|
||||||
block modal-footer
|
block modal-footer
|
||||||
|
|
|
@ -10,18 +10,34 @@ clusters = {
|
||||||
'animals': ['Cow', 'Horse']
|
'animals': ['Cow', 'Horse']
|
||||||
'wood': ['Firewood 1', 'Firewood 2', 'Firewood 3', 'Barrel']
|
'wood': ['Firewood 1', 'Firewood 2', 'Firewood 3', 'Barrel']
|
||||||
'farm': ['Farm']
|
'farm': ['Farm']
|
||||||
|
'cave': ['Cave']
|
||||||
|
'stone': ['Gargoyle', 'Rock Cluster 1', 'Rock Cluster 2', 'Rock Cluster 3']
|
||||||
}
|
}
|
||||||
|
|
||||||
presets = {
|
presets = {
|
||||||
# 'dungeon': {
|
'dungeon': {
|
||||||
# 'type':'dungeon'
|
'type':'dungeon'
|
||||||
# 'borders':['Dungeon Wall']
|
'borders':['Dungeon Wall']
|
||||||
# 'floors':['Dungeon Floor']
|
'borderNoise':0
|
||||||
# 'decorations':[]
|
'borderSize':4
|
||||||
# }
|
'floors':['Dungeon Floor']
|
||||||
|
'decorations': {
|
||||||
|
'cave': {
|
||||||
|
'num':[1,1]
|
||||||
|
'width': 20
|
||||||
|
'height': 20
|
||||||
|
'clusters': {
|
||||||
|
'cave':[1,1]
|
||||||
|
'stone':[2,4]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
'grassy': {
|
'grassy': {
|
||||||
'type':'grassy'
|
'type':'grassy'
|
||||||
'borders':['Tree 1', 'Tree 2', 'Tree 3']
|
'borders':['Tree 1', 'Tree 2', 'Tree 3']
|
||||||
|
'borderNoise':1
|
||||||
|
'borderSize':0
|
||||||
'floors':['Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05']
|
'floors':['Grass01', 'Grass02', 'Grass03', 'Grass04', 'Grass05']
|
||||||
'decorations': {
|
'decorations': {
|
||||||
'house': {
|
'house': {
|
||||||
|
@ -102,7 +118,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
presetSize = presetSizes[presetSize]
|
presetSize = presetSizes[presetSize]
|
||||||
@thangs = []
|
@thangs = []
|
||||||
@randomizeFloor preset, presetSize
|
@randomizeFloor preset, presetSize
|
||||||
@randomizeBorder preset, presetSize
|
@randomizeBorder preset, presetSize, preset.borderNoise
|
||||||
@randomizeDecorations preset, presetSize
|
@randomizeDecorations preset, presetSize
|
||||||
|
|
||||||
randomizeFloor: (preset, presetSize) ->
|
randomizeFloor: (preset, presetSize) ->
|
||||||
|
@ -116,21 +132,21 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
randomizeBorder: (preset, presetSize) ->
|
randomizeBorder: (preset, presetSize, noiseFactor=1) ->
|
||||||
for i in _.range(0, presetSize.x, thangSizes.borderSize.x)
|
for i in _.range(0, presetSize.x, thangSizes.borderSize.x)
|
||||||
for j in _.range(thangSizes.borderSize.thickness)
|
for j in _.range(thangSizes.borderSize.thickness)
|
||||||
@thangs.push {
|
@thangs.push {
|
||||||
'id': @getRandomThang(preset.borders)
|
'id': @getRandomThang(preset.borders)
|
||||||
'pos': {
|
'pos': {
|
||||||
'x': i + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2)
|
'x': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2)
|
||||||
'y': 0 + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y)
|
'y': 0 + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@thangs.push {
|
@thangs.push {
|
||||||
'id': @getRandomThang(preset.borders)
|
'id': @getRandomThang(preset.borders)
|
||||||
'pos': {
|
'pos': {
|
||||||
'x': i + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2)
|
'x': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2)
|
||||||
'y': presetSize.y + _.random(-thangSizes.borderSize.y, thangSizes.borderSize.y/2)
|
'y': presetSize.y - preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y, thangSizes.borderSize.y/2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,15 +155,15 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
||||||
@thangs.push {
|
@thangs.push {
|
||||||
'id': @getRandomThang(preset.borders)
|
'id': @getRandomThang(preset.borders)
|
||||||
'pos': {
|
'pos': {
|
||||||
'x': 0 + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x)
|
'x': 0 + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x)
|
||||||
'y': i + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2)
|
'y': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@thangs.push {
|
@thangs.push {
|
||||||
'id': @getRandomThang(preset.borders)
|
'id': @getRandomThang(preset.borders)
|
||||||
'pos': {
|
'pos': {
|
||||||
'x': presetSize.x + _.random(-thangSizes.borderSize.x, thangSizes.borderSize.x/2)
|
'x': presetSize.x - preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.x, thangSizes.borderSize.x/2)
|
||||||
'y': i + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2)
|
'y': i + preset.borderSize/2 + noiseFactor * _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue