tag:blogger.com,1999:blog-3464110495317252246.post5521382585656673250..comments2023-04-03T06:21:56.542-07:00Comments on Programmer's Ranch: C# Basics: Snake Game in ASCII Art (Part 2)Daniel D'Agostinohttp://www.blogger.com/profile/03674104019613318379noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-3464110495317252246.post-80256544379181297222014-09-30T09:46:13.996-07:002014-09-30T09:46:13.996-07:00Hi there! If you want to take care of collisions, ...Hi there! If you want to take care of collisions, then you need to store everything that appears on the 'map'. We're already storing the snake itself, but for walls you might want to use a 2D array. Then, for each move, you can check whether a wall or the snake itself is on that square, and restart the game accordingly.<br /><br />Letting the snake continue to move independently is slightly more complicated but I have covered that concept in another article - See "C# Threading: Bouncing Ball".<br /><br />Obviously this article is oversimplified because I was trying to introduce some simple concepts without letting it get complicated. Making part 3 is an interesting suggestion as I could use it to introduce multidimensional arrays and basic collision detection. I'll do it if I find some time over the weekend.Daniel D'Agostinohttps://www.blogger.com/profile/03674104019613318379noreply@blogger.comtag:blogger.com,1999:blog-3464110495317252246.post-81270556421425648152014-09-30T07:36:02.666-07:002014-09-30T07:36:02.666-07:00Can you make part 3 for these? :)Can you make part 3 for these? :)Anonymoushttps://www.blogger.com/profile/06951465103812504660noreply@blogger.comtag:blogger.com,1999:blog-3464110495317252246.post-22502217606318935402014-09-30T07:34:59.769-07:002014-09-30T07:34:59.769-07:00I have some questions!
What if i want to do walls...I have some questions!<br /><br />What if i want to do walls, and if snake hits the wall, game restarts?<br />Also i want to make the snake move automatically if i press like leftarrow key, then it moves left until i press something else like uparrow key.<br />Also how i can tell the snake that if it touches itself, then die and restart game again?Anonymoushttps://www.blogger.com/profile/06951465103812504660noreply@blogger.com