Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolution to issues #74 and #129 #156

Open
wants to merge 35 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f422970
added new key bindings that print to console
bohu8 Nov 19, 2015
341d8d8
moved colour blind colours to a TOGGLE function, will impelment a tru…
bohu8 Nov 19, 2015
66e0237
some work done
bohu8 Nov 20, 2015
802284f
proof of concept for colour changing.
bohu8 Nov 20, 2015
54eec34
work done at school today
bohu8 Nov 21, 2015
05fc7bd
updated read
bohu8 Nov 21, 2015
22b7950
clean up readme file, refer to original push for info
bohu8 Nov 22, 2015
2cfaf19
implemented colour change, todo: fix test for colour change feature
bohu8 Nov 22, 2015
5467d68
the beginning of creating test cases
bohu8 Nov 22, 2015
ed61a3d
updated scenarios, added unit tests, extracted method to adjust speed…
bohu8 Nov 22, 2015
98cd9b0
updated wave generation to better be suited to speed changes
bohu8 Nov 22, 2015
05d301a
added 1.1 test for changing speed, update more later.
bohu8 Nov 22, 2015
2de7b07
need to update tests case, resume work later.
bohu8 Nov 22, 2015
049b60a
attempt at blanket
bohu8 Nov 23, 2015
61caf65
Added qunit tests for scenarios 1.2 to 1.4
xinwei-tee Nov 24, 2015
e9830ec
Added comments to doesBlockCollide. Refactoring to be performed (bloc…
xinwei-tee Nov 25, 2015
de23d3a
Added toggleDrop function in input.js: block drops immediately upon c…
xinwei-tee Nov 27, 2015
d689f50
Edited toggleDrop function
xinwei-tee Nov 28, 2015
2df0d52
drop only closest block to hex feature implemented
bohu8 Nov 29, 2015
c335a71
Updated scenarios for toggleDrop; Modified toggleDrop function to use…
xinwei-tee Nov 30, 2015
65fa3e9
assert that blocks are added to Hex, rewrite some test cases to confo…
bohu8 Nov 30, 2015
d82febb
more formal qunit tests for speeds.
bohu8 Dec 1, 2015
b351c46
removed unnecessary code
bohu8 Dec 1, 2015
f386eda
Fixing toggleSpeed issues, qunit tests has to be modified accordingly
Dec 1, 2015
3a63e49
Merge branch 'gh-pages' of https://github.com/bohuce/hextris into gh-…
Dec 1, 2015
1c26846
Revert "Fixing toggleSpeed issues, qunit tests has to be modified acc…
bohu8 Dec 2, 2015
c52d4c0
Fix issue that prevents game from becoming too slow
bohu8 Dec 2, 2015
346de82
fixed issues so game isnt too fast/slow
bohu8 Dec 2, 2015
4c97cde
removed unnecessary code
bohu8 Dec 2, 2015
e779497
fixed issue for game running too fast
bohu8 Dec 2, 2015
2dd1de7
Edit to toggleSpeed wavegen
Dec 2, 2015
e43d6d3
remove unnecessary comments
bohu8 Dec 2, 2015
761d802
Fixed qunit tests
bohu8 Dec 3, 2015
d2ad50a
Added readme.txt explaining the team's contributions and implementati…
Dec 6, 2015
14de33c
Update team06_readme.txt
bohuce Dec 6, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
CPEN 321 L1A Group Members:

Team 06

1. Bo Hu
2. Xin Wei (Patrick) Tee
3. William (Will) Tang


Original Project Infomration:

Hextris
==========

Expand All @@ -7,19 +18,6 @@ Contributors:
- Noah Moroze (@nmoroze)
- Michael Yang (@themichaelyang)

#Conribtions
Please submit pull requests to clay-improvements

# Releases
#### iOS: https://itunes.apple.com/us/app/hextris/id903769553?mt=8
![](http://i.imgur.com/KBYZcf5.png)

#### Android: https://play.google.com/store/apps/details?id=com.hextris.hextris
![](http://i.imgur.com/mxj8yKs.png)

#### Firefox OS: https://marketplace.firefox.com/app/hextris-app
![](http://i.imgur.com/RhECXPg.png)

## Press kit

http://hextris.github.io/presskit/info.html
Expand Down
107 changes: 107 additions & 0 deletions docs/scenarios.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Github issue:
Please allow for a more gradual increase of speed
#129 opened on Mar 3, 2015 by EricViala

1. User Story:
As a player
I want to have the ability to speed up or slow down the game
So that I am able to adjust the game for my skill level

Acceptance Criteria:

Scenario 1.1: Game is currently at 40% of its original speed or higher
Given that the game has started
And the player is currently playing the game
And the game is at 40% of its original playing speed or higher
When the player presses the "Down" arrow key
Then the speed of the dropping blocks will be slowed down by 10%
And the rate of generation of blocks will be slowed down by 10%
And the game continues.

Scenario 1.2: Game is currently at 30% of its original speed (game is very slow)
Given that the game has started
And the player is currently playing the game
And the game is at 30% of its original playing speed
When the player presses the "Down" arrow key
Then the speed of the dropping blocks will remain the same
And the rate of generation of blocks blocks will remain the same
And the game continues.

Scenario 1.3: Game is currently at 170% of its original speed or lower
Given that the game has started
And the player is currently playing the game
And the game is at 170% of its original playing speed or lower
When the player presses the "UP" arrow key
Then the speed of the dropping blocks will be sped up by 10%
And the rate of generation of blocks will be sped up by 10%
And the game continues.

Scenario 1.4: Game is currently at 180% of its original speed (game is very fast)
Given that the game has started
And the player is currently playing the game
And the game is at 180% of its original playing speed
When the player presses the "UP" arrow key
Then the speed of the dropping blocks will remain the same
And the rate of generation of blocks will remain the same
And the game continues.


=====================================================
Github issue:
Alternate color combination to Red/Green, Color blind people may face issue. enhancement
#74 opened on Aug 17, 2014 by tripples

2. User Story:
As a colourblind player
I want to have the ability change the appearence of the colours of the block
So that I am able to distinguish the blocks from each other

Scenario 2.1: User Press Colourblind Toggle Button when in the default colour
Given that the game has started
And the player is currently playing the game
When the player presses the "T" key
Then the colour of the blocks will change to another colour that is friendly for the colourblind
And the game continues.

Scenario 2.2: User Press Colourblind Toggle Button when in a colourblind mode
Given that the game has started
And the player is currently playing the game
And the blocks are currently in a colourblind colour
When the player presses the "T" key
Then the colour of the blocks will change to anothe set of colours that is friendly for the colourblind,
if the player has not cycled through all the colourblind colours yet, otherwise the colour of the blocks
will revert back to the default colour.
And the game continues.

=====================================================
Additional Feature:
Block falls immediately onto center hex upon keypress

3. User Story:
As a player
I want to be able to drop the closest falling block immediately onto the side of the center hex I have rotated to immediately
So that I am able to play the game at a faster pace

Scenario 3.1: User presses Drop Block Toggle Button when a single block is falling
Given that the game has started
And the player is currently playing the game
And a single-block is currently falling
When the player presses the "space" key
Then the currently falling single-block will fall instantly onto the side of the center hex the player has rotated to
And the game continues.

Scenario 3.2: User presses Drop Block Toggle Button when a doubly-joint block is falling
Given that the game has started
And the player is currently playing the game
And a doubly-joint block is currently falling
When the player presses the "space" key
Then the whole joint block will fall instantly onto the side of the center hex the player has rotated to as a single piece
And the game continues.

Scenario 3.3: User presses Drop Block Toggle Button when multiple blocks are falling on the screen
Given taht the game has started
And the player is currently playing the game
And there are 2 blocks both falling onto the center hex on the same lane
Whe the player presses the "space" key
Then only the block closest to the center hex falls instantly while the other falling block remains falling at its original speed
And the game continues.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<script type='text/javascript' src="js/input.js"></script>
<script type='text/javascript' src="js/main.js"></script>
<script type='text/javascript' src="js/initialization.js"></script>
<script type='text/javascript' charset='utf-8' src='cordova.js'></script>
<!--<script type='text/javascript' charset='utf-8' src='cordova.js'></script>-->
<script src="vendor/sweet-alert.min.js"></script>
<link rel="stylesheet" href="style/rrssb.css"/>
</head>
Expand Down
214 changes: 214 additions & 0 deletions js/Block_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
function Block(fallingLane, color, iter, distFromHex, settled) {
settings = {
os: "other",
platform: "nonmobile",
baseScale: 1,
startDist: 340,
creationDt: 9,
scale: 1,
prevScale: 1,
hexWidth: 65,
baseHexWidth: 87,
baseBlockHeight: 20,
blockHeight: 15,
rows: 8,
speedModifier: 0.65,
creationSpeedModifier: 0.65,
comboTime: 310
};
// whether or not a block is rested on the center hex or another block
this.settled = (settled === undefined) ? 0 : 1;
this.height = settings.blockHeight;
//the lane which the block was shot from
this.fallingLane = fallingLane;

this.checked=0;
//the angle at which the block falls
this.angle = 90 - (30 + 60 * fallingLane);
//for calculating the rotation of blocks attached to the center hex
this.angularVelocity = 0;
this.targetAngle = this.angle;
this.color = color;
//blocks that are slated to be deleted after a valid score has happened
this.deleted = 0;
//blocks slated to be removed from falling and added to the hex
this.removed = 0;
//value for the opacity of the white blcok drawn over falling block to give it the glow as it attaches to the hex
this.tint = 0;
//value used for deletion animation
this.opacity = 1;
//boolean for when the block is expanding
this.initializing = 1;
//speed of block
this.iter = iter;
//number of iterations before starting to drop
this.initLen = settings.creationDt;
//side which block is attached too
this.attachedLane = 0;
//distance from center hex
this.distFromHex = distFromHex || settings.startDist * settings.scale ;

this.incrementOpacity = function() {
if (this.deleted) {
//add shakes
if (this.opacity >= 0.925) {
var tLane = this.attachedLane - MainHex.position;
tLane = MainHex.sides - tLane;
while (tLane < 0) {
tLane += MainHex.sides;
}

tLane %= MainHex.sides;
MainHex.shakes.push({lane:tLane, magnitude:3 * (window.devicePixelRatio ? window.devicePixelRatio : 1) * (settings.scale)});
}
//fade out the opacity
this.opacity = this.opacity - 0.075 * MainHex.dt;
if (this.opacity <= 0) {
//slate for final deletion
this.opacity = 0;
this.deleted = 2;
if (gameState == 1 || gameState==0) {
localStorage.setItem("saveState", exportSaveState());
}
}
}
};

this.getIndex = function (){
//get the index of the block in its stack
var parentArr = MainHex.blocks[this.attachedLane];
for (var i = 0; i < parentArr.length; i++) {
if (parentArr[i] == this) {
return i;
}
}
};

this.draw = function(attached, index) {
this.height = settings.blockHeight;
if (Math.abs(settings.scale - settings.prevScale) > 0.000000001) {
this.distFromHex *= (settings.scale/settings.prevScale);
}

this.incrementOpacity();
if(attached === undefined)
attached = false;

if(this.angle > this.targetAngle) {
this.angularVelocity -= angularVelocityConst * MainHex.dt;
}
else if(this.angle < this.targetAngle) {
this.angularVelocity += angularVelocityConst * MainHex.dt;
}

if (Math.abs(this.angle - this.targetAngle + this.angularVelocity) <= Math.abs(this.angularVelocity)) { //do better soon
this.angle = this.targetAngle;
this.angularVelocity = 0;
}
else {
this.angle += this.angularVelocity;
}

this.width = 2 * this.distFromHex / Math.sqrt(3);
this.widthWide = 2 * (this.distFromHex + this.height) / Math.sqrt(3);
//this.widthWide = this.width + this.height + 3;
var p1;
var p2;
var p3;
var p4;
if (this.initializing) {
var rat = ((MainHex.ct - this.ict)/this.initLen);
if (rat > 1) {
rat = 1;
}
p1 = rotatePoint((-this.width / 2) * rat, this.height / 2, this.angle);
p2 = rotatePoint((this.width / 2) * rat, this.height / 2, this.angle);
p3 = rotatePoint((this.widthWide / 2) * rat, -this.height / 2, this.angle);
p4 = rotatePoint((-this.widthWide / 2) * rat, -this.height / 2, this.angle);
if ((MainHex.ct - this.ict) >= this.initLen) {
this.initializing = 0;
}
} else {
p1 = rotatePoint(-this.width / 2, this.height / 2, this.angle);
p2 = rotatePoint(this.width / 2, this.height / 2, this.angle);
p3 = rotatePoint(this.widthWide / 2, -this.height / 2, this.angle);
p4 = rotatePoint(-this.widthWide / 2, -this.height / 2, this.angle);
}

if (this.deleted) {
ctx.fillStyle = "#FFF";
} else if (gameState === 0) {
if (this.color.charAt(0) == 'r') {
ctx.fillStyle = rgbColorsToTintedColors[this.color];
}
else {
ctx.fillStyle = hexColorsToTintedColors[this.color];
}
}
else {
ctx.fillStyle = this.color;
}

ctx.globalAlpha = this.opacity;
var baseX = trueCanvas.width / 2 + Math.sin((this.angle) * (Math.PI / 180)) * (this.distFromHex + this.height / 2) + gdx;
var baseY = trueCanvas.height / 2 - Math.cos((this.angle) * (Math.PI / 180)) * (this.distFromHex + this.height / 2) + gdy;
ctx.beginPath();
ctx.moveTo(baseX + p1.x, baseY + p1.y);
ctx.lineTo(baseX + p2.x, baseY + p2.y);
ctx.lineTo(baseX + p3.x, baseY + p3.y);
ctx.lineTo(baseX + p4.x, baseY + p4.y);
//ctx.lineTo(baseX + p1.x, baseY + p1.y);
ctx.closePath();
ctx.fill();

if (this.tint) {
if (this.opacity < 1) {
if (gameState == 1 || gameState==0) {
localStorage.setItem("saveState", exportSaveState());
}

this.iter = 2.25;
this.tint = 0;
}

ctx.fillStyle = "#FFF";
ctx.globalAlpha = this.tint;
ctx.beginPath();
ctx.moveTo(baseX + p1.x, baseY + p1.y);
ctx.lineTo(baseX + p2.x, baseY + p2.y);
ctx.lineTo(baseX + p3.x, baseY + p3.y);
ctx.lineTo(baseX + p4.x, baseY + p4.y);
ctx.lineTo(baseX + p1.x, baseY + p1.y);
ctx.closePath();
ctx.fill();
this.tint -= 0.02 * MainHex.dt;
if (this.tint < 0) {
this.tint = 0;
}
}

ctx.globalAlpha = 1;
};
}

function findCenterOfBlocks(arr) {
var avgDFH = 0;
var avgAngle = 0;
for (var i = 0; i < arr.length; i++) {
avgDFH += arr[i].distFromHex;
var ang = arr[i].angle;
while (ang < 0) {
ang += 360;
}

avgAngle += ang % 360;
}

avgDFH /= arr.length;
avgAngle /= arr.length;

return {
x:trueCanvas.width/2 + Math.cos(avgAngle * (Math.PI / 180)) * avgDFH,
y:trueCanvas.height/2 + Math.sin(avgAngle * (Math.PI / 180)) * avgDFH
};
}
Loading