This is a simple program to exchange tiles. Here the use has to click on a tile drag the mouse and release the mouse in the nearby tile(horizontally or vertically). The colors of the tiles gets exchanged.
Here is a snap shot of the program.
It started out as a mesh program and i modified it to have different colors for the tiles. If you want further modification say vary dx,dy,maxx,maxy and choose a texture on the tiles.... as soon as the tiles exchanged form the correct image the game should end. The effort spent in making this game is less than three hours.
Ping me on google chat if you want the source. Will give to anyone interested(123 lines of code). By may end will give out the source on the blog for anyone to download.
Change of mind...====> Here <====is the code for the above project.
I have now found time to develop the project a bit further. I have succeeded in allotting colours such that not more than two squares have the same colour. After that when we exchange the tiles so that three same coloured tiles are in a line they vanish and white space created gets filled by movement of tiles above downwards.
Next i want to implement new tiles created at the top to fill the ones left empty. For now this is what i have done. There are some problems still to be ironed out. It is worthless to mention them here at this point. So download the game from ====> here <====and try to tinker with it.
Change of mind...====> Here <====is the code for the above project.
I have now found time to develop the project a bit further. I have succeeded in allotting colours such that not more than two squares have the same colour. After that when we exchange the tiles so that three same coloured tiles are in a line they vanish and white space created gets filled by movement of tiles above downwards.
Next i want to implement new tiles created at the top to fill the ones left empty. For now this is what i have done. There are some problems still to be ironed out. It is worthless to mention them here at this point. So download the game from ====> here <====and try to tinker with it.
Sir, kindly share the modification details
ReplyDeleteI can try and make a 3x3 grid with image on it. Give me some more time.
DeleteSir, I am doing this project for my Computer Graphics mini project. I am asked to make it work something like candy crush, that is same color tiles should disappear or something like that. Please me with it
DeleteIn that case you need to do two things...1) While generating colors randomly in the squares ensure that no three colors are assigned in a row or column 2) after squares are exchanged remove(vanish) the ones in a row(column) and then move all tiles above them down. Can u do these things urself?
DeleteSee the new code posted... after that i don't have any more code.
DeleteThank you sir..
Deletesir, when I try run your code, I get error
ReplyDeletemain.cpp:228: error: 'usleep' was not declared in this scope
can u help me?
Try to read through this Q&A forum for the answer...
Deletehttp://stackoverflow.com/questions/10976176/c-error-sleep-was-not-declared-in-this-scope
How can I map a texture on to tiles based on colour
ReplyDeleteYou can do that with a little bit of effort. Divide a photo into as many tiles as you need. Number each tile. Store the correct number sequence in a list. Shuffle this list after taking backup. Draw the tiles after shuffle. Challenge user to swap and solve. Stop game once correct sequence is made.
Delete