The Quest for Tetris... Part 1
Hello all,
My Tetris project has many problems, and I need your help.
PROBLEM 1: My blocks can fly off the right of the screen. I adjusted the right bounds of the screen but still it doesn't work. It can also store values from the 9th row (I only want 8), which is weird because my array has 8 placeholders, and the very left column works fine. (SOLVED)
PROBLEM 2: When I tell the blocks to move, they move twice for every one button press. It will sucessfully detect a collision if there is something in the way of it moving the second time, but it doesn't move one by one. (this may be more of an SDL problem, but it's easier to post it here...) (SOLVED)
PROBLEM 3: My new line-removing code doesn't work. Every time I use it, it removes every line above it... (see t001.h)
Updated Code
Thanks to all in advance for the help!
adam_o
EDIT 1: Updated code.
EDIT 2: Updated code and added Problem 3.
EDIT 3: Updated code and updated Problem 3.
[Edited by - adam_o on June 3, 2007 3:30:28 PM]
Problem #1... solved! I don't know why, but it was ignoring the new code that I had put in there, so now it stays within the bounds... (code updated in case I changed something without knowing it)
You never check what kind of event it is when checking which key is pressed. This means that you will move the piece both when pressing down the key, and also when releasing it. You have to check whether it is a SDL_KEYDOWN event, or a SDL_KEYUP event.
Quote:Original post by Perost
You never check what kind of event it is when checking which key is pressed. This means that you will move the piece both when pressing down the key, and also when releasing it. You have to check whether it is a SDL_KEYDOWN event, or a SDL_KEYUP event.
Ok, so the code says:
if(event.key.keysym.sym == SDLK_LEFT) { left_check();}
So how would I fix this, assuming that I want to move the pieces on keydown or whatever?
Further down in the code you have a switch(event.type) where you check for SDL_USEREVENT and SDL_QUIT. You should add the SDL_KEYDOWN and SDL_KEYUP cases too, and handle the keys there instead. As you do now you check which key was pressed everytime an event happen, regardless of the type of the event.
while(sdl_poolevent(&event)){switch(event.type) case SDL_KEYDOWN: if(event.key.keysym.sym == SDLK_LEFT) { left_check(); } break;}
basicly something like this
Thank you both for the help... I will now go back, make the corrections, and then figure out what new problems I have...
Problem 3 added along with my updated code. I knew it wouldn't be long before something popped up...
Your link doesn't work. But the most probable cause is that you are going out of bounds of an array. But if it fires up the debugger, don't you think your IDE is trying to tell you something? Perhaps you can try and use the debugger [smile]
Quote:Original post by Perost
Your link doesn't work. But the most probable cause is that you are going out of bounds of an array. But if it fires up the debugger, don't you think your IDE is trying to tell you something? Perhaps you can try and use the debugger [smile]
Heh. One letter was wrong in my whole url. I just figured out what it was trying to tell me... for my clearing detection, I started at the top and worked up instead of down. But now my problem is that when it clears a row, it also clears everything on top of that row.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement