1 1 1 1 1 Rating 0% (0 Votes)
Attachments:
Access this URL (http://abapblog.com/files/nugg/ZAB_BATTLESHIPS.nugg)ZAB_BATTLESHIPS.nugg
I was playing a bit with CL_GUI_TIMER some time ago and I thought that this would be good to use it somewhere to have idea how it works. So I've created then a small game Battleships, which you for sure know from analog version. 

Game is very simple, firstly you have to build your own map with ships. Just to remind you, there are 2 submarines, 2 destroyers, 1 cruiser, 1 battleship and 1 aircraft carrier. Map is created with CL_GUI_ALV_GRID. Once you click on status button to add one of the ships, map will show you in which place you can start ship. When you'll select position of the start it will show you possible fields for end.
After you build your map hit Join Game button and wait for second player to join you. 
In this moment when you pressed button, your unique ID is stored in INDX table under AB id. Additionally gui timer has started to run, and at end of the event FINISHED method to search partner for you is run. If it founds one, then you start to play, if not then the timer is started again.
 
Once you'll be linked with second player, the first timer will stop, and new will start which will check in INDX table if it's time for your turn, or if other player did any hits already. You'll notice that if opponent hits the ship on the left map (which is yours) a cancel icon will appear on a place of your ship. If opponent hits water then you'll see water icon also. On the top of the screen there is an HTML container builded with CL_GUI_HTML_VIEWER.  This container will tell you if it's your turn or if you have won the battle.

 
As this is the first version, it can contains still some bugs and it could be written better (constants instead of texts, etc..) .
Gameplay also available at YT.


Any feedback is appreciated! 
Have  fun !