I want to make a program that saves the high score of the game.How should I programme?
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to make a program that saves the high score of the game.How should I code to do this? Thanks!
댓글 수: 0
채택된 답변
Image Analyst
2014년 12월 15일
Is it the kind of game where the score can only increase? Or can it ever decrease? Actually, it doesn't matter. Let's say you have an array called scores that keeps track of all scores - whenever there is a new score you add an element. The high score is just
highScore = max(scores);
To save that to a file, just use save():
save(matFillFileName, 'highScore');
댓글 수: 0
추가 답변 (1개)
Star Strider
2014년 12월 12일
I don’t know what the game is, but I assume the score increases to the end. I would use the max function.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!