Add unicode snake printing
Removed a lot of unused and commented code
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
## Snake in rust using [ncurses](https://docs.rs/ncurses)
|
||||
## Snake in rust using [ncurses](https://docs.rs/ncurses) crate
|
||||
|
||||
The game is playable
|
||||
|
||||
@@ -18,7 +18,19 @@ esc or p to pause
|
||||
|
||||
Click the image for asciinema
|
||||
|
||||
[<img src="images/screenshot.png" width="650" />](https://asciinema.org/a/PtMG7dghPAEZ7tNgx70sKplKq?autoplay=1)
|
||||
[<img src="images/screenshot.png" width="650" />](https://asciinema.org/a/FVB1DZmA7lVK4BILFkzkreMQ9?autoplay=1)
|
||||
|
||||
#### Need unicode support in terminal to print the snake
|
||||
|
||||
The unicode characters used are:
|
||||
|
||||
- 0x0298 ʘ
|
||||
- 0x2550 ═
|
||||
- 0x2551 ║
|
||||
- 0x2554 ╔
|
||||
- 0x2557 ╗
|
||||
- 0x255a ╚
|
||||
- 0x255d ╝
|
||||
|
||||
#### Todo :construction:
|
||||
|
||||
@@ -28,13 +40,16 @@ Click the image for asciinema
|
||||
- [ ] Implement Highscore System
|
||||
- [ ] Make the ui
|
||||
- [ ] Internal Implementation
|
||||
- [x] Use unicode charachters to draw the snake
|
||||
|
||||
#### Bugs :bug:
|
||||
|
||||
- ~~Snake going through the walls~~
|
||||
- ~~Food spawning in the walls~~
|
||||
- ~~Boxdraw characters not rendering properly~~
|
||||
- Remove all the logging in the ui
|
||||
- Pausing delayed if esc is pressed but not if p is pressed.
|
||||
- The game flickers a lot after sometime (probably due to the constant redrawing of the whole board every tick)
|
||||
|
||||
#### Maybe in the future
|
||||
|
||||
@@ -42,19 +57,32 @@ Click the image for asciinema
|
||||
|
||||
#### Notes
|
||||
|
||||
A few notes about the complexity of the game and how I should improve the game
|
||||
A few notes about the game and how I should improve the game
|
||||
|
||||
<details>
|
||||
<summary>Read More</summary>
|
||||
<summary>A few notes about time complexity and redrawing with ncurses</summary>
|
||||
|
||||
The complexity of the program is O(n) every tick (time which changes relative to the speed)
|
||||
> The complexity of the program is O(n) every tick (time which changes relative to the speed)
|
||||
|
||||
However the place, I can improve is the redrawing of the game
|
||||
> However the place, I can improve is the redrawing of the game
|
||||
|
||||
As of commit
|
||||
<a href="https://github.com/uttarayan21/snake/commit/de66f7d249a56f883dd632598a4178b1bd1320ba">f9be68e</a>
|
||||
the game redraws the total board and the total snake every tick.
|
||||
> At the time of writing the in commit
|
||||
> <a href="https://github.com/uttarayan21/snake/commit/de66f7d249a56f883dd632598a4178b1bd1320ba">f9be68e</a>
|
||||
> the game still redraws the total board and the total snake every tick.
|
||||
|
||||
I think this can be improved by only drawing the parts of the snake and the board when needed
|
||||
> I think this can be improved by only drawing the parts of the snake and the board when needed
|
||||
|
||||
</details>
|
||||
<br>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Rust specific stuff I learned</summary>
|
||||
|
||||
> [char](https://doc.rust-lang.org/stable/std/primitive.char.html) and [std::char](https://doc.rust-lang.org/stable/std/char/index.html) are different
|
||||
|
||||
> [char](https://doc.rust-lang.org/stable/std/primitive.char.html) is the primitive type [std::char](https://doc.rust-lang.org/stable/std/char/index.html) is the char module. All the functions are not completely same for both (as of rust v1.49.0)
|
||||
|
||||
> [ncursesw](httsp://docs.rs/ncursesw) is not needed to print unicode characters. I have no clue where I got that idea from.
|
||||
|
||||
</details>
|
||||
|
||||
Reference in New Issue
Block a user