C++ Program: Number Puzzle Game on Turbo-C++

0
2663

In this programs a set of numbers are spread randomly and the user has to put numbers in correct format.

C++ Program: Number Puzzle Game on Turbo-C++

At line 9 we have a drawRectangle function which is used to draw a rectangle of given dimension on screen when graphics mode is there. In the main function first we have cleared the screen then defined some local variables and an interData array which will be used to store the data in program and in this array we have randomly filled numbers which are less than 16 and greater than equal to 0. Then we have initialized the graphics mode using initgraph function in the graphics.h header file.
C++ Program: Puzzle Game on Turbo-C++
Then we print the numbers on the screen as we have filled them in interData array. And then use the drawRectangle function to draw some fitting rectangles on the screen. Then we have printed the message on screen and set the background color to red of our graphics screen and prompt user how to use this game for playing. After this we have exited the graphics mode. Now we ll do everything in normal output mode.

C++ Program: Puzzle Game on Turbo-C++

After this we start the game prompting user to use arrow keys for moving different numbers across the screen and keep checking at each step if required pattern has been made by user, if user comes to the required pattern then we simply declare him win else we keep playing game keeping boundary conditions in our code logic.

C++ Program: Puzzle Game on Turbo-C++

Rest of the logic in code is for to get the value corresponding to each key press by the user. We identify from the ascii value of key which key has been pressed by the user and then accordingly we adjust values in our data structure. In this way we keep on doing this unless wither user wants to exit or he has reached to the particular pattern.

Here are some screenshots of running program-

Download C++ Program: Puzzle Game on Turbo-C++

[sociallocker]
Download C++ Program: Puzzle Game on Turbo-C++
[/sociallocker]

Save

LEAVE A REPLY

Please enter your comment!
Please enter your name here