Merge pull request #1333 from jayant1992/master

Preset images for terrain generator
This commit is contained in:
Nick Winter 2014-07-25 14:42:03 -07:00
commit a1d1d7cef3
5 changed files with 35 additions and 29 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View file

@ -3,7 +3,7 @@
.choose-option
margin-bottom: 15px
width: 100%
height: 100px
height: 200px
overflow: hidden
background: white
border: 1px solid #333
@ -125,4 +125,7 @@
.hard-option .preset-name
border-top: 25px solid black
color: white
color: white
.capitalize
text-transform: capitalize

View file

@ -5,11 +5,12 @@ block modal-header-content
block modal-body-content
div#normal-view
a(href="#")
div.choose-option(data-preset-type="grassy", data-preset-size="small")
div.preset-size.name-label
span(data-i18n="editor.small") Small
div.preset-name
span(data-i18n="editor.grassy") Grassy
//- for model in models
each sizeObject, size in presetSizes
each preset in presets
a(href="#")
div.choose-option(data-preset-type=preset.type, data-preset-size=size, style="background:url(/images/pages/editor/level/preset_"+preset.type+"_"+size+".jpg) no-repeat center; background-size: cover")
div.preset-size.name-label.capitalize
span(data-i18n="editor."+size) #{size}
div.preset-name.capitalize
span(data-i18n="editor.grassy") #{preset.type}
block modal-footer

View file

@ -50,7 +50,7 @@ presets = {
}
}
sizes = {
presetSizes = {
'small': {
'x':80
'y':68
@ -59,6 +59,9 @@ sizes = {
'x':160
'y':136
}
}
thangSizes = {
'floorSize': {
'x':20
'y':17
@ -96,55 +99,55 @@ module.exports = class TerrainRandomizeModal extends ModalView
randomizeThangs: (presetName, presetSize) ->
preset = presets[presetName]
presetSize = sizes[presetSize]
presetSize = presetSizes[presetSize]
@thangs = []
@randomizeFloor preset, presetSize
@randomizeBorder preset, presetSize
@randomizeDecorations preset, presetSize
randomizeFloor: (preset, presetSize) ->
for i in _.range(0, presetSize.x, sizes.floorSize.x)
for j in _.range(0, presetSize.y, sizes.floorSize.y)
for i in _.range(0, presetSize.x, thangSizes.floorSize.x)
for j in _.range(0, presetSize.y, thangSizes.floorSize.y)
@thangs.push {
'id': @getRandomThang(preset.floors)
'pos': {
'x': i + sizes.floorSize.x/2
'y': j + sizes.floorSize.y/2
'x': i + thangSizes.floorSize.x/2
'y': j + thangSizes.floorSize.y/2
}
}
randomizeBorder: (preset, presetSize) ->
for i in _.range(0, presetSize.x, sizes.borderSize.x)
for j in _.range(sizes.borderSize.thickness)
for i in _.range(0, presetSize.x, thangSizes.borderSize.x)
for j in _.range(thangSizes.borderSize.thickness)
@thangs.push {
'id': @getRandomThang(preset.borders)
'pos': {
'x': i + _.random(-sizes.borderSize.x/2, sizes.borderSize.x/2)
'y': 0 + _.random(-sizes.borderSize.y/2, sizes.borderSize.y)
'x': i + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2)
'y': 0 + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y)
}
}
@thangs.push {
'id': @getRandomThang(preset.borders)
'pos': {
'x': i + _.random(-sizes.borderSize.x/2, sizes.borderSize.x/2)
'y': presetSize.y + _.random(-sizes.borderSize.y, sizes.borderSize.y/2)
'x': i + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x/2)
'y': presetSize.y + _.random(-thangSizes.borderSize.y, thangSizes.borderSize.y/2)
}
}
for i in _.range(0, presetSize.y, sizes.borderSize.y)
for i in _.range(0, presetSize.y, thangSizes.borderSize.y)
for j in _.range(3)
@thangs.push {
'id': @getRandomThang(preset.borders)
'pos': {
'x': 0 + _.random(-sizes.borderSize.x/2, sizes.borderSize.x)
'y': i + _.random(-sizes.borderSize.y/2, sizes.borderSize.y/2)
'x': 0 + _.random(-thangSizes.borderSize.x/2, thangSizes.borderSize.x)
'y': i + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2)
}
}
@thangs.push {
'id': @getRandomThang(preset.borders)
'pos': {
'x': presetSize.x + _.random(-sizes.borderSize.x, sizes.borderSize.x/2)
'y': i + _.random(-sizes.borderSize.y/2, sizes.borderSize.y/2)
'x': presetSize.x + _.random(-thangSizes.borderSize.x, thangSizes.borderSize.x/2)
'y': i + _.random(-thangSizes.borderSize.y/2, thangSizes.borderSize.y/2)
}
}
@ -182,9 +185,8 @@ module.exports = class TerrainRandomizeModal extends ModalView
getRenderData: ->
c = super()
models = _.values CocoModel.backedUp
models = (m for m in models when m.hasLocalChanges())
c.models = models
c.presets = presets
c.presetSizes = presetSizes
c
onHidden: ->