C/C++ How to Implement the Snake Game Using Struct and Constants in C++?

  • Thread starter Thread starter FallArk
  • Start date Start date
  • Tags Tags
    Game
Click For Summary
The discussion focuses on implementing a Snake game in C++ using structs and constants. Key points include defining the game board's dimensions with NUMROWS and NUMCOLS, and the snake's maximum length with TAILLENGTH. The player ('U') starts at the upper left corner, while the opponent ('X') starts at the lower right corner. The game logic requires careful management of player movements, ensuring that the snake does not exceed its defined length and that collisions are handled appropriately. The implementation emphasizes the importance of using local variables and structuring functions correctly to maintain game state and display the board effectively.
  • #31
manveenkaur said:
So did you not figure out something?
Nope.
 
Technology news on Phys.org
  • #32
How did u guys deal with the tail?
 
  • #33
I am still not able to get a solution. I'll really appreciate it if someone could help me. M problem is that my opponent does not move. Please help!
 
  • #34
manveenkaur said:
I am still not able to get a solution. I'll really appreciate it if someone could help me. M problem is that my opponent does not move. Please help!

It appears that you are using an underscore '_' instead of a regular minus sign '-'. When you make the changes the code should work!
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 7 ·
Replies
7
Views
76K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 11 ·
Replies
11
Views
9K
Replies
1
Views
4K