hold would i make like a game that scrolles a lomg the screen
Printable View
hold would i make like a game that scrolles a lomg the screen
kinda like the game dirt bike
Well, do you want to use Visual Basic controls like the Image control, or do you wanna use complex stuff like BitBlt or DirectX? :)
well this is my first time making a game so ill use the visual basic stuff :)
Ok... for the scrolling, the only way would be to have 2 pictureboxes with the background image: one occupying the whole form, and another exactly above it.
Then, put this code in the form.
You'll need a timer with the interval set to something like 20 or 10 miliseconds, and the form must have the scalemode set to 3 - Pixels:
VB Code:
Private Sub tmrBackgroundScroll_Timer() picBackground1.Top = picBackground1.Top + 1 picBackground2.Top = picBackground2.Top + 1 If picBackground1.Top > frmGame.ScaleHeight Then picBackground1.Top = 0 If picBackground2.Top > frmGame.ScaleHeight Then picBackground2.Top = 0 End Sub
That should work :)
Btw, to have the second picturebox above the first one, all you have to do is set its Top to its Height with a minus sign before it (eg.: if the Height is 200, the Top would be -200)
how would i make it where like if u pushed the up key it wold scroll and if u didnt it wouldnt scroll
Sure, instead of making it happen in the timer event, put it in the Form_KeyDown event, and check if the key is being pressed. Since you want the Up arrow, just use this:
VB Code:
'Put this in the Form_KeyDown event... If KeyCode = vbKeyUp Then 'The other code I gave you goes here... End If
That should work. I'm not sure if it's "vbKeyUp" or "vbKeyUpArrow". This way it will scroll the map ONLY when you press the key.
Don't worry you got it right Jotaf :D
LOL :D
Yeah, I'm just to lazy to open up VB and check if I'm right or not :)
hmmm can get it to work it says that the keycode is a invaid ouside pocedure.....and how would i make it scroll right insted of down
Weird... Use this code to make it scroll right:
VB Code:
picBackground1.Left = picBackground1.Left - 1 picBackground2.Left = picBackground2.Left - 1 If picBackground1.Left < 0 Then picBackground1.Left = frmGame.ScaleWidth If picBackground2.Left < 0 Then picBackground2.Left = frmGame.ScaleWidth
Ah, don't forget to put the picturebox that is above the other one in the right :)
Oh, I think I know why you're getting that error. You didn't try to put the whole code I gave you inside the KeyDown event, right? :rolleyes: You'd have to remove the "Sub ..." and "End Sub" code.
where is the form downkey event?
Double-click the form... the go to the second drop-down list in the top and choose "KeyDown".
it goes even if i dont push up