From 49bf42e1fbe627bfa1f4c8d892d262669dbdb369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Mon, 1 Oct 2018 21:39:53 +0200 Subject: [PATCH] Testing card placement --- client/scripts/10-conf.coffee | 2 +- client/scripts/20-comp-Card.coffee | 25 +++++----------- client/scripts/40-test-entities.coffee | 41 +++++++++++++++++++++----- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/client/scripts/10-conf.coffee b/client/scripts/10-conf.coffee index 44dab95..f1187c3 100644 --- a/client/scripts/10-conf.coffee +++ b/client/scripts/10-conf.coffee @@ -10,7 +10,7 @@ CONF = bigcard: x: (2000 - 1200) / 2 - y: (2000 - 1675) / 2 + y: ( 0 - 1675) / 2 w: 1200 h: 1675 diff --git a/client/scripts/20-comp-Card.coffee b/client/scripts/20-comp-Card.coffee index 4c9e2e0..becf525 100644 --- a/client/scripts/20-comp-Card.coffee +++ b/client/scripts/20-comp-Card.coffee @@ -21,14 +21,14 @@ Crafty.c 'Card', Crafty.log 'Card was removed!' return - # smooth placement - place: (px, py) -> - @tween { - x: px - y: py - }, CONF.anim.time, CONF.anim.func - events: + # smooth placement + Place: (position) -> + @tween { + x: position.x + y: position.y + }, CONF.anim.time, CONF.anim.func + # Tap or untap, pass true iff you want to tap Tap: (newState) -> # store new state in property as boolean value @@ -89,7 +89,7 @@ Crafty.c 'EnemyCard', ################ Crafty.c 'AllyCard', # is a card - required: 'Card, Draggable' + required: 'Card' # normally oriented by default init: -> @@ -102,12 +102,3 @@ Crafty.c 'AllyCard', DoubleClick: -> @trigger 'ToggleTap' return - - # snap to 100×100 grid (TODO) - StopDrag: -> - - round100 = (v) -> - Math.round(v / 100) * 100 - - @place round100(@_x), round100(@_y) - return diff --git a/client/scripts/40-test-entities.coffee b/client/scripts/40-test-entities.coffee index f124134..53e7202 100644 --- a/client/scripts/40-test-entities.coffee +++ b/client/scripts/40-test-entities.coffee @@ -8,14 +8,39 @@ Crafty.sprite 480, 670, '//www.fftcgmognet.com/images/cards/hd/1/1/107.jpg', 0 ] -Crafty.e 'shantotto, AllyCard, Backup' - .place 0, 0 +backups = [ -Crafty.e 'shantotto, AllyCard, Backup' - .place 300, 0 + Crafty.e 'shantotto, AllyCard' + .attr { + card: + type: 'backup' + } -Crafty.e 'shantotto, AllyCard, Backup' - .place 600, 0 + Crafty.e 'shantotto, AllyCard' + .attr { + card: + type: 'backup' + } -Crafty.e 'shantotto, EnemyCard, Backup' - .place 900, 0 + Crafty.e 'shantotto, AllyCard' + .attr { + card: + type: 'backup' + } + +] + +Crafty 'AllyCard' + .each (index) -> + switch @card.type + when 'backup' + @trigger 'Place', + x: CONF.coord.x.main + index * CONF.coord.x.step + y: CONF.coord.y.bkup + return + + +Crafty.e 'shantotto, EnemyCard' + .trigger 'Place', + x: 900 + y: 0