changing luminosity by rgb values.(my tetris game project)
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: changing luminosity by rgb values.(my tetris game proje
yeah:D.i'm a newbie programmer for now so my programs tend to be very complicated,but once i finish them and see them as a whole i can find way's to make them simpler:)
altough after a bit of research i found out that for simpler collision detection on tetris is better to have the internal representation grid made from a 2d array,the problem was that when i was trying to check if the next position for the shape is empty the code would also check some of the squares forming the current shape,so since they not empty they would practicaly collide with they'r own squares (like moving a vertical line down,the bottom square would pass the check but all others would fail because the square tehy'd go to are ocupied by the current shape squares)
so i basicaly went on the principle of d3d frame building,made a square grid to hold the moving shape which i'm clearing after each frame,and the solid shape square grid to hold the settled pieces ,
so when checking i just have to see if the squares forming the new shape will be in empty squares of the solid square grid,
anyway my code is about 1000 lines long,is that too complicated?
altough after a bit of research i found out that for simpler collision detection on tetris is better to have the internal representation grid made from a 2d array,the problem was that when i was trying to check if the next position for the shape is empty the code would also check some of the squares forming the current shape,so since they not empty they would practicaly collide with they'r own squares (like moving a vertical line down,the bottom square would pass the check but all others would fail because the square tehy'd go to are ocupied by the current shape squares)
so i basicaly went on the principle of d3d frame building,made a square grid to hold the moving shape which i'm clearing after each frame,and the solid shape square grid to hold the settled pieces ,
so when checking i just have to see if the squares forming the new shape will be in empty squares of the solid square grid,
anyway my code is about 1000 lines long,is that too complicated?
Re: changing luminosity by rgb values.(my tetris game proje
It could probably be made simpler, but whatever works for you virus. It's all a learning experience bro.
Chili
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: changing luminosity by rgb values.(my tetris game proje
i finally made it:D
had a few problems on how to update the solid blocks,as i wanted them to stick with eachother when falling after a full line is made and the whole line is destroyed
first try only the line above the empty was moving,then i coded a loop to do multiple passing before going out of UpdateBloks function.
altough if i'd stay to say how many trials and errors i had doing this would probably get to page 3 by the end of it
basically my coding practice is sticking with outcome i want from a code part and changing that code until it does exacly what i want,in the process i get to add other extra stuff to get the same outcome ,
the three main design concepts were :
-get a square table
-draw a shape and send it towards the bottom and being controled by key movement
-check if any line is filled then empty it and move any other blocks on top of it one line down each
it was a lot of learning experience doing it and i'd recommend any newbie to give it a try at
least,there will be lots of dead ends but once u get a part of it to work u get an idea on how to make the next one to work.
kinda like the game,can't put a piece on the top lines without building from the bottom,and cant be a whole line if ther's empty spaces.
had a few problems on how to update the solid blocks,as i wanted them to stick with eachother when falling after a full line is made and the whole line is destroyed
first try only the line above the empty was moving,then i coded a loop to do multiple passing before going out of UpdateBloks function.
altough if i'd stay to say how many trials and errors i had doing this would probably get to page 3 by the end of it
basically my coding practice is sticking with outcome i want from a code part and changing that code until it does exacly what i want,in the process i get to add other extra stuff to get the same outcome ,
the three main design concepts were :
-get a square table
-draw a shape and send it towards the bottom and being controled by key movement
-check if any line is filled then empty it and move any other blocks on top of it one line down each
it was a lot of learning experience doing it and i'd recommend any newbie to give it a try at
least,there will be lots of dead ends but once u get a part of it to work u get an idea on how to make the next one to work.
kinda like the game,can't put a piece on the top lines without building from the bottom,and cant be a whole line if ther's empty spaces.
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: changing luminosity by rgb values.(my tetris game proje
ther's something strange hapening, when in debug mode it runs fine,but when in release it messes up when changing shape facing near the edge,altough ther's a check in place to not change facing if too close,instead pick a spot further away to draw it.
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: changing luminosity by rgb values.(my tetris game proje
actualy i think it skips some of the code,all shapes with x coord being offset by1 to he left from the shape edge get offscreen when in release mode:/
EDIT:
what the .... the release mode total;y screwed my code:/ now there's no checks for full lines either..
is there a huge difference in between the modes that i don't know about yet ???
EDIT:
what the .... the release mode total;y screwed my code:/ now there's no checks for full lines either..
is there a huge difference in between the modes that i don't know about yet ???
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: changing luminosity by rgb values.(my tetris game proje
turns out to be the fault of optimization procedure done by the compiler,i've disabled optimization for release mode in project settings and it works fine,but now i'm just thinking if my code was wrong how to make it to run with optimization?
Re: changing luminosity by rgb values.(my tetris game proje
Strange stuff bro. I've had problems with release/debug, but only because I had cloned the solution folder and it was still using an absolute path to the files in the old folder. Did you try cleaning the solution and then rebuilding in Release configuration? I don't see how optimization should change the behavior of your program.
Chili
- viruskiller
- Posts: 399
- Joined: June 14th, 2012, 5:07 pm
Re: changing luminosity by rgb values.(my tetris game proje
yeah,i looked more into it but can't find anything that could go wrong unless the optimization totally messes up with how variables are handled,it seems that whenever kx enters the 0x coord of the table the shape gets sucked out of the table,even stranger is it only happends with shapes that have more than 2 squares touching the edge,
i have like 3 checks for the min x value to not go below 0 and somehow it misses them all,although the shape gets off screen once it moves into the x=0 column not when trying to move beyond it,so whenever the min x value gets to 0 the kx gets decreased drastically and the shape goes offscreen..
anyway i've decided not to bang my head around it and move on learning new stuff and maybe start a different project ,maybe my coding concepts are not yet ready to work with release mode,once i'll get a better understanding on what optimization does i may be able to find a fix..
also i'd like some honest opinion about the code,i've tryed to keep it simple and with lots of comments,but this is just my second c++ direct x game (first one was tic tac toe) so pointing where i was wrong or right at this stage could help me get better in future projects
i have like 3 checks for the min x value to not go below 0 and somehow it misses them all,although the shape gets off screen once it moves into the x=0 column not when trying to move beyond it,so whenever the min x value gets to 0 the kx gets decreased drastically and the shape goes offscreen..
anyway i've decided not to bang my head around it and move on learning new stuff and maybe start a different project ,maybe my coding concepts are not yet ready to work with release mode,once i'll get a better understanding on what optimization does i may be able to find a fix..
also i'd like some honest opinion about the code,i've tryed to keep it simple and with lots of comments,but this is just my second c++ direct x game (first one was tic tac toe) so pointing where i was wrong or right at this stage could help me get better in future projects
Re: changing luminosity by rgb values.(my tetris game proje
I tried to look at that problem too, without finding anything. Cool game btw, you should still add stuff to it like score and maybe a "shadow" of where the block is gonna fall, and if you still want more suggestions, something cool would be something I remember from the tetris on nintendo 64, where if you made a square with the blocks it makes a golden or silver square that gives more points.
My best guess about your problem would be that the array gets somehow messed when you leave its area. I remember from my unfinished scrolling map "prototype" that when I left the map array at the maximum end, the map would simply loop from the beginning, creating a never ending map loop.
You code looks good. The only thing I didn't like is how you squeeze all the code blocks together without leaving some space in between, but that personal prefrence. But as I suggested, maybe you should look up or figure out a better way to handle the rotation and movement etc.
My best guess about your problem would be that the array gets somehow messed when you leave its area. I remember from my unfinished scrolling map "prototype" that when I left the map array at the maximum end, the map would simply loop from the beginning, creating a never ending map loop.
You code looks good. The only thing I didn't like is how you squeeze all the code blocks together without leaving some space in between, but that personal prefrence. But as I suggested, maybe you should look up or figure out a better way to handle the rotation and movement etc.
ʕ •ᴥ•ʔ