|
-
May 31st, 2000, 09:21 PM
#1
Thread Starter
Lively Member
Hey ppl,
does anyone remember that brilliant game called nibbles, it is on some mobile phones now calling itself snake.
well i want to write my own version in vb, but dont know how to make the worm move properly, what am i going to use as the sprite? and how can i tell the head from the tail and make him bend in the middle?
Please help me as i love that game!
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
May 31st, 2000, 10:27 PM
#2
PowerPoster
A friend wanted to make the same game and asked me the same thing... I however told him to make an array to store the points and draw them by simple PSet-ing. He made it and it became nearly the same as on mobile phones 
Code:
Type tCoord2D
x as Long
y as Long
End Type
Type tSnake
PointCount as Long
Point() as tCoord2D
Name as String
Score as Long
End Type
Global SnakeCount as Long
Global Snake() as tSnake
Got the idea?
-
May 31st, 2000, 10:36 PM
#3
Thread Starter
Lively Member
yeah sorta, i have never done any of that coding with types and what you have said... creating my own objects, is that what it is?
how do i paint the snake then? That may be a completely strange question to you, if the code already does that, but as i said i havent ever done that before, thanks
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
May 31st, 2000, 11:17 PM
#4
transcendental analytic
A user defined type (UDT) is a bunch of standard data types you put together the way it suits your need. What fox have done is a set of UDT that simplifies the way you handle your snakes(s) so you can use the snakes like this:
Code:
Dim Magsnake as tsnake
magsnake.name="Mag-Net"
magsnake.score=magsnake.score+1
'To move your snake:
magsnake.point(0).x=magsnake.point(0).x+directionx
magsnake.point(0).y=magsnake.point(0).y+directiony
For n=0 to pointcount-2
magsnake.point(n)=magsnake.point(n+1)
next n
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 31st, 2000, 11:56 PM
#5
PowerPoster
Indeed.
Making your own object would mean to make a class. It is however easier to use an UDT for this simple game
-
Jun 1st, 2000, 04:43 AM
#6
Thread Starter
Lively Member
ok, so i followed that code and now i get a subscript out of range error with this line:
'To move your snake:
Magsnake.Point(0).x = Magsnake.Point(0).x + directionx
I dont have a clue why? any ideas?
thanks
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
Jun 1st, 2000, 05:30 AM
#7
Where did you put the code?
-
Jun 1st, 2000, 05:31 AM
#8
PowerPoster
You probably didnt initialize the Snake:
Code:
Dim MagSnake as tSnake
With MagSnake
'Set start values
.PointCount = 20
Redim .Point(.PointCount)
.Name = "Mag-Net"
.Score = magsnake.score+1
'To move your snake
.point(0).x = .point(0).x + directionx
.point(0).y = .point(0).y + directiony
'Move the points
For n=0 to pointcount-2
.point(n)= .point(n+1)
Next
End With
-
Jun 1st, 2000, 06:21 AM
#9
Hyperactive Member
I did a game similar to this in Java a bit back and I found it made things a lot simpler to create a 2 Dimensional array of byte or something. You'll still want to use UDT's like the other guys are telling you but a two dimensional array might help too. Then you end up with the screen being a grid.
"People who think they know everything are a great annoyance to those of us who do."
-
Jun 1st, 2000, 08:37 AM
#10
PowerPoster
I dont see why you want to make a 2D array. The screen is in our case not a grid coz were going to set and collide single pixels...
-
Jun 1st, 2000, 08:47 AM
#11
Hyperactive Member
Well If your doing snakes I really dont think you need pixel by pixel collision detection. It really does depend on how you want to make your game. It worked out well for me becasue every spot on the grid would either be a snake, a wall or nothing. And each snake object had a reference to the grid. It made drawing and updating much easier for me.
"People who think they know everything are a great annoyance to those of us who do."
-
Jun 1st, 2000, 10:10 AM
#12
PowerPoster
Since were talking about 1 pixel sized snakes were going to use the screen as grid, that means in our case we have a resolution as high as the screen. Thats why we dont need a grid, we can directly use the pixels...
-
Jun 1st, 2000, 10:35 AM
#13
Hyperactive Member
I didnt realise you where using 1 pixel snakes, then using just pixels makes a lot more sense. I was using 10 pixels by 10 pixels and a game size of something like 300*250. This is a different case then
"People who think they know everything are a great annoyance to those of us who do."
-
Jun 1st, 2000, 10:45 AM
#14
PowerPoster
Think so. Well, now hes got 2 solutions
-
Jun 1st, 2000, 03:20 PM
#15
Thread Starter
Lively Member
Have i got this right? there will be the snake one pixel thick? that is a bit thin isn't it! I would rather have a big bulging snake, especially if what he has to collect is pies
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
Jun 1st, 2000, 03:26 PM
#16
Thread Starter
Lively Member
Thanks Fox, ur right i didnt initialise the snake, i must have been tired! I knew that it would need to be done...yeah lets put it down to tiredness!
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
Jun 1st, 2000, 03:36 PM
#17
Thread Starter
Lively Member
Hey guess what, I am confused again...
...the code runs, but how do i get it to work so that i can see the snake on the screen?
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
Jun 1st, 2000, 08:23 PM
#18
transcendental analytic
Mag, you need to have a continous loop, or timer, (i hope you use the loop) Within it you call the mousemoving method, the collisiondetecting method, and the drawing method. You must also have a doevents (if you use a loop)
The drawing need your snake pixel size so you need to declare it
Private Snakepixel%
And let snakepixel=16 in form load
or just use
Const Snakepixel%=16
Then to the drawing method:
Code:
cls
With magsnake
for x=0 to .pointcount-1
line(snakepixel*.point(x).x,snakepixel*.point(x).y)-(snakepixel*(1+.point(x).x),snakepixel*(1+.point(x).y)),vbred,BF
next x
end with
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 2nd, 2000, 03:11 AM
#19
Thread Starter
Lively Member
Now I get you, I can see this being a long thread! Hope not! Thanks, as I have said before I have never done it before and so dont know how to do these things...
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
Jun 5th, 2000, 07:45 PM
#20
Junior Member
I maked this game all ready!
Mag, I got this game
i made it all ready...
if you want the source email me, i send it to you.
hope to help
-
Jun 7th, 2000, 05:02 AM
#21
PowerPoster
There's also a demo on my website...
-
Jun 7th, 2000, 07:07 PM
#22
Thread Starter
Lively Member
Thanks Fox and TalZ, much appreciate it!

Fox, i love the description on ur site of the game, to the point!
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|