Wazza
06-07-2001, 07:01 PM
I am having a real problem, I have very little experience in Vb 6.0 and my teacher hasnt got a clue, and i am trying to recreate the simple Space invaders original, from comadore64 but I dont know how to do any graphics and i have little experience with code, and my Majorwork is due in less than a month. Can anyone help me out on how to meke these graphics and with the code????????
Also, how do I attach the code to control the movement of the spaceship ffrom the keyboard keys?????????
Computer_Guy
06-07-2001, 07:12 PM
Okay, here is how to make the spaceship move
in the form properties, set keypreview to TRUE
next
in the code, go to form load, click on the box that says load, and select KeyDown, click that
a new menu will look like this:
Form KeyDown(keycode as integer, shift as Integer)
Then you say...
If KeyCode = vbKeyLeft And ImgSpaceship.left > picSpace.left Then
imgSpaceShip.left = imgSpaceShip.left - 100
ElseIf KeyCode = vbKeyRight And ImgSpaceShip.left + imgSpaceShip.Width < picSpace.width Then
imgSpaceShip.left = imgSpaceshipleft + 100
End if
Try this code out, and it should work with the keycode.
andrewo
06-21-2001, 06:31 AM
well use the keypress event in form keydown bit.
or use the example above...
so when u push the key to go left maybe have
an image as the spaceship and say image.left = image.left - 20
the 20 stands for the distance to move left.
and for right have
image.left =image.left +1
i dont really know anything about shooting but you could
create like 10 bullet images and have them set to visible=false
and every time u press a fire button
have an if statement like
if bullet1.visible = false then bullet1.visible = true
if bullet1.visible = true then...
have the first bullet image to move to the ships position
like bullet1.left = spaceship.left
and bullet1.top = spaceship.top
then have a timer maybe to enable and say
bullet1.top = bullet1.top + 30
so the bullet will move up
and when it reaches the top of the screen use a if statement to make it disapear.
and when u fire another bullet have an if statement to
say
if bullet1.visible = true then bullet2.visible
etc etc
this is a very bad way of doing it and will require loads of code but it may work :)