Skip to main content
gamedev.net
🔒 Locked

problems programming a tetris clone

Started by da_cobra Dec 2, 2001 at 10:45 AM 2 replies 200+ views
Original Post
da_cobra
da_cobra
I already posted this one in the "beginners" forum but there is no response there as of yet so that''s why I post it again here, because I''m really desperate i''m good stuck in this game I already have a random block that I can move in my playfield now when I hit the floor (or another block) it should be placed on my playfield at that place My playfield is a 20x10 array Playfield [20] [10] and my blocks are also put in an array like this blocks = 6 ; // 7 blocks rotation = 3 ; // 4 rotations a block block [Blocks] [rotation] [4] [4] those [4] [4] are my blocks, like this by example 0000 0100 0110 0010 0100 0110 0111 0100 0110 0000 0100 0000 a 1 is for a red block, 2 purple, ..... now when I place that block in my playfield (array) I go to my function BlockInArray() and now it places that block on 3 positions in my array?!? everytime 10 blocks between and my function is only runned once (I used a timer to check) here''s my function : void BlockInArray() { x = ((Pos_X/16)-19) ; // calculate x/y y = ((Pos_Y/16)-9) ; // position in playfield for (i=0; i<4; i++) { for (j=0; j<4; j++) { if (blocks [block] [rotation] [j]) // check if there is a cube in that array { // if so position it beginning at x & y PlayField [x+i] [y+j] = blocks [block] [rotation] [j] ; } ; // end of if } ; // end of for j } ; // end of for i Pos_X = PlayfieldX+48 ; // position new block in the Pos_Y = PlayfieldY ; // middle top of playfield RandomPiece() ; } // end of BlockInArray() I''m really desperade, I''ve been breaking my head over this problem now for 2 weeks :/ Big thanx in advance if any one can help me (if you want me to send the complete code to you then send an email to s_noppe@hotmail.com or contact me on MSN or icq 3347831)
Enigma
Enigma
Don''t know if this is the only problem in your code, but blocks should equal 7, not 6 (indices 0, 1, 2, 3, 4, 5 and 6) and rotation should equal 4, not 3 (indices 0, 1, 2 and 3)

Hope that helps

Enigma
------
...work who isn''t pulling their...
da_cobra
da_cobra
no that''s not my problem

it''s such a strange problem that I have to send my code to someone to debug it, because it''s very hard to find the bug this way

but thanx anyway for your reply
Advanced Bug
Advanced Bug
If I correctly understand what your function is doing, you must write:

  
if(blocks[block][rotation][i][j])
Playfield[x + i][y + j] = blocks[block][rotation][i][j];


instead of

  
if(blocks[block][rotation][j])
Playfield[x + i][y + j] = blocks[block][rotation][j];



Edited by - Advanced Bug on December 4, 2001 3:49:40 AM

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.