{"id":8877,"date":"2015-08-05T09:00:30","date_gmt":"2015-08-05T16:00:30","guid":{"rendered":"https:\/\/blog.digilentinc.com\/?p=8877"},"modified":"2021-06-16T16:09:52","modified_gmt":"2021-06-16T23:09:52","slug":"snake-game-with-score-tracking-in-labview","status":"publish","type":"post","link":"https:\/\/digilent.com\/blog\/snake-game-with-score-tracking-in-labview\/","title":{"rendered":"Snake Game with Score Tracking in LabVIEW"},"content":{"rendered":"<p>In preparation for NI week, we decided to resurrect our snake game with a new twist. \u00a0Score tracking and high scores in LabVIEW! \u00a0While the snake is alive, the score is updated continuously. \u00a0Once your snake dies, your final score will be shown on the front panel of LabVIEW and if you have a high score, you will be asked to input your name and the high scores will be updated. \u00a0You can find the Instructable for this project <a href=\"http:\/\/www.instructables.com\/id\/Snake-Game-with-Scores-in-LabVIEW\/\" target=\"_blank\" rel=\"noopener\">here<\/a>. \u00a0Below is a picture of the front panel for LabVIEW.<\/p>\n<p><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/jamespic.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-8878 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/jamespic.png\" alt=\"jamespic\" width=\"426\" height=\"199\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/jamespic.png 426w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/jamespic-225x105.png 225w\" sizes=\"auto, (max-width: 426px) 100vw, 426px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>If you haven&#8217;t already, check out our video of the 900 LED board below!<\/p>\n<p><iframe loading=\"lazy\" width=\"735\" height=\"413\" src=\"https:\/\/www.youtube.com\/embed\/2GxZOn7Znac?feature=oembed\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/p>\n<p style=\"text-align: left;\">For this project, I used <a href=\"http:\/\/www.ni.com\/labview\/\" target=\"_blank\" rel=\"noopener\">LabVIEW<\/a>, <a href=\"http:\/\/chipkit.net\/tag\/mpide\/\" target=\"_blank\" rel=\"noopener\">MPIDE<\/a>, <a href=\"http:\/\/www.instructables.com\/id\/Addressable-LEDs-WS2812-on-chipKIT\/\" target=\"_blank\" rel=\"noopener\">Marshall&#8217;s PIXcel library<\/a>, a <a href=\"https:\/\/digilent.com\/blog\/Products\/Detail.cfm?NavPath=2,892,1035&amp;Prod=CHIPKIT-UC32\" target=\"_blank\" rel=\"noopener\">chipKIT uC32<\/a>, and <a href=\"http:\/\/www.ni.com\/visa\/\" target=\"_blank\" rel=\"noopener\">NI VISA<\/a> (an add-on for LabVIEW that let&#8217;s you read from a serial line). \u00a0During the run, a serial.write command in MPIDE is used to send a &#8220;1&#8221; and then another serial.write follows that contains the length of the snake. \u00a0LabVIEW then reads these values and updates the current snake score. \u00a0When the snake game ends, a serial.write command sends a &#8220;2&#8221; followed by\u00a0the final snake score. \u00a0LabVIEW reads the &#8220;2&#8221; in front of the length and determines whether or not this is a high score. \u00a0If it is a high score, the user is asked to input their name and the high scores are updated. \u00a0All of the high scores are saved to the computer so that when the LabVIEW code is shut off or the snake game is disconnected and then reconnected the overall high scores are shown. \u00a0Here is a picture of the LabVIEW code I wrote.<\/p>\n<p><a href=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/SerialWriteWithHighScoreSaved1.png\"><img loading=\"lazy\" decoding=\"async\" class=\" size-medium wp-image-8881 aligncenter\" src=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/SerialWriteWithHighScoreSaved1-600x133.png\" alt=\"SerialWriteWithHighScoreSaved\" width=\"600\" height=\"133\" srcset=\"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/SerialWriteWithHighScoreSaved1-600x133.png 600w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/SerialWriteWithHighScoreSaved1-1024x227.png 1024w, https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/SerialWriteWithHighScoreSaved1-225x50.png 225w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Check out the code linked in the instructable and see if you can use it as a guide to write your own LabVIEW code to read serial data from a board! \u00a0Let me know if you have any questions and I will be happy to answer them.<\/p>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style6 like-8877 jlk' data-task='like' data-post_id='8877' data-nonce='ee750c7abc' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Like' \/><span class='lc-8877 lc'>0<\/span><\/a><\/div><div class='action-unlike'><a class='unlbg-style6 unlike-8877 jlk' data-task='unlike' data-post_id='8877' data-nonce='ee750c7abc' rel='nofollow'><img src='https:\/\/digilent.com\/blog\/wp-content\/plugins\/wti-like-post-pro\/images\/pixel.gif' title='Unlike' \/><span class='unlc-8877 unlc'>-1<\/span><\/a><\/div><\/div> <div class='status-8877 status align-left'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>In preparation for NI week, we decided to resurrect our snake game with a new twist.  Score tracking and high scores in LabVIEW!  <\/p>\n","protected":false},"author":33,"featured_media":8897,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4327,4323],"tags":[],"ppma_author":[4481],"class_list":["post-8877","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","category-software"],"jetpack_featured_media_url":"https:\/\/digilent.com\/blog\/wp-content\/uploads\/2015\/07\/IMG_20150517_180241.jpg","authors":[{"term_id":4481,"user_id":33,"is_guest":0,"slug":"sudharsan-sukumar","display_name":"Sudharsan Sukumar","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/ade8dccd0e229a47c849e77c724cb3a6?s=96&d=mm&r=g","author_category":"","user_url":"","last_name":"Sukumar","last_name_2":"","first_name":"Sudharsan","first_name_2":"","job_title":"","description":""}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/8877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/comments?post=8877"}],"version-history":[{"count":0,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/posts\/8877\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media\/8897"}],"wp:attachment":[{"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/media?parent=8877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/categories?post=8877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/tags?post=8877"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/digilent.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=8877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}