How do i add a game board into matlab ?

4 views (last 30 days)
I am designing a battleship game 6by6 game board.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Jan 2022
image([0.5 5.5], [0.5 5.5], ones(6,6,3));
xticks(0:6); xticklabels([]);
yticks(0:6); yticklabels([]);
grid on
text(0.5:5.5, 6.5*ones(1,6), string(1:6).')
text(-0.5*ones(1,6), 0.5:5.5, string(1:6).')
  4 Comments
Aman Kumar
Aman Kumar on 9 Jan 2022
Thank you, I think what you sent just changing the colour of the squares is the best. Do you know how to make it so that the player gets turns to shoot and each turn only has 3 hits
Walter Roberson
Walter Roberson on 10 Jan 2022
turn = 0;
while true
turn = turn + 1;
player1_active = mod(turn, 2) == 1;
for shot = 1 : 3
and so on
end
end

Sign in to comment.

More Answers (0)

Categories

Find more on Strategy & Logic in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!