Results 1 to 16 of 16

Thread: 2d scrolling

  1. #1

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211

    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.

  2. #2

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    kinda like the game dirt bike

  3. #3
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Well, do you want to use Visual Basic controls like the Image control, or do you wanna use complex stuff like BitBlt or DirectX?
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  4. #4

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    well this is my first time making a game so ill use the visual basic stuff

  5. #5
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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:
    1. Private Sub tmrBackgroundScroll_Timer()
    2.   picBackground1.Top = picBackground1.Top + 1
    3.   picBackground2.Top = picBackground2.Top + 1
    4.  
    5.   If picBackground1.Top > frmGame.ScaleHeight Then picBackground1.Top = 0
    6.   If picBackground2.Top > frmGame.ScaleHeight Then picBackground2.Top = 0
    7. End Sub

    That should work
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  6. #6
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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)
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  7. #7

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    how would i make it where like if u pushed the up key it wold scroll and if u didnt it wouldnt scroll

  8. #8
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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:
    1. 'Put this in the Form_KeyDown event...
    2.  
    3. If KeyCode = vbKeyUp Then
    4.   'The other code I gave you goes here...
    5. 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.
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  9. #9
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  10. #10
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    LOL

    Yeah, I'm just to lazy to open up VB and check if I'm right or not
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  11. #11

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    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

  12. #12
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Weird... Use this code to make it scroll right:

    VB Code:
    1. picBackground1.Left = picBackground1.Left - 1
    2.   picBackground2.Left = picBackground2.Left - 1
    3.  
    4.   If picBackground1.Left < 0 Then picBackground1.Left = frmGame.ScaleWidth
    5.   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
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  13. #13
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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.
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  14. #14

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    where is the form downkey event?

  15. #15
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Double-click the form... the go to the second drop-down list in the top and choose "KeyDown".
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  16. #16

    Thread Starter
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    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
  •  



Click Here to Expand Forum to Full Width