The blogging has been a bit slow due to exams and assignments. One thing that I haven't mentioned which saved my life and has saved me from a lot of hassle to is the "True Type Fonts" functionality in SDL.
The idea is that now I do not have to blit images so to show a person is writing rather whenever the user is writing onto the screen the true type font file makes sure of the image created. The size and colour included.
Sudoku SDL C++
Friday, 28 October 2016
True Type Fonts usage
I had been particularly concerned about the number images that were coming onto the screen. The pink background was not vanishing and also caused me some library errors which made me lag behind in my game. After much prodding in lazyfoo tutorials I got to know the concept of True Type Fonts.
Some libraries offer the functionality of writing onto your game with their inbuilt functions. SDL is among them. By defining font and size of your writing specified in a .ttf file one can write onto their programs without blitting images onto screen and worrying about their classes, positioning etc.
Some libraries offer the functionality of writing onto your game with their inbuilt functions. SDL is among them. By defining font and size of your writing specified in a .ttf file one can write onto their programs without blitting images onto screen and worrying about their classes, positioning etc.
Revised Algorithm for Solution and Generation
The algorithm I used for Solution generation worked by filling in each cell as it loops through the grid. Before filling a cell, it checks whether the numbers within its row and column are the same as the proposed number, and if it is it tries another. If it gets to the end of the list, then no number is suitable so it backtracks to the previous cells and checks whether it can swap the numbers.
Because in the case of Sudoku board generation random generation of numbers was paramount therefore I used
https://bytes.com/topic/c/answers/578206-random-number-generator-use-random_shuffle
and
http://stackoverflow.com/questions/12540918/shuffle-vector-in-c/12541009
Even though the game winning condition does not work in my project by employing the above mentioned method I do not waste my memory into file reading of solved boards and then making my game board. I am able to generate infinite number of different boards without wasting any memory.
Because in the case of Sudoku board generation random generation of numbers was paramount therefore I used
random_shuffle
. Help used was from :https://bytes.com/topic/c/answers/578206-random-number-generator-use-random_shuffle
and
http://stackoverflow.com/questions/12540918/shuffle-vector-in-c/12541009
Even though the game winning condition does not work in my project by employing the above mentioned method I do not waste my memory into file reading of solved boards and then making my game board. I am able to generate infinite number of different boards without wasting any memory.
Tuesday, 25 October 2016
Week 4
There have been many issues in the project this week. I have been facing library errors and bugs. Considering my approach of taking everything bit by bit and then building over it had more or less failed I started building my program by taking everything together.
The bugs that still exist are:
The bugs that still exist are:
Friday, 7 October 2016
Week 3
This week I was concerned with the Sudoku board generation. The method that a friend told me about seems the easiest in the generation of random Sudoku boards.
The method I'll follow is that I'll take 4-5 solved Sudoku puzzles. These puzzles will then be stored in a data structure (preferably array). Randomly after every sudoku board generation some numbers of the Sudoku puzzle will not show. For varying difficulty I will make more numbers to not show on the board.
Solved Sudoku board( one of the many):
Randomly not showing some elements of the board:
For a relatively difficult level:
The method I'll follow is that I'll take 4-5 solved Sudoku puzzles. These puzzles will then be stored in a data structure (preferably array). Randomly after every sudoku board generation some numbers of the Sudoku puzzle will not show. For varying difficulty I will make more numbers to not show on the board.
Solved Sudoku board( one of the many):
Randomly not showing some elements of the board:
For a relatively difficult level:
Tuesday, 4 October 2016
Week 2
So far the progress has been slow. I have been solving some Sudoku puzzles to get a deeper idea of how Sudoku game works.
I have been successful in creating the basic game board for Sudoku. I have also made the writing class by which as the user inputs numbers subsequent images of the numbers are displayed on the screen
So far only I have been only focusing on the GUI aspect of the game.
I have been reading up on mouse and keyboard events and have been able understand the keyboard events in SDL from this tutorial: http://lazyfoo.net/tutorials/SDL/04_key_presses/index.php
Helpful websites to note:
- https://www.youtube.com/watch?v=xMDo35oFef0
- http://www.codeproject.com/Articles/33894/Creating-a-Sudoku-game
- http://www.dreamincode.net/forums/topic/76948-sudoku-game-in-c/
- http://www.cplusplus.com/forum/beginner/32467/
- http://lazyfoo.net/tutorials/SDL/04_key_presses/index.php
- http://www.sdltutorials.com/sdl-tutorial-basics
- http://stackoverflow.com/questions/21007329/what-is-a-sdl-renderer
Week 1
Introduction:
Sudoku is a logic-based, combinatorial number
placement puzzle.
The objective is to fill a 9×9 grid with digits so that each column, each row,
and each of the nine 3×3 subgrids that compose the bigger grid contain all of
the digits from 1 to 9. The puzzle setter provides a partially completed grid,
which for a well-posed puzzle has a unique solution.
Objectives:
The objective of my application will be to emulate the above
mentioned properties of the game with three levels of increasing difficulty and
a professional looking gui. The boards for the levels will not be randomly
generated and will be fed into the program beforehand.(However if time remains
I might work on a random generation of the board)
My application will run both by mouse and keyboard.
Tools:
Libraries to be used: SDL
Programming Language: C++
Tasks to do:
·
Make splash screens
·
Make a GUI interface for the game board
·
Winning condition
·
Error detection
·
Keyboard and mouse handling
Subscribe to:
Posts (Atom)