# Tower building challenge

I have recently thought of a wonderful relatively old mobile game, called Tower Bloxx. Alhough I'm not really old myself, but it reminded me of childhood and school :)

So this my challenge is a kind of a reference to that good game!

I have (hopefully) looked into any tower question on PPCG and this won't be a dupe.

## Definition

Given N - number of blocks, build a tower of N blocks with the following pattern. The horizontal coordinate is changed with every block.

In order to avoid misinterpretations, here's the "table" of correlations between the n-th block and its horizontal coordinate.

There're no random things there, the coordinate for each block is strictly defined.

These horizontal coordinates are all listed relative to the first block and they are in fact just for readability of the following test cases.

N    X (coord)
------
1    0
2    2
3   -2
4    0
5   -2
6    2
7    goto N=1


On top of the last block, you must smash a roof.

## Input

Positive integer (N).

## Output:

N blocks stacked on top of each other and the roof. Each block is horizontally moved compared to the first block (to either -2, 0, or 2 points), as described in the table.

The block structure:

  *********
* ----- *
* |   | *
* |   | *
* ----- *
*********


Once they are stacked together, the top of the lower block intersects with the bottom of the higher block:

    *********
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
*********


The roof that should be stacked on top of the last, n-th block is:

      *
***
** **
**   **


The block with the roof atop looks like this:

      *
***
** **
**   **
*********
* ----- *
* |   | *
* |   | *
* ----- *
*********


## Test cases below.

Input: 1. Output:

      *
***
** **
**   **
*********
* ----- *
* |   | *
* |   | *
* ----- *
*********


Input: 2. Output:

        *
***
** **
**   **
*********
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
*********


Input: 3. Output:

    *
***
** **
**   **
*********
* ----- *
* |   | *
* |   | *
* ----- *
*************
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
*********


Input: 4. Output:

      *
***
** **
**   **
*********
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
*************
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
*********


Input: 10. Output:

      *
***
** **
**   **
*********
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
*************
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
*************
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
*************
* ----- *
* |   | *
* |   | *
* ----- *
***********
* ----- *
* |   | *
* |   | *
* ----- *
*********


## Scoring

Code golf, shortest wins!

Trailing invisible stuff is allowed.

• Are the coordinates relative to the first block or the previous block? Because first you said „first“ and then „previous“. – O.O.Balance Apr 3 '18 at 20:05
• @O.O.B The coordinates stated in tables are just for readability, and they are relative to the first block. Each next block is moved relative to the previous block. I see no conflict in wording. – nicael Apr 3 '18 at 20:08
• In fact, I believe anyone can see the pattern by looking just in the test cases without seeing the table and anything else. – nicael Apr 3 '18 at 20:08
• While the test cases are unambiguous, the wording „Each block is horizontally moved compared to the previous block, as described in the table.“ is misleading imo. – O.O.Balance Apr 3 '18 at 20:14
• @o.O edited. 😏 – nicael Apr 3 '18 at 20:18

# Charcoal, 48 bytes

ＦＮ«Ｍ×Ｘ±¹ιＩ§224ι←Ｂ⁹±⁶*↗↗↑↓²→⁵↖↑²←⁵↖»ＧＨ<⁵*Ｍ⁷←ＧＨ<⁴*


Try it online! Link is to verbose version of code. Explanation:

ＦＮ«


Draw N Blox.

Ｍ×Ｘ±¹ιＩ§224ι←


Adjust the horizontal position before drawing each Blox.

Ｂ⁹±⁶*


Draw the outer wall of the Blox.

↗↗↑↓²→⁵↖↑²←⁵↖»


Draw the inner wall of the Blox.

ＧＨ<⁵*Ｍ⁷←ＧＨ<⁴*


Raise the roof.

# JavaScript (ES6), 206 bytes

Saved 2 bytes thanks to @kamoroso94

f=(n,k=0)=>n--?f(n,k+1)+${n? :23456}0110.replace(/./g,c=>' '.repeat('240204'[k%6])+'* ----- ,* | | , , **, ** *, ** *,********'.split,[c]+* )+(k%6<2?' ':'')+'*'.repeat(k?k%3<2?11:13:9):''  Try it online! •  23456  doesn't need to have backticks around it, save two bytes. – kamoroso94 Apr 3 '18 at 21:59 • @kamoroso94 Thanks, nice catch! – Arnauld Apr 3 '18 at 22:01 • @kamoroso94 Also, use \23456\ to have backticks in code: 23456. – user202729 Apr 4 '18 at 4:47 # SOGL V0.12, 53 bytes ø.∫"│“3─wι«@*ο"²¹EiΕbK⁷‘╬$.F=?"¦○⌠Q°‘5nΓ;+}┼JGKh╬8;++


Try it Here!

# Python 2, 258 bytes

n=input()
l=[[4,2,4,0,2,0][(n-i)%6]for i in[0]+range(n)+[n-1]]
for i,v in enumerate(l[:-1]):s=v*' ';a,b=s+'* ----- *',s+'* |   | *';x,y=sorted([l[i+1],v]);print'\n'.join(([a,b,b,a]if i else[s+'    *',s+'   ***',s+'  ** **',s+' **   **'])+[' '*x+'*'*(9+y-x)])


Try it online!

# JavaScript (Node.js), 238 bytes

n=>{for(l=n>2&&2,s=i="";i<n;l=A)
s=(y=(p=" "[r="repeat"](A="240204"[i++%6]-(n<3)*2))+* ----- *
)+(x=p+* |   | *
)+x+y+" "[r](l>A?A:l)+"*"[r](9+Math.abs(A-l))+
+s
return p+    *
${p} ***${p}  ** **
${p} ** **${p}*********
+s}


Try it online!