Pular para o conteúdo principal

Postagens

Mostrando postagens de junho, 2020

A Battleship Game using JavaFX

Battleship Game during action A few months ago I started a Battleship API which I could use to teach Java for beginners. Create games is always fun, in this blog we created a JavaFX Pong game with only 90 lines of code and also a Stacker Game . Both games required constar screen redrawing and the logic behind the games were very simple, Battleship is different. Battleship is a board game with rules that can be translated into Java code. The board has a state according to players guesses and the game ends if a certain state is acquired which is: a player is able to sink all the ships from the other player. Once we have rules we can easily test it. In this post we will share the API behind our game, show the JavaFX UI and show what could be improved. Just show me the code! Battleship Game API The goal with the API design is make it immutable and fluent, but I didn't work to make it perfectly fluent or immutable, because at some time I wanted to start creating the...