This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/client/scripts/game/30-scene-Battle.coffee

44 lines
956 B
CoffeeScript
Raw Normal View History

2018-09-30 21:48:24 +00:00
Crafty.defineScene "Battle", ->
2018-09-30 21:49:27 +00:00
2018-09-30 21:48:24 +00:00
# free viewport
Crafty.viewport.clampToEntities = false
# attach viewport to an (invisible) entity twice as big as a playmat
2018-09-30 21:49:27 +00:00
Crafty.viewport.follow (
Crafty.e '2D, Canvas'
2018-09-30 21:48:24 +00:00
.attr {
w: 1 * CONF.playmat.w
h: 2 * CONF.playmat.h
}
.origin 'middle left'
.attr {
ox: 0
oy: 0
}
.origin 'center'
2018-09-30 21:48:24 +00:00
)
# scale viewport automatically (show that new entity)
Crafty.bind 'ViewportResize', ->
sX = @viewport._width / (1 * CONF.playmat.w)
sY = @viewport._height / (2 * CONF.playmat.h)
@viewport.scale Math.min(sX, sY)
return
# force scale adjustment
Crafty.trigger 'ViewportResize'
# Example playmats at https://imgur.com/a/VSosu#cwGQdAS
2018-10-01 01:32:42 +00:00
Crafty.sprite 2000, 1000, 'assets/ff7.jpg',
2018-09-30 21:48:24 +00:00
playmat: [
0
0
]
2018-09-30 21:49:27 +00:00
# Place example playmats
Crafty.e 'playmat, AllyPlaymat'
Crafty.e 'playmat, EnemyPlaymat'
2018-09-30 21:48:24 +00:00
return