Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Tetris-dropping shapes
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Neja




PostPosted: Thu May 20, 2004 4:34 pm   Post subject: 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".

code:

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;

code:
    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
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Thu May 20, 2004 6:41 pm   Post subject: (No subject)

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




PostPosted: Sun May 23, 2004 10:45 am   Post subject: (No subject)

Asian your just getting lazy now. Giving people complete source code? Your a lazy drunk. No offense and all Wink
AsianSensation




PostPosted: Sun May 23, 2004 1:43 pm   Post subject: (No subject)

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




PostPosted: Mon May 24, 2004 8:09 pm   Post subject: (No subject)

Wow, you're nicer online than in real life Wink
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: