|
-
Sep 20th, 2001, 11:27 PM
#1
Thread Starter
Frenzied Member
2d scrolling
hold would i make like a game that scrolles a lomg the screen
Last edited by Motoxpro; Sep 21st, 2001 at 01:32 AM.
-
Sep 21st, 2001, 05:37 PM
#2
Thread Starter
Frenzied Member
kinda like the game dirt bike
-
Sep 22nd, 2001, 01:36 PM
#3
Frenzied Member
Well, do you want to use Visual Basic controls like the Image control, or do you wanna use complex stuff like BitBlt or DirectX?
-
Sep 22nd, 2001, 02:00 PM
#4
Thread Starter
Frenzied Member
well this is my first time making a game so ill use the visual basic stuff
-
Sep 22nd, 2001, 02:10 PM
#5
Frenzied Member
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
-
Sep 22nd, 2001, 02:13 PM
#6
Frenzied Member
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)
-
Sep 22nd, 2001, 02:58 PM
#7
Thread Starter
Frenzied Member
how would i make it where like if u pushed the up key it wold scroll and if u didnt it wouldnt scroll
-
Sep 23rd, 2001, 04:36 PM
#8
Frenzied Member
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.
-
Sep 23rd, 2001, 04:46 PM
#9
Good Ol' Platypus
Don't worry you got it right Jotaf
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Sep 23rd, 2001, 05:06 PM
#10
-
Sep 23rd, 2001, 05:10 PM
#11
Thread Starter
Frenzied Member
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
-
Sep 23rd, 2001, 06:00 PM
#12
Frenzied Member
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
-
Sep 23rd, 2001, 06:04 PM
#13
Frenzied Member
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? You'd have to remove the "Sub ..." and "End Sub" code.
-
Sep 23rd, 2001, 06:08 PM
#14
Thread Starter
Frenzied Member
where is the form downkey event?
-
Sep 23rd, 2001, 06:16 PM
#15
Frenzied Member
Double-click the form... the go to the second drop-down list in the top and choose "KeyDown".
-
Sep 23rd, 2001, 07:17 PM
#16
Thread Starter
Frenzied Member
it goes even if i dont push up
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|