I have now introduced the ability to remove a placed block by clicking/touching it again. It will add the block back to your block count. The code was relatively simple as shown below:
for (var i = 0; i < rectsCreated.length; i++) {
if (x > rectsCreated[i].x && x < rectsCreated[i].x + rectsCreated[i].w &&
y > rectsCreated[i].y && y < rectsCreated[i].y + rectsCreated[i].h)
{
blockCount++;
document.getElementById("blockNum").innerText = blockCount;
createBlock = false;
rectsCreated.splice(i, 1);
}
}
It just checks the rectangle area in each created block to see whether the click is actually inside of it. If it is, increment the block count and remove the block from the screen.
This comes in handy for the Fish level that was added as well. The Fish level is a survive as long as you can level. You need to survive by staying above the spikes as long as you can while the fish chase after you and destroy your blocks.
Experiments
ToDo List/Game
ToDo List/GamePlace a description in the Items field and put a time (in minutes) for how long the task will take and click Add Item. When complete, click the Complete button and that will strengthen your character.
Platformer
Desktop Version Mobile VersionPlayer must try to collect the diamond. They can click/touch the screen to create blocks to get to the diamond. Enemies can destroy any created blocks on touch.
Created Blocks can be removed by clicking/touching them again.
Unity
Unity Game Tutorial
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment