VB Classic: Snake's Escapade [Source]
Language: VB Classic (VB 6)
Taking NoteMe's Snakes tutorial, I implemented it and expanded upon it. It does what NoteMe's program did and more:
- Multiple fruits for different values
- Multiple power-ups
- Tracks levels: increases speed as you level up
- Tracks score: your snake gains body segments every 100 points
- Simple help/about windows to provide control/gameplay assistance
- /debug: Comes with a basic debug mode for testing/development
I've tested it through the first two levels, and it behave a little unbalanced or unpredictable as gameplay continues. There are more things that I've thought about doing for it, but I may move on to another game/format unless someone is curious to see it developed. It come as is. Every function/sub is formatted and has a comment header with everything filled out except for Description, and it comes with a table of contents to easily find code that I grouped together (Game Loop, Image Processing, etc).
Graphics are handled via three image objects and not bitblt, but all of the objects are tracked in corresponding arrays so you would probably only have to rewrite the image routines to make it behave that way.
Re: VB Classic: Snake's Escapade [Source]
I suppose I better give some feedback :).
The game has a minor bug that I am sure is easily fixable, but I am too lazy to fix it atm. Here is the code:
VB Code:
Private Sub GetCommandArguments()
Dim ls As String
Dim lsCommands() As String
lsCommands = Split(Command$, " ")
For [COLOR=Red]li[/COLOR] = LBound(lsCommands) To UBound(lsCommands)
Select Case LCase(lsCommands(li))
Case "/debug"
mnuDebug.Visible = True
End Select
Next
End Sub
Error: "Variable Not Defined"
Re: VB Classic: Snake's Escapade [Source]
Quote:
Originally Posted by Seraphino
I suppose I better give some feedback :).
The game has a minor bug that I am sure is easily fixable, but I am too lazy to fix it atm.
...
Add a declaration for li.
VB Code:
Private Sub GetCommandArguments()
Dim ls As String
Dim lsCommands() As String
[COLOR=Red]Dim li As Integer[/COLOR]
lsCommands = Split(Command$, " ")
For li = LBound(lsCommands) To UBound(lsCommands)
Select Case LCase(lsCommands(li))
Case "/debug"
mnuDebug.Visible = True
End Select
Next
End Sub
I've made the change in my code, but I haven't uploaded a new version of the game since it is a single line change.
Re: VB Classic: Snake's Escapade [Source]
giWindowStatus needs to be defined as well
I set it as int, game seems to work ok now.
Private Sub InitializeGame(Optional vbRunGame As Boolean = True)
1 Attachment(s)
VB Classic: Snake's Escapade [Source]
Thanks for the feedback. I've made changes to the source code to get through those two errors. It compiled and ran for me so you shouldn't have any variable isn't defined type messages.
Re: VB Classic: Snake's Escapade [Source]
Hey I did that tutorial and im working on m own with my own features as well...
I couldnt figure out how to change the speed and saw that you have done that could you give me some help with that.
My movement is the same as the tutorials ... so I dont know if you changed yours... but could you provide me with some code or help. THanks.
Re: VB Classic: Snake's Escapade [Source]
Quote:
Originally Posted by HaLLa
My movement is the same as the tutorials ... so I dont know if you changed yours... but could you provide me with some code or help. THanks.
Are you using a Timer object like the tutorial? If you are using the Timer for the game loop, then just set the Timer's Interval value to a smaller number.
VB Code:
Timer.Interval = 150 ' Original speed
Timer.Interval = 100 ' Faster Game Loop/Movement
Timer.Interval = 200 ' Slower Game Loop/Movement
When and How you set these values depend on how you want to handle your game's "gameplay". :bigyello:
Re: VB Classic: Snake's Escapade [Source]
Yeah I figured that out... lol so easy.
I just have to figure out where you cant go the opposite direction onw...
like when your going right you cant go left and over your body.
Re: VB Classic: Snake's Escapade [Source]
Quote:
Originally Posted by HaLLa
Yeah I figured that out... lol so easy.
I just have to figure out where you cant go the opposite direction onw...
like when your going right you cant go left and over your body.
For me, I just ignored the key_down event if the key pressed would move it against the body:
VB Code:
If gbStatus(geStatus.fRunning) Then
liNewKeyCode = KeyCodeMapping(viKeyCode) 'Used for snake effects
Select Case liNewKeyCode
Case geKeyCode.Left, geKeyCode.NK4
If Not foSnake(0).Facing = geDirection.Right Then
foSnake(0).Facing = geDirection.Left
End If
Case geKeyCode.Up, geKeyCode.NK8
If Not foSnake(0).Facing = geDirection.Down Then
foSnake(0).Facing = geDirection.Up
End If
Case geKeyCode.Right, geKeyCode.NK6
If Not foSnake(0).Facing = geDirection.Left Then
foSnake(0).Facing = geDirection.Right
End If
Case geKeyCode.Down, geKeyCode.NK2
If Not foSnake(0).Facing = geDirection.Up Then
foSnake(0).Facing = geDirection.Down
End If
End Select
End If
Now, ensuring that it won't move over another snake piece--aside from walking back over itself--is another problem to tackle, but this code would work if you were just trying to prevent the snake from walking over itself.