how to combine a GUI timer with battleship game

hi everyone , so i have a .m file that is a battleship game that works fine , and i need to add to this game a timer.
ive successed to create a timer with gui , but the big problem is that i dont know how to combine them ,
i dont know what should i do maybe add an axes option in the GUI and try to plot the game into it
really need your help thx.

5 Comments

Create a timer object in an accessible place http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F . Configure the callback for the timer to be a "You did not move quickly enough" function.
Under appropriate circumstances, just before permitting the user to start a move, start the timer. In the code that recognizes that the user has made a valid move, stop the timer.
I do not know how you have the user inputting a move. In some input methods, the user might be able to enter invalid data, such as column that is not A to J. In such a case, you do not want to stop the timer until the user enters something valid, so that you do not permit the user to get extra time to think by deliberately entering an invalid move.
basically i need a timer for the whole game not for every move , its just runs in backround
my question is that , i have a game that runs with a figure and timer that runs with gui how do i make them runs toghter in the same window
In MATLAB, "figure" and "gui" are the same thing.
The timer that is running in the background -- is that just like a game clock to show how long the game has gone on? Or does it affect game play?
I need to appropiate time for each game , like i determine a 2 minute game and a countdown clock is displayed while the game is running
https://www.mathworks.com/matlabcentral/fileexchange/12628-stopwatch shows an example of building a clock based upon a timer object. timer objects execute asynchronously, so you can have that running at the same time the GUI is operating.

Sign in to comment.

Answers (1)

FYI, the MATLAB Facebook page has an item on Battleship:

Categories

Find more on Board games in Help Center and File Exchange

Asked:

on 15 Jun 2019

Answered:

on 17 Jun 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!