
-----------------------------------
Neja
Thu May 20, 2004 4:34 pm

Tetris-dropping shapes
-----------------------------------
Making Tetris for my final.  I'm using 2-d arrays to set my blocks and grid up but the problem is that I  really suck at it.  I have no idea how to drop these "virtual shapes". 

 
var gridy, gridx : int := 30
% Grid.
for counter : 1 .. 18
    gridy := gridy + 20
    Draw.Line (30, gridy, 230, gridy, 3)
end for
for counter : 1 .. 10
    gridx := gridx + 20
    Draw.Line (gridx, 30, gridx, 390, 3)
end for

proc SetUpBlock (var block : array 0 .. 3, 0 .. 3 of int)
    /*
     . []
     . [][][]   0
     .
     . [][][]
     . []       1
     .
     . [][]
     . [][]     2
     .
     . [][][]
     .   []     3
     .
     . [][][][] 4
     .
     . [][]
     .   [][]   5
     .
     .   [][]
     . [][]     6
     .
     .
     */
    for x : 0 .. 3
        for y : 0 .. 3
            block (x, y) := 0
        end for
    end for

    var whatblock : int := Rand.Int (0, 6)
    case whatblock of
        label 0 :
            block (0, 3) := 1
            block (0, 2) := 1
            block (1, 2) := 1
            block (2, 2) := 1
        label 1 :
            block (0, 1) := 1
            block (0, 2) := 1
            block (1, 2) := 1
            block (2, 2) := 1
        label 2 :
            block (0, 3) := 1
            block (1, 3) := 1
            block (0, 2) := 1
            block (1, 2) := 1
        label 3 :
            block (0, 3) := 1
            block (1, 3) := 1
            block (2, 3) := 1
            block (1, 2) := 1
        label 4 :
            block (0, 3) := 1
            block (1, 3) := 1
            block (2, 3) := 1
            block (3, 3) := 1
        label 5 :
            block (0, 3) := 1
            block (1, 3) := 1
            block (1, 2) := 1
            block (2, 2) := 1
        label 6 :
            block (0, 2) := 1
            block (1, 2) := 1
            block (1, 3) := 1
            block (2, 3) := 1
    end case

end SetUpBlock

I already have the rotations finished (thanks to Martin). Here is what I have that I thought would work for dropping;

    for counter : 1 .. 4
        for counter2 : 1 .. 4
            if block (counter, counter2) = 1 then
                Draw.Fill (31 + (20 * counter), 369 - (20 * counter2), 3, 3)
            end if
        end for
    end for

-----------------------------------
AsianSensation
Thu May 20, 2004 6:41 pm


-----------------------------------
I PMed you the full code for a tetris game, dodge released it on some other site.

if you have any more questions, ask anytime.

-----------------------------------
Delta
Sun May 23, 2004 10:45 am


-----------------------------------
Asian your just getting lazy now. Giving people complete source code? Your a lazy drunk. No offense and all ;)

-----------------------------------
AsianSensation
Sun May 23, 2004 1:43 pm


-----------------------------------
lol, it's ok, she's a friend of mine. So I figured I'll give her the source, and explain at school all the stuff, so I don't have to find the source code again.

-----------------------------------
Neja
Mon May 24, 2004 8:09 pm


-----------------------------------
Wow, you're nicer online than in real life  :wink:
