views:

53

answers:

2

I am currently in the process of making a snake game using VB.NET... I was just wanting to gather ideas on how to do the body of the snake...

Currently I have a class called SnakeBody which contains the following code:

Public Class SnakeBody
    Dim yCoord As Integer
    Dim xCoord As Integer
    Dim body As PictureBox
End Class

I guess what I am asking is if Dim body As PictureBox a logical thing to put in my class. As in, I am not sure if that is the correct thing to do? To create the actual body of the snake I will have an array of these SnakeBody objects.

If `'Dim body As PictureBox is valid How do I reproduce the same picturebox everytime my snake eats something?

I hop this makes sense... Thanks Alot

+3  A: 

Well, it is okay but it is not going to work well in practice. PictureBox is a window, when snakes overlap each other, you'll obscure part of them with a rectangle. You'll essentially see one snake in a rectangle with bits of other snakes peeking out past that rectangle.

Use the form's Paint event to draw the snakes, don't use a control.

Hans Passant
Agreed, paint the snake, if you look back to the original game the snake was just pixels that would add another to the back when you ate another pixel.
Pieces
ALrighty that helps me out alot! Thank you!
A: 

Don't use Winforms. Use vb.net and silverlight, you can design a template for the snake , you have silverlights sophisticated built in animation. It will be so much easier and better and it will run on a PC and Mac.

David