Friday, February 27, 2015

Tiles Exchange like Candy Crush

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.

10 comments:

  1. Sir, kindly share the modification details

    ReplyDelete
    Replies
    1. I can try and make a 3x3 grid with image on it. Give me some more time.

      Delete
    2. Sir, 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

      Delete
    3. In 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?

      Delete
    4. See the new code posted... after that i don't have any more code.

      Delete
  2. sir, when I try run your code, I get error
    main.cpp:228: error: 'usleep' was not declared in this scope
    can u help me?

    ReplyDelete
    Replies
    1. Try to read through this Q&A forum for the answer...
      http://stackoverflow.com/questions/10976176/c-error-sleep-was-not-declared-in-this-scope

      Delete
  3. How can I map a texture on to tiles based on colour

    ReplyDelete
    Replies
    1. You 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