0% found this document useful (0 votes)
2K views2 pages

Journal It Proj

Uploaded by

bautistavladyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views2 pages

Journal It Proj

Uploaded by

bautistavladyy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# IT Journal - Snake Game Issues and Bugs

## Description
The Snake Game source code written in C exhibits several bugs, issues, and areas
for improvement. These problems affect gameplay, code functionality, and
readability.

## Identified Problems

### 1. Lack of Modularity


- The code lacks modularity, making it difficult to maintain, understand, and
debug. Functions are excessively long and perform multiple unrelated tasks.

### 2. Magic Numbers


- The usage of magic numbers throughout the code reduces readability and makes it
challenging to understand the purpose of certain values.

### 3. Undefined Functions


- The following functions are declared but not defined in the code:
- `record()`
- `Scoreonly()`

### 4. Poor Code Structure


- The absence of proper code structuring (such as functions for specific tasks)
hampers readability and maintenance.
- The `Move()` function has too many responsibilities, performing various tasks,
including movement, collision detection, and game flow control.

### 5. Delay Function


- The `Delay()` function seems ineffective and needs improvement for better control
of game speed.

### 6. Unhandled Edge Cases


- The game does not handle edge cases appropriately, such as:
- Snake hitting the game boundary
- Snake collision with its own body
- Inconsistent food generation and placement

### 7. Improper Use of Conio.h and Process.h


- The code uses non-standard libraries like `conio.h` and `process.h`, making it
less portable across different systems.

### 8. Global Variables


- The code utilizes numerous global variables, increasing the risk of unintended
modifications and making the code harder to maintain.

## Suggestions for Improvement

### 1. Modularize Code


- Split the code into smaller, manageable functions, each handling specific tasks.
- Create functions for collision detection, snake movement, food generation, and
game logic.

### 2. Remove Magic Numbers


- Replace magic numbers with constants or named variables to enhance code
readability and maintainability.

### 3. Define Undefined Functions


- Define the `record()` and `Scoreonly()` functions to resolve compilation errors.
### 4. Implement Proper Code Structure
- Organize code into logical sections or modules to improve readability and
maintainability.

### 5. Enhance Game Logic


- Implement robust collision detection to handle wall collisions and self-
collisions for the snake.
- Ensure consistent and appropriate food generation and placement.

### 6. Use Standard Libraries


- Replace non-standard libraries (`conio.h`, `process.h`) with standard
alternatives for portability.

### 7. Reduce Global Variables


- Minimize the use of global variables by encapsulating data within functions and
using parameters where necessary.

### 8. Improve Delay Function


- Enhance the `Delay()` function to control game speed effectively.

### 9. Implement Error Handling


- Include error handling mechanisms for user input and game state validation.

### 10. Add Comments and Documentation


- Add comments to clarify the code's functionality, improve readability, and aid
future maintenance.

## Conclusion
The Snake Game code requires significant refactoring and bug fixing to enhance
functionality, readability, and maintainability. Implementing modular, well-
structured code with proper error handling will lead to a more robust and enjoyable
gaming experience.

You might also like