• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

code a game

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

blackhabit

Member
Joined
Nov 19, 2002
Location
WI (in my small bedroom dungeon)
i am in visual basic and my semester class is coming to a end we have one last program to code and it has to be a game. i got one of the last picks( no two people can have the same game) and i wanted to do something like holdthebutton.com, but she said that that would be two easy so then i thought of pong and i realized that i would have to code the computer also, and then that turn me away so what i picked for my game is break out where there are blocks on the top of the screena nd you have you pong bar on the bottom and you hit the ball at the block so that they fall down or blow up. and then when you get all the blocks you go to the next level. i would only like to have a total of three levels. andi reall dont want to make this project to hard. plus i am really bad at programming. i am getting a c in the class now and well it just does not come natural to me like it does to others. my questions is can you help me get started or is there a nice link you can send my way thay would help me out.thanks alot
 
You might be able to see an example of what you are trying to do at http://www.freevbcode.com/ShowCode.Asp?ID=913 or http://www.homestead.com/vbgames6/game.html .

unless you are using VB .NET.

For .NET you might look at;
http://www.c-sharpcorner.com/Code/2002/April/SpaceBreakOutMJ.asp

Ths one is done in C# but might help you find the which objects/methods/etc to use.

These are only meant to provide guidance, if you can be more specific about the version of VB you are using, some people in here (my self included) might be able to provide help or help you work through any bugs you might run into.
 
If programming does not come naturally to you I would pick something a little less in depth than breakout... hangman? jeapardy? how about tic tac toe, or scrabble? just some thoughts. If you are interested in this program, nemisys is right, let us know what version you are using and maybe we can help you out when you get stuck.
 
most of those other games already have been taken and i have been thinking about how to do it and it will be hard for me but at the same time a good challenge that will teach me some new stuff. i am not sure what version of visual basic i am using just what the school has it is visual basic 6 i know run on windows 98 and well that is about all i know. i am seeing if i can get a version of it from my friend cause i dont have it at home i only work on it at school but i would like to at home because it will take me a longer time to code it. well i will be starting to code it tommorro and when i come into a problem i know where to come. thanks alot
 
No problem, There quite a few people here who can help. And there are a ton of resources that you can find on the web. Good luck, and let us know how it turns out.
 
you can use a proxy to get to the sites... i dont knwo any off hte top of my head but my friend uses it to get to his site cuz he hosts porn for some other site and he cant get onto HIS becasue of it... kinda funny... try searching google for a proxy:D :D :D
 
hey CrashOveride you know i tried looking up proxy and they wont even let me look at the search results here at school (stupid school) well i will check it out when i get home.
( i spend on my time on the forums here at school) not much at home.
plus i got visual basic 6 from a friend and now i can work at home on it.
 
Last edited:
Can you think of something RPGish? Something where you're making decisions at each turn. Or maybe a card game or board game of some sort (that doesn't require much AI). Rather than something action oriented where you have to worry about graphics and detecting where you graphical objects are and what they are interacting with. If you have some experience with graphics you can go for it, though. My suggestion would be something like a simplified version of Asteroids, like scroll some circles horizontally across the screen and make the player dodge them by moving up and down. You can make it more complicated if you want, allow the player to shoot the circles, larger circles requiring more shots to destroy. Think about your data structure, how you would keep track of the circle, the values it might have:
X
Y
strength (number of shots before it is destroyed)
speed
color
etc...

Just an idea... Good luck.
 
thanks nil_esh but i already have started playing around with the breakout one and i got some source code off the net at home and been studying that( no i am not copying it) and seeing what needs of mine will be similar and how i will go about coding each need. so far i am on a good track. and every problem i am come in to i have figured out or a way around. nothing has me really that stuck at this point. well thanks and when i do get stuck for good i will be back asking some questions
 
ok i think i might have a problem ok here is my code so far for this part what i want to do is when the player runs out of balls( he only gets three) a msgbox comes up saying do you want to restart if he choose yes then the form reloads if he presses no the i want the form to unload.(jail is the form name)

Dim sngMsg As Single
Dim intUserResponse As Integer
Const conBtns = 1
If ball1 >= 3 Then

sngMsg = MsgBox("you have missed 3 balls GAME OVER, Do you want to restart")
sngMsg = conBtns
conBtns = vbYesNo + vbDefaultButton1 + vbExclamation + vbApplicationModal
'if thenStatement
If intUserResponse = vbYes Then
Load jail
Else
Unload jail
End If

End If
now what happens is when the player misses three balls it tells me compile error assignment to consant not permitted so how do i make all this work out thanks alot
 
What I believe you want is (I dont have my compiler but I will double check this tommorrow(or if one of the other guys can check it thanks as I'm in meetings until 4:00)


If ball1 >= 3 Then
sngMsg = MsgBox("you have missed 3 balls GAME OVER, Do you want to restart", vbYesNo + vbDefaultButton1 + vbExclamation, vbModal)

'if thenStatement
If intUserResponse = vbYes Then
Unload jail ' You may need to do this to reset all your variables
Load jail ' Reload the main screen
Else
msgbox("Thank you for playing")
'Close all objects
Unload jail
End If

End If
 
that seems like it should work by looking at it, it is much closer it run and the msg boxes come up but it does not restart when i choose restart, plus at the first msgbox when it says
"you have missed 3 balls GAME OVER, Do you want to restart" there is only one command button to choose. lets say the user do not want to restart, so what i would like to do is have it say
"you have missed 3 balls GAME OVER, Do you want to restart" and then have two choices yes and the game will reload (start over) or no and it will exit and then if wanted but really not needed the other msgbox saying "thank you play again" with only one command button to choose (the ok button) i hope this make sense and Krieger your way sure seems like it should work but it doesn't want to be very nice
 
loos like you will need to pass the type of messagebox in the parameters for msgbox()

something like vbYesNoCancel would tell the message box to have a Yes, No, and Cancel button. I don't remeber the exact one for the two buttons, but the intellisense in your VB6 editor should give you a drop down with choices.
 
this is making me mad now yes and no come up for the first msg box but both end the game and i cant figure out why when you click yes it doesn't reset and start over. i tried calling the form load event procedurer, and still no why help it is wednes day and it is due monday
 
How bout somethin like:

Code:
Dim testmsg As Integer 
testmsg = MsgBox("Click to test", vbYesNo)
If testmsg = 1 Then 
  'Reload Form 
Else 
  'Unload Form
End If

just replace the commented parts with either sub/function calls to your code or insert your code directly there.
 
Ok, I have been looking a little more and this is how I would adjust your code
Code:
Dim intUserResponse As Integer
If ball1 >= 3 Then
  sngMsg = MsgBox("GAME OVER, Do you want to restart", vbYesNo + vbDefaultButton1 + vbExclamation, vbModal)
  If intUserResponse = 0 Then
    Unload jail
    Load jail
  Else
    msgbox("Thank you for playing")
    Unload jail
  End If
End If

However, and someone may want ot confirm or deny this, but make sure jail is a child form and that the parent form is calling the load and unload methods on the form jail. Once the form unloads itself it is not going to execute anymore code thus it wont reload itself.

Also, you can do some thing like this to reload the jail form
Code:
Set jail = Nothing
jail.Load

As long as all the variables are declared in the jail form, the parent form can use this code to reload it and let the jail for reinitialize everything.
 
Last edited:
Ok, here is how I would do it for a single form (psuedo code)

Code:
Option Explicit
Dim variable1 as whatever
Dim variable2 as whatever

Sub From.Load()
  Call the Sub to set values
End Sub

Sub Setvals()
  variable1 = something
  variable2 = something
End Sub

Sub OnLose()
  Dim i as integer
  i = msgbox(whatever)
  If i = 1
    call SetVals() Sub
  Else
    Unload Form
  End If
End Sub

Now, you will naturally have other subs to handle the ingame display and incrementing the Values. But, this should show the generic structure when resetting things.
 
Back