User prompt
When stacking plates, create a variable that calculates if the overhang happened on the left or right side of the stack
User prompt
If the overhang is on the right side of the stack, move the stacked plate such that the right edge is aligned with the plate below it
User prompt
When stacking a plate, subtract the overhang from the width of this plate
User prompt
Subtract the overhang from the current plate width
User prompt
When calculating overhang factor in the width of both top and new plate
User prompt
When stacking plates, calculate how much the just stacked plate overhangs the plate below it
User prompt
Set initial plate width to 1000
User prompt
when creating the first new plate, also use current plate width
User prompt
Create a variable inside Game indicating the current width of plates, then use that when creating plates
User prompt
Update plate class to accept a targetWidth variable.
User prompt
Don't use arguments[...] in plate, rather create a named variable
User prompt
Update plate class to accept targetWidth, then use that to set plate graphics width
User prompt
Update the plate class to accept a width attribute, then use that for the plate width. Make sure to parse width from game when creating plates
User prompt
width of plates should be defined by the game class, not the plate class
User prompt
Fix Bug: 'ReferenceError: Can't find variable: plateWidth' in this line: 'plateGraphics.width = plateWidth;' Line Number: 4
User prompt
Create a global plate width variable in game, subtract overhang from this variable and apply that width to newly spawned plates
User prompt
When stacking a plate, calculate how much of the stacked plate overhangs the plate below it
User prompt
When calculating overhang factor in the width of the top plate
User prompt
When stacking a plate, calculate how much of the stacked plate overhangs compared to the plate below it. Then cut off the overhang by resizing the plate that got stacked.
User prompt
when stacking plates, if there is more than 17 plates on the screen, increase the target y of plate container by the hight of one plate
User prompt
Set initial target y and y of plate container to 0
User prompt
In tick, if plate container target y is different than actual Y animate the plate container y towards the target y
User prompt
Introduce a target Y position for the plate container element.
User prompt
Create a container element in game that all plates are attached to
User prompt
Write a tick function that moves down the plates by the hight of one plate, if the stack is higher than 17 plates
===================================================================
--- original.js
+++ change.js
@@ -44,15 +44,14 @@
stage.on('down', function (obj) {
var topPlate = plates[plates.length - 2];
if (newPlate.x < topPlate.x + topPlate.width && newPlate.x + newPlate.width > topPlate.x) {
var overhang = newPlate.x + newPlate.width / 2 - (topPlate.x + topPlate.width / 2);
+ var overhangSide = overhang > 0 ? 'right' : 'left';
+ overhang = Math.abs(overhang);
console.log('Overhang:', overhang);
newPlate.stack();
- currentPlateWidth -= Math.abs(overhang);
- newPlate.width -= Math.abs(overhang);
- if (overhang > 0) {
- newPlate.x -= overhang;
- }
+ currentPlateWidth -= overhang;
+ newPlate.width -= overhang;
newPlate = new Plate(currentPlateWidth);
newPlate.slide();
newPlate.y = 2732 - plates.length * newPlate.height - newPlate.height / 2;
plateColorIndex++;