Inspiration

The inspiration behind this project was to create an engaging and interactive gaming experience that allows users to enjoy the classic game of Battleships in a modern, digital format. The goal was to integrate a RESTful API into a Flutter application, providing users with the ability to play against both human and AI opponents, while also gaining experience with managing asynchronous operations, state management, and responsive UI design.

What it does

The application allows users to register, log in, and play games of Battleships against either human or computer opponents. Users can view a list of ongoing and completed games, start new games, place ships on a game board, and play their turns by selecting shot locations on the board. The app ensures that the gameplay is smooth and responsive amongst every user playing through the server, providing feedback for each action, such as hit, miss, or win, and supports session management with tokens for secure user authentication.

How we built it

The application was built using Flutter for the frontend, which provided a responsive and visually appealing user interface. We utilized the http package to handle asynchronous communication with the RESTful API, and the shared_preferences package to manage session tokens locally. The app's state management was handled using the provider package, which allowed us to efficiently manage data and keep the UI in sync with the game state. The backend services were accessed via a RESTful API, which facilitated user registration, login, game creation, and gameplay.

Challenges we ran into

One of the main challenges was ensuring that the application remained responsive during asynchronous operations, such as retrieving game data from the server or submitting moves. Managing the game state across different screens and ensuring that the UI reflected the latest game status, especially in human vs. AI games, was also challenging. Additionally, implementing a clean and modular code structure that adhered to best practices for Flutter development required careful planning and organization.

Accomplishments that we're proud of

We are proud of successfully integrating the RESTful API into the Flutter application, providing a seamless experience for users to play Battleships. The responsive design of the game board, which adapts to different screen sizes, is another accomplishment we're proud of. We also managed to handle session management efficiently, ensuring that users' tokens were stored securely and that they were prompted to log in again when needed.

What we learned

Throughout this project, we gained valuable experience in working with RESTful APIs, handling asynchronous operations in Flutter, and managing application state using the provider package. We also learned how to design a responsive UI that works well across different devices, as well as how to structure a Flutter project in a modular and maintainable way.

What's next for Battleship Game

In the future, we plan to enhance the AI opponents to provide a more challenging gameplay experience, possibly incorporating different levels of difficulty. We also aim to add more features, such as multiplayer support with real-time updates, improved animations for ship placement and shots, and additional game modes. Expanding the application to support online multiplayer with matchmaking and chat functionality is also on our roadmap.

Built With

Share this project:

Updates