Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




A Simple Snake Game I Made In 5 Mins


All you need is a form (form1) a timer (timer1) and a label (label1)

make the form a square and about 5 inches on each side...



Dim kc As Integer
Dim x As Integer
Dim y As Integer
Dim x2 As Integer
Dim y2 As Integer
Dim xg As Integer
Dim yg As Integer



Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
kc = KeyCode

End Sub

Private Sub Form_Load()
Scale (0, 100)-(100, 0)
form1.drawwidth = 10
x = 50 'start the snake off in the middle
y = 50
x2 = Int(Rnd * 90) + 5 'find a random spot for the snakke
y2 = Int(Rnd * 90) + 5
xg = 50
yg = 50
End Sub

Private Sub Timer1_Timer()


Select Case kc 'depending on the arrows move the snake
Case Is = 37
x = x - 1
Case Is = 38
y = y + 1
Case Is = 39
x = x + 1
Case Is = 40
y = y - 1
End Select





PSet (xg, yg), Form1.BackColor 'cover up the last spot the snake was
PSet (x, y), vbBlack 'show the new spot the snake is
PSet (x2, y2), vbRed ' show the fruit

If x < 4 Or y < 4 Or x > 97 Or y > 97 Then 'if the snake goes out of bounds return it to the middle
Form1.Refresh
x = 50
y = 50

End If

xg = x 'sets a point for the last spot of the snake so it can be covered
yg = y

If Abs(x - x2) < 3 And Abs(y - y2) < 3 Then 'check if the snake found the fruit
Label1.Caption = Label1.Caption + 5 'add points to the scoreboard
PSet (x2, y2), Form1.BackColor 'hide the fruit if it was found
x2 = Int(Rnd * 90) + 5 'make a new fruit
y2 = Int(Rnd * 90) + 5
End If



End Sub




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
I Made A Snake Game From Scratch, Saves Scores, Wall Options...
i made this from scratch, the only module i used was one that allows me to write an INI file, I wrote everything else in here, including the save top scores algorythm, feel free to take it and put it into your games if you'd like. It saves the top 10 scores... The way i did this is probably not the way most people did but here it is...let me know what u think...Im pretty proud if it, i started programming a few months ago and have picked up just about everything on my own...

Snake Help! Ending Game When Snake Hits Itself
Hi. I have been making a Snake clone using the following tutorial:

http://www.geocities.com/note_ladybug/snake1.html

I have the snake moving and it gets bigger when it eats a block. I have also stopped the snake from leaving the form, but I cannot figure out how to make is that when the snake hits its self then the game is over.

Could someone please help me on this one? Thanks!

O and im using images for the snake body segments.

My Snake Game
this is the snake game i made in a cupple of days i putthe source instead of the exe in this time i hope that would be to people likeing

fell free to play or edit i guess feedback would be apriciated




(if you are an admin please delete the thread "Done" because it is the same game but i put the exe file in atachment didnt know it was against the form law sry)

Snake Game, Please Help
Im having a problem with my snake game, actually a couple of problems:

1.I would like the dot to be drawn thicker, i use the setpixel function

2.My snake is dissapearing and im not able to move it, it has something to do with my collision detection which I use this:

in the form i use:
Code:
If dot.collide(root) Then
dot.x = Rnd * 3285
dot.y = Rnd * 4680
dot.Draw Picture1.hDC
End If

then in the class pos I use:


Code:
Private Declare Function SetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Public y As Integer
Public dot As pos
Public x As Integer

Public Function collide(target As Snake)
target.x = x
target.y = y
End Function


Public Sub Draw(hDC As Long)
SetPixel hDC, x, y, vbBlack
End Sub

and this does not work, this may seem confusing so here is my game file, please help anyone who can:

My Snake Game
this is the game that i made for my fina assignment thanks again Iceplug and JimCamel. tell me what you think of it

Edit by Squirm: Attachment removed. Source code only please, no compiled binaries.
Posting Guidelines (Guideline 10)

Edit by Iceplug: EXE removed from attachment

oops sorry i didnt know that ok heres the uncompiled version

My Snake Game
well the game is completed and i have attached it, the only problem i think you will find is the top left corner a green box appears, im not sure how to get rid of that though

hmm i cant seem to upload it

Snake Game
hi everybody

i'd like to reproduce the famous mobiles' Snake game that also appeared on Comodore128 as "Nibbles" (yeah, those days!!) but can't find a way to program it, who can give a little idea behind the algo ?

Snake Game
Hey..

I have this snake game underway.. I made it, so that when, the snake eats some food a new picturebox will be created, and added to the o_snake() array.

So the snakehead is o_snake(0). When it eats it will spawn a o_snake(1):
6543210
oooooo>

get it?

So now when the snake moves i want the minion last in the snakes tail to be moved to the snake heads position.

My code for moving the snake:

VB:

Code:
Public Sub Move(Direction As Directions, Optional Simulation As Boolean)
TempCoords(1) = o_snake(0).Left
TempCoords(2) = o_snake(0).Top

If Checkwrap(Direction) Then
If Direction = down Then
o_snake(0).Top = o_snake(0).Top + SNAKEWIDTH
ElseIf Direction = Up Then
o_snake(0).Top = o_snake(0).Top - SNAKEWIDTH
ElseIf Direction = Left Then
o_snake(0).Left = o_snake(0).Left - SNAKEWIDTH
ElseIf Direction = Right Then
o_snake(0).Left = o_snake(0).Left + SNAKEWIDTH
End If
Else
Err.Raise 1001, , "Direction was not inside the enum"
'MAKE FUNCTION FOR LOSING!
End If

EatFood
MoveMinion
End Sub

Private Sub MoveMinion()
o_snake(UBound(o_snake)).Top = TempCoords(1)
o_snake(UBound(o_snake)).Left = TempCoords(2)
End Sub

The problem is that, it is only the last spawned minion, that will be moved.. not the last in the Que

Edit: I thought a little about doing kind ala this:

Take the last in que, and move it up front.. = snake(first) = snake(last)... snake(first) = snake(second) and so on.. And when new minion spawned it should just be added last in the que,

But i can't find a way to assign this snake(9) to snake(1). Dont even know if its possible
I also wondered. Instead of creating a new picturebox for every single minion, couldn't i then do the snake in some kind of grid? and then just paint the grid where it is. hmm.
Then i just needed a status for every grid in game.

Snake Game
I am making a snake game i can make everything in the game but the snake. I use a shape for the snake but i don't know how to make that shape go in the L shape of you press right.

Snake Game Help !?
I am making a snake game but I don't get how to make it move i can move the snake but i want it 2 be constantly moving so that if you don't turn him he'll crash into a wall, how do i go about doing this !?

Help With Snake Game
Just for fun im trying to code a snake game. Everything was fine until i got to the part where i need to add extra body lengths to the snake for all the food he's eaten. How can I go about using a single image over and over for his body?

HELP! Snake Game
i dont know whats wrong, the line just dosent work!

PLAESE HELP!

Snake Game (Help Please For Stoping)
Im also doing a snake game but i want there to be a timer so you have 60 seconds to get a certain amount (10 or so) of items. Can anyone help me? I dont know anything about timers coz ive just started with vb.

Snake Game (Help Please For Stoping)
I'm working on a Snake Game in VB and I can't seem to get the snake to stop moveing when it hits the walls.

I tried this:

If Snake(0).X = (The X Number Of the Block) And Snake(0).Y = (The Y number of the block) Then
Call StopSnake
End If


Stop snake was the same as move snake but it would just have everything as 0 for movement.

Heres the ZIP Any help would be greatly helpfull, thanks.

Oh I have been programming VB for a few months.

Snake Game ( Help Needed!!!!!!)
I am trying to do a snake game like the ones found on mobile phonesss...


1.Able to move the snake up,down,left,right by using keyboard and command buttons... snake should not be able to move back on it self.

2.Snake is not allowed outside the bounds of the game area..

3.Snake grows when it eats the food.

4.Points should be awarded to the player based on the lenght of time survive.

5.Random start + random food places.

6.snake cannot eat it self!!!


Plzzzz can i have some help for each of these point...
write me the code with explanation if possible

This is what i've done so far

--------
Code:
Option Explicit
Dim intsnake_x(500) As Integer
Dim intsnake_y(500) As Integer
Dim intsnake_lenght As Integer
Dim intx_dir As Integer
Dim inty_dir As Integer

Private Sub CmdDown_Click(Index As Integer)
intx_dir = 0
inty_dir = 10
End Sub
Private Sub draw_snake(colour)
Dim intcount As Integer
For intcount = 0 To intsnake_lenght
picSnake.PSet (intsnake_x(intcount), intsnake_y(intcount)), colour
Next intcount
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdGo_Click()
tmrMove.Enabled = True
tmrMove.Interval = 2

End Sub

Private Sub cmdLeft_Click(Index As Integer)
intx_dir = -10
inty_dir = 0
End Sub

Private Sub cmdUP_Click()
intx_dir = 0
inty_dir = -10
End Sub

Private Sub Command4_Click(Index As Integer)
intx_dir = 10
inty_dir = 0
End Sub

Private Sub Form_Load()
Dim intcount As Integer
intsnake_lenght = 100
For intcount = 0 To intsnake_lenght
intsnake_x(intcount) = 200 - intcount * 10
intsnake_y(intcount) = 500
Next intcount
intx_dir = 10
inty_dir = 0
frmMain.Show
Call draw_snake(vbRed)
End Sub
Private Sub tmrMove_Timer()
Dim intcount As Integer
Call draw_snake(frmMain.BackColor)
For intcount = intsnake_lenght To 1 Step -1
intsnake_x(intcount) = intsnake_x(intcount - 1)
intsnake_y(intcount) = intsnake_y(intcount - 1)
Next intcount
intsnake_x(0) = intsnake_x(0) + intx_dir
intsnake_y(0) = intsnake_y(0) + inty_dir
Call draw_snake(vbRed)
End Sub
----------

Snake Type Game...Help
Heres what i want to do...

Have the head...once it eats a point, another segment of its body gets added on and i want each segment to follow the head...like snake...how would i do that?

Snake Game Problem
I was making a Snake Game and i had a problem. After the Snake eats the Apple(Or whatever he eats), I don't know how to place to new Snake Part. Lets say the snake is going up, i can place it on the bottom but lets say the snake is in an L shape then i won't know how to place it because the placement would be different.
My placement method was basically based on this; if the snake direction is up then place on the bottom of last snake part. If is was left place it to the right of the last snake part but when it's in an L shape it doesn't quiet work. Can someone please give me some advice on how to overcome this problem?Thanks~!



Code:
Option Explicit
Dim snakeleft As Boolean
Dim snakeright As Boolean
Dim snakeup As Boolean
Dim snakedown As Boolean
Dim i As Integer
Dim p As Integer
Dim snakecount As Integer

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeyLeft Then
snakeleft = True
snakeright = False
snakeup = False
snakedown = False
End If

If KeyCode = vbKeyRight Then
snakeleft = False
snakeright = True
snakeup = False
snakedown = False
End If

If KeyCode = vbKeyUp Then
snakeleft = False
snakeright = False
snakeup = True
snakedown = False
End If


If KeyCode = vbKeyDown Then
snakeleft = False
snakeright = False
snakeup = False
snakedown = True
End If
End Sub




Private Sub Form_Load()
'place food
Randomize
food.Top = Int(Rnd * Form1.ScaleHeight)
food.Left = Int(Rnd * Form1.ScaleWidth)
'snake length
snakecount = 2
'set snake directions
snakeleft = True
snakeright = False
snakeup = False
snakedown = False
End Sub

Private Sub Timer1_Timer()

'eating
If snake(0).Top <= food.Top + food.Height And Not snake(0).Left >= food.Left + food.Width And Not snake(0).Left + snake(0).Width <= food.Left And Not snake(0).Top + snake(0).Height <= food.Top Then
Call placefood
End If


'move left
If snakeleft = True Then
For i = 0 To snakecount
snake(i).Left = snake(i).Left - 400
Next i
End If


If snakeleft = True Then
If Not snake(0).Top = snake(snakecount).Top Then
For i = snakecount To 1 Step -1
snake(i).Left = snake(i - 1).Left + 400
snake(i).Top = snake(i - 1).Top
Next i
End If
End If

'move right
If snakeright = True Then
For i = 0 To snakecount
snake(i).Left = snake(i).Left + 400
Next i
End If


If snakeright = True Then
If Not snake(0).Top = snake(snakecount).Top Then
For i = snakecount To 1 Step -1
snake(i).Left = snake(i - 1).Left - 400
snake(i).Top = snake(i - 1).Top
Next i
End If
End If


'move up
If snakeup = True Then
For i = 0 To snakecount
snake(i).Top = snake(i).Top - 400
Next i
End If


If snakeup = True Then
If Not snake(0).Left = snake(snakecount).Left Then
For i = snakecount To 1 Step -1
snake(i).Top = snake(i - 1).Top + 400
snake(i).Left = snake(i - 1).Left
Next i
End If
End If


'move down
If snakedown = True Then
For i = 0 To snakecount
snake(i).Top = snake(i).Top + 400
Next i
End If


If snakedown = True Then
If Not snake(0).Left = snake(snakecount).Left Then
For i = snakecount To 1 Step -1
snake(i).Top = snake(i - 1).Top - 400
snake(i).Left = snake(i - 1).Left
Next i
End If
End If

End Sub


Private Sub placefood()
Randomize
food.Top = Int(Rnd * Form1.ScaleHeight)
food.Left = Int(Rnd * Form1.ScaleWidth)
Load snake(snakecount + 1)
snakecount = snakecount + 1
'here i want to put the code for loading new snake part after snake eats apple

snake(snakecount).Visible = True
Randomize
snake(snakecount).FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)

End Sub

Problem With My Snake Game
When you eat the apple, it draws a black spot where the apple is instead of drawing the snake. It goes away after snake is totally over that spot. I can't figure it out for the life of me. I went head and posted the whole project just in case. Thanks ahead of time.

--Joey

P.s. line 199 is where you can change the timer interval....i had it set really slow so i could check the values and stuff. I have a listbox set up on the right that gives the coordinates of the snake each time it moves

Pls Help Me Change The Snake Game
Hi all,
I got the snake game courtesy of si_the_geek.I need you guys to help me improve it.
1)The game ends when the snake touches itself.
2)The game ends when the snake touches the wall.
3)Food and snake have to be within the wall.
This might be a stupid question and you guys can settle it in 5 minutes but i am new to vb so do not laugh.
Thanks.

A Snake Game Not Quite Working.
hi i have written some code and i cant quite get it rite.
um there is a load of stuff contradicting itself now, so u might need to delete some stuff!

Collision Code In Snake Game.
I am attempting to make a Snake Game on Visual Basic. I have a block moving using keydown codes and timers. I have a random code making red squares (what will later be berries) pop up in random places. I want something to happen when these two things colide (it can be anything now, such as a labels caption changing, ill fix later) I know how to do a collision code for a moving object and an object that is always in the same place, but this random code is screwing me up. If somebody could help me get this code working I would really appreciate it. It would solve one of my biggest problems that i am having making this game.

Thanks.

Snake Game, Need Help Fixing Bugs
Hi all,

I've just finished making a snake game in VB for a school project, but there is a bug that I don't know the cause of and therefore I cannot fix. I've attached the game so please feel free to look and it and help me figure out what I've done wrong.

Please don't tell me how badly or messy I've coded it, I only just started learning VB a few weeks ago and it is my first programming language (I'm in year 9 at school). However, feel free to give me advice on how to improve my coding.

Anyway, the bug that I've noticed is that every so often when you eat a piece of food, one block of the snake seems to go black. This happens sporadically so make sure you play a bit to see it happen.

Please help me fix this and tell me about any other bugs you've noticed or any advice you have.

Thanks in advance!

Grrrrrrrr Snake GAME NEED HELP REALLY DESPERATLY
ok i am still havin trouble making my stupid snake game work i want him to grow every time he eats an apple and i want his body to move with him, i can show you my code if someone is willing to help me figure this out !!!!


*Thanx*

Snake Game - Adding Segments
The game that I am making sucks hehe I can;t get anything to work obviously because this is like my tenth post my problem now is when my snake eats an apple that randomly appears on the screen i want an extra segment to be added on to his bak end, and along with that i want each segment to follow the following one when he turns if you know how i mean, now how would I attempt doing this in the simplest form of code possible !?


*Thanx*

Nokia Snake Game...help Needed
I am currently creating a typical nokia snake game in VB6. i have a method called actual_move() which has code to move the snake and a timer control which calls this fn. I store the direction of movement (left,right,up,down) in the tag property of the snake(the snake is a rectangular element). The keypress event ( left,right,up,down) updates the tag property of the snake

Given the overview

Now my problem is when the actual_move fn is running ie., the snake is moving, when i perform a keypress event, the current control in call stack moves from actual_move to key_press (as key_press has higher precedence in order of execution, i assume), and so causes inconsistancy in my code. What i want is the keypress event should wait for actual_move fn to finish and
then execute ...I dont know how to do this..may be if you can shed some of your knowledge

I think the preferred approach is to Set a flag variable in my code to indicate when a move is in progress and defer execution of the keypress code if it's set (put it in a queue somewhere
and process it when read). But how do i defer execution of keypress code?


Thanks in advance

Snake Game - Using LINE, No Arrays.
Hello world.

I am making this simple snake game for my assignment project, therefore I want to understand what I am doing, therefore I only use line and no arrays because its easier for me to understand. Its nearly 5 hours already Im trying to solve my problem with the very little knowledge of VB I have and yes, I give up and decided to ask for help here.

Basically, to get started, I want to make a loop of the line, from left bottom, goes through left up area of the form where Y1 coordinate = 0, when user hit the up arrow key.

I did:


Code:
Private Sub Form_KeyDown(KeyCode as Integer, Shift as Integer)

Select Case vbKeyCode
Case vbKeyUp
For SnakeY1 = SnakeY1 to 0 Step -50
lnSnake.Y1 = SnakeY1
Next
End Select
End Sub
I tried to use Form_KeyPress but it just won't work, so I try KeyCode which I don't understand the Shift as Integer part. But since I'm not going to use that Shift, I don't really care, but would be appreciated if someone can explain about it as it is automatically generated when you select KeyDown.

Okay so it works when you press up arrow key, but thats more like super-ultra-speed to me, so I tried to add some more lines to delay it a bit. This is where my problem is.


Code:
Private Sub Form_KeyDown(KeyCode as Integer, Shift as Integer)

Dim Delay as Long

Select Case vbKeyCode
Case vbKeyUp
For SnakeY1 = SnakeY1 to 0 Step -50
lnSnake.Y1 = SnakeY1
For Delay = 1 To 50000
Next
Next
End Select
End Sub
I added the delay part, but VB stops responding when I press up arrow key. I tried to reduce the 50,000 to somewhat smaller number, it worked but its just the same as if I don't have the Delay.

My other question is, often I see people use Public Sub rather than Private Sub, what are the differences?

Thanks for your time.

NOOB: Need Ideas {snake Game}
m making the snake game u no the one wer u control the snake to get food and wat not, nut i have a problem highscore i want to be able to save the highscores wen u close the game and reload them back wen u start it. i need ideas on the easiest and most effecient way to do this

[VB6] Snake Game Source Code
The source code to the snake game is enclosed.

Originally called nibbles.bas for QBASIC bundled with DOS, then disappeared for a while, and found its way back into our lives as Snake on the Nokia 3210 mobile phone, and then Snake II in newer versions of the mobile.

If you have any queries on the source code, or any comments or suggestions, just Private Message or e-mail me

Wondering How To Go About Making A Tron/Snake Game
I am using the circle function on a timer to draw circles based on variables X and Y, with direction set by a press of an arrow key. I am trying to think of a way to register where a line has already been drawn, but haven't been able to think of anything yet. Any ideas?

Line Collision Problem In My Snake Game
Im working on an advanced twist on average snake games. This one uses an old physics algorithm that I rewrote for this project. The snake itself acts like a string being pulled on at one end. The snake will also slide around the apples insted of moving through it unless the head runs into it.

The snake is made up of many segments and I added line collision detection to see if the snake has passed through any of its sections. This isnt working for some reason and I cant see why. It all looks right and all the test lines I tried worked right.

If you have an idea of what I'm doing wrong or just want to make a comment, feel free.

Simple Question, Be Back In A Mo If I Haven't Found The Answer (30 Mins)
I need a 2 second delay in my form everytime the user makes a click event happen... I havn't done anything withthe timer control before... whats the procedure? as it do i call teh name of teh control evertime I want a 2 second delay and set the interval in the control to 2000?

Many thanks

Nit

I Made My First Game! Some Help Please!
Hi !
I managed to write some code for my first game ever which is similar to the astroids game. Somehow the 'bullets' do not hit the stones and it's too late at night for me to figure it out! So if you would please download it and take a look at it and give some some comments to make it better or perhaps help me with the bullets thing i would appreciate you.

Thanx,
-Pooya

I Made My First Game! Some Help Please!
I'm a starting game programmer and i would like to know how you made the program shoot when you click. Is there anyone who knows how to do this is visualbasic.net please tell me.

A Little Game I Made
This is just your standard Tile game (slide the tiles around to put the pieces in the proper order). Feel free to comment (no flames, please), add to it, pass it along, or whatever.

I figured it might help some people with a few things. It was just something I was tinkering with to help get my brain back in programming mode (to get the rust off, so to speak).

Enjoy!

Can I See An EXE Of A 3D Game Made By Someone Here?
I would like to see what I can make in 3D in visual basic. If anyone has made even a very small 3D game, I would like to see it. Please send it to SteveCRM@aol.com

Steve (Thank You)

I Got The Game Made.. But One Confusing Thing.
Ok here is my game:

If Text = "playgame" Then
Dim UserNumber As Integer
Dim CompNumber2 As Integer
Randomize Timer
Number = Int(Rnd * 500) + 1
Number2 = Int(Rnd * 500) + 1
BRBot.SendText "&b&lMy number is " & Number & ""
BRBot.SendText "&b&gYour number is " & Number2 & ""
If Number2 > Number Then
BRBot.SendText "&b&rHoly ****! You won!"
Else
If Number2 < Number Then
BRBot.SendText "&b&uYou lost! Time to die you big fat loser!"
x = Timer
Do Until Timer > x + 3
DoEvents
Loop
BRBot.SendText "/remove " & Handle & ""
Else
If Number2 = Number Then
BRBot.SendText "&bWe Tied! Try again... *cough* you suck *cough*"
End If
End If
End If
End If

Ok, The chat program I use this for only lets the owner of the room be able to remove people. Sort of like Op's on mirc or whatever. I want it to make it so that if you win this game you can type
"/remove (name) " and it will be able to remove them. They'd only be able to do that IF they one.. can anyone help me?

Looking To Find How Pogo.com Auto Game Programs Are Made
was curious if anyone know how the game auto's on pogocheats.net where made and if anyone could help me make one of my own ?
they are programs that play the games on pogo.com for you without doing anything just run the program and it will play the game n beat the game for you or however the game is it will do all the work for you any help be appreciated

File Assocition Made Simple
i'dont Know whether there is more simple code to make file association
like this ,Please see this
This is done using WINDOWS Scripting Host

Private Sub Form_Load()
associate ".jpg", "JPGFile", "C:ProgramFilesAccessoriesMSPAINT.EXE"
Unload Me
End Sub


Public Sub associate(EXT As String, FileType As String, FileName As String)
On Error Resume Next
Dim b As Object
Set b = CreateObject("wscript.shell")
b.regwrite "HKCR" & EXT & "", FileType
b.regwrite "HKCR" & FileType & "", "MY file"
b.regwrite "HKCR" & FileType & "DefaultIcon", FileName
b.regwrite "HKCR" & FileType & "shellopencommand", FileName & " %L"
b.regdelete "HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts" & EXT & "Application"
b.regwrite "HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts" & EXT & "Application", FileName
b.regdelete "HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts" & EXT & "OpenWithList"
b.regwrite "HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts" & EXT & "OpenWithLista", FileName
End Sub

Simple Net Utility I Made With The Winsock Control
u need 4 text boxes and winsock control, andsome labels, heres the code

Private Sub Form_Load()
Text1.Text = Winsock1.LocalIP
Text2.Text = Winsock1.LocalHostName
Text3.Text = Winsock1.BytesReceived
Text4.Text = Winsock1.LocalPort
End Sub

label text1 as "your ip"
label text2 as "your host name"
label text3 as bytes received and text 4 as local port.

this is very simple but good for noobs in winsock and its usefull

Does Anyone Know Where To Find A Zelda Game, Or A Zelda-like Made In Visual Basic?
Does anyone know where to find a Zelda game, or a Zelda-like made in Visual Basic?

------------------
"I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"

Simple Game, Simple Question
hey people, how can i put a picture on a specific label?

i got:

Private Sub Label2_Click(index As Integer)

End Sub


but, i would like to add a picture when you click on the right label.

i got 5 indexed label

label2(0) <---i would like to add a picture when i click on this label
label2(1) <---the samething
label2(2) <--- same
label2(3) <--- same
label2(4) <--- same

someone can help me pls

Simple Game
im have a word scramble game that im working on right now i got it setup where i you can just change the names in the code but i want to make it to where some one can just put in a word and it will automaticly scramble i know how to make it print and set all the var. i just want to know if there is any way to make the words sramble themselfs in run time after they are entered!!

Help With A Simple VB Game.
Im in a basic/intro VB class at my University. As a final project we could make any program , basically utilizing what weve learned over the year.

My problem is I am clueless as to where to start. I want to make a basic click and shoot type game (ie: Hogans Alley)


Or better yet, heres a rough outline of what Id like to do.

Main window opens, "Intro". User clicks the start button and the Intro closes and opens the "Rules" screen. User reads the rules and clicks another start button.

The game will have 6 "windows". Id like for the target to sit there for 2 seconds and if the user doesnt click on it, it re-draws in another window. If the user does click on it, 1 point is added to a score and the target re-draws. This will occur for 30 seconds, then the game ends.

The end screen will display the number hit, and the user can click either close or play again.


Ill be using custom made paintbrush images as well.

Ive read some FAQS, but to be honest I am completely lost. Any help would be appreciated

Thanks

Help On Simple Game
Hi everyone.

This might be a really essy one for the more advanced members here.

I've only just started to use Visual basic as part of my university course, we've been asked to design a simple hand eye coordination game. I have managed through text books to create one which contains a form, label, picture box, command button and timer; where when you click the command button the picture box appears in a random position and you have to click on in and then a score of your time to click appears.

I now need to create a game where I have a continously moving object, possibly a picture box or a command button? also need to incorporate some levels, i.e add new forms.

I am at ends with the books availiable as there is no where to find out how to do this, If anyone here could start me up with how to write the code that would move a picture box or command button around a form that would be much appreciated?

thanks for reading this

Sunny

Need Help With Simple Game
hey all,

im a noob at vb and i need some help

im making a game that is pretty easy. You drive a car and try to avoid stuff that falls. I noe how to do everything except make random stuff fall. I need to noe that plz. Anything will help???


P.S.-Can u try to make it a pretty simple code??THX alot!

A Simple 2d Game
Hello! In Computer Programming at my high school, we are currently studying Visual Basic. For a grade, we make programs to impress our teacher by using what we have learned thus far and branching out a little. I have made a simple tic-tac-toe game, a calculator, and some other programs that I have gotten inspiration from by looking at the Start >> Programs menu . But to the point.. For our last grade before the quarter ends, I'm hoping to make a 2d game. It's simple and corny, but I love programming! Yes, I am a geek but meh.. Here's what I have planned:

-No scrolling, because I have looked at some examples and it looks confusing, so it might just be a set of forms that display 10 32x32 tiles or something like that.

-The goal is to get to the end of the last level (of course)!
-However, there are things like pushable walls and switches you must use to get past the puzzles

But, there is a slight problem.. I have a rough idea on how to get the tiles on the screen and then have a way of seeing if something is a wall or whatnot, but it isn't efficient, and definatly not the simplest, but it was the first thing that came to my mind..

-Make a string array, and fill it with letters
-When the form loads, take the letters and place the tiles on the form and place the player's letter at the start*
-When the player moves, check to see that the letter in their direction isn't, let's say, a W for a wall.*

This might be simple, now that I take a look at it again, but anyways.. Are there any other ways that you can display tiles on either a picturebox or the form itself, and check to see if it's a wall when the character moves?

Thank you!
Mike

Simple Game, In Need Of Help
I move around with a shape1, with my arrow keys
another shape2 is falling downwards with a timer

Thats how far I got
Now if I move into this falling shape2, I should get a msgbox saying I lost.

- I dont think there should be any number with twips. Because the shape2 is moving evry second. All I came up with was something alike

If shape1.left=shape2.left then
msgbox x
end if

Looking for a very simple solution, its much like snake when you crash into a wall, but this time a moving wall (Changing coordinations constantly)
Help really appreciated

Please Help With This Simple Game
Hi, i am a beginner trying to make a hangman game!

What this game does so far:

reads from an array of words
displays the word hidden by ******'s
if the entered letter is not in the word the letter shows up under 'bad guesses'
hangman picture is drawn

What the game won't do:

if a correct guess is made i get an error message saying "argument 'start' is not a valid value"


Code:
Imports System
Imports System.Drawing
Imports System.Windows.Forms
imports Microsoft.VisualBasic

Namespace pleasework

Public Class MainForm
Inherits System.Windows.Forms.Form
Private label2 As System.Windows.Forms.Label
Private label1 As System.Windows.Forms.Label
Private lblBadGuess As System.Windows.Forms.Label
Private lblWord As System.Windows.Forms.Label
Private btnQuit As System.Windows.Forms.Button
Private picGallows As System.Windows.Forms.PictureBox
Private txtGuess As System.Windows.Forms.TextBox
Private btnNew As System.Windows.Forms.Button

Public Shared Sub Main
Dim fMainForm As New MainForm
fMainForm.ShowDialog()
End Sub

Public Sub New()
MyBase.New
'
' The Me.InitializeComponent call is required for Windows Forms designer support.
'
Me.InitializeComponent
'
' TODO : Add constructor code after InitializeComponents
'
End Sub

#Region " Windows Forms Designer generated code "
' This method is required for Windows Forms designer support.
' Do not change the method contents inside the source code editor. The Forms designer might
' not be able to load this method if it was changed manually.
Private Sub InitializeComponent()
Me.btnNew = New System.Windows.Forms.Button
Me.txtGuess = New System.Windows.Forms.TextBox
Me.picGallows = New System.Windows.Forms.PictureBox
Me.btnQuit = New System.Windows.Forms.Button
Me.lblWord = New System.Windows.Forms.Label
Me.lblBadGuess = New System.Windows.Forms.Label
Me.label1 = New System.Windows.Forms.Label
Me.label2 = New System.Windows.Forms.Label
Me.SuspendLayout
'
'btnNew
'
Me.btnNew.Location = New System.Drawing.Point(168, 136)
Me.btnNew.Name = "btnNew"
Me.btnNew.Size = New System.Drawing.Size(64, 40)
Me.btnNew.TabIndex = 6
Me.btnNew.Text = "New Word"
AddHandler Me.btnNew.Click, AddressOf Me.btnNew_Click
'
'txtGuess
'
Me.txtGuess.Location = New System.Drawing.Point(112, 72)
Me.txtGuess.Name = "txtGuess"
Me.txtGuess.Size = New System.Drawing.Size(56, 20)
Me.txtGuess.TabIndex = 3
Me.txtGuess.Text = ""
AddHandler Me.txtGuess.TextChanged, AddressOf Me.txtGuess_TextChanged
'
'picGallows
'
Me.picGallows.Location = New System.Drawing.Point(184, 16)
Me.picGallows.Name = "picGallows"
Me.picGallows.Size = New System.Drawing.Size(88, 120)
Me.picGallows.TabIndex = 1
Me.picGallows.TabStop = false
'
'btnQuit
'
Me.btnQuit.Location = New System.Drawing.Point(160, 192)
Me.btnQuit.Name = "btnQuit"
Me.btnQuit.Size = New System.Drawing.Size(72, 40)
Me.btnQuit.TabIndex = 7
Me.btnQuit.Text = "Quit"
'
'lblWord
'
Me.lblWord.Location = New System.Drawing.Point(8, 144)
Me.lblWord.Name = "lblWord"
Me.lblWord.Size = New System.Drawing.Size(136, 24)
Me.lblWord.TabIndex = 4
Me.lblWord.Text = "The Word"
'
'lblBadGuess
'
Me.lblBadGuess.Location = New System.Drawing.Point(0, 184)
Me.lblBadGuess.Name = "lblBadGuess"
Me.lblBadGuess.Size = New System.Drawing.Size(144, 32)
Me.lblBadGuess.TabIndex = 5
Me.lblBadGuess.Text = "Bad Guesses:"
'
'label1
'
Me.label1.Font = New System.Drawing.Font("Tahoma", 20.25!, System.Drawing.FontStyle.Regular, _
System.Drawing.GraphicsUnit.Point, CType(0,Byte))
Me.label1.Location = New System.Drawing.Point(16, 16)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(160, 56)
Me.label1.TabIndex = 0
Me.label1.Text = "Hangman"
'
'label2
'
Me.label2.Location = New System.Drawing.Point(16, 80)
Me.label2.Name = "label2"
Me.label2.Size = New System.Drawing.Size(88, 40)
Me.label2.TabIndex = 2
Me.label2.Text = "Guess a letter"
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.btnQuit)
Me.Controls.Add(Me.btnNew)
Me.Controls.Add(Me.lblBadGuess)
Me.Controls.Add(Me.lblWord)
Me.Controls.Add(Me.txtGuess)
Me.Controls.Add(Me.label2)
Me.Controls.Add(Me.picGallows)
Me.Controls.Add(Me.label1)
Me.Name = "MainForm"
Me.Text = "MainForm"
Me.ResumeLayout(false)
End Sub

#End Region

Dim target As String
Dim workCopy As String
Dim guesses As Short
Dim found As Short
Dim PicNo As Short
Dim myPath As String

Private Sub MainForm_Load(ByVal eventSender As System.Object, ByVal eventArgs _
As System.EventArgs) Handles MyBase.Load
myPath = "pleaseworkin"
Randomize()
newgame()
End Sub

Private Sub btnNew_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs)
newgame()
End Sub

Private Sub newgame()
Dim letters As String
Dim n As Short
Dim times As Short
Dim wordfile As String
Dim Fnum As Short
Fnum = FreeFile()
wordfile = myPath & "words.txt"
FileOpen(Fnum, wordfile, OpenMode.Input)
times = Rnd() * 5
For n = 1 To times
Input(Fnum, target)
Next n
FileClose(Fnum)
target = UCase(target)
workCopy = target
letters = Len(target)
lblWord.Text = New String("*", letters)
guesses = 0
found = 0
lblBadGuess.Text = "Bad Guesses: "
picGallows.Image=System.Drawing.Image.FromFile(myPath & "hang0.bmp")
PicNo = 1
End Sub


Private Sub txtGuess_TextChanged(ByVal eventSender As System.Object, _
ByVal eventArgs As System.EventArgs)
Dim picname As String
Dim temp As String
Dim n As integer
Dim inword As Boolean
Dim guess As String
If txtGuess.Text = "" Then Exit Sub
guess = UCase(txtGuess.Text)
If guess < "A" Or guess > "Z" Then txtGuess.Text = "" : Exit Sub
inword = False

For n = 1 To Len(target)
If guess = Mid(target,n , 1) then
inword = True
mid(temp, n, 1) = guess
mid(target, n, 1) ="*"
found = found +1
End If
Next n

If Not inword Then
lblBadGuess.Text &= guess
picname = myPath & "hang" & PicNo & ".bmp"
picGallows.Image = System.Drawing.Image.FromFile(picname)
PicNo += 1
If PicNo = 11 Then MsgBox("The word was " & workCopy)
End If
txtGuess.Text = ""
End Sub

Private Sub lblWord_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
If lblWord.Text = workCopy Then MsgBox("You Win ****it")

End Sub

End Class
End Namespace

I'm a beginner so go easy on me! i think the problem is something to do with
Code:
For n = 1 To Len(target)
If guess = Mid(target,n , 1) then
inword = True
mid(temp, n, 1) = guess
mid(target, n, 1) ="*"
found = found +1

End If
Next n

Any suggestions? here is the form http://www.johnhutton.plus.com/pleasework.zip

Copyright 2005-08 www.BigResource.com, All rights reserved