Results 1 to 10 of 10

Thread: side scroller without bitblt

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39

    side scroller without bitblt

    I attached a sidescroller program in which I did not use any API
    or whatsoever to write this

    please help me on the collision detection
    and gravity as well
    i dont mind using a bit of API

    theres this icon 'dont walk' in it
    the thing are not suppose to walk oever it
    u can jump over it and stand over it
    any help?
    Attached Files Attached Files
    Code:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    >>  ___      __ ____   ____     _         ____    <<
    >>  \  \    /  / _  | |  __|   | |       |  __|   <<
    >>   \  \  /  / |_| | | |__    | |       | |__    <<
    >>    \  \/  /|  _ <  |__  \   | |       |  __|   <<
    >>     \    / | |_| |  __)  )  | |___  _ | |__    <<
    >>      \__/  |_____| |____/   |_____||_||____|   <<
    >>		      			          <<
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
          Visual Basic 5 SP3 Learning Edition.
    
    Sub QuoteOfTheDay()
    If ASCII.ugly = True Then
      WhatTheHeck.ICare = True
    End If
    End Sub

  2. #2
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221

    Thumbs up Nice work

    Nice job.
    You can try using the IntersectRect API function, it's fast, and does a great job for collision detection.
    "1 4m 4 1337 #4xz0r!'
    Janus

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39
    Well
    can u help me with the code?
    its pretty confusing i know
    is it possible to add gravity in it?
    thanks a lot
    Code:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    >>  ___      __ ____   ____     _         ____    <<
    >>  \  \    /  / _  | |  __|   | |       |  __|   <<
    >>   \  \  /  / |_| | | |__    | |       | |__    <<
    >>    \  \/  /|  _ <  |__  \   | |       |  __|   <<
    >>     \    / | |_| |  __)  )  | |___  _ | |__    <<
    >>      \__/  |_____| |____/   |_____||_||____|   <<
    >>		      			          <<
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
          Visual Basic 5 SP3 Learning Edition.
    
    Sub QuoteOfTheDay()
    If ASCII.ugly = True Then
      WhatTheHeck.ICare = True
    End If
    End Sub

  4. #4
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221

    Wink Sure

    I'd be glad to help.
    Gravity isn't that hard, as long as you don't mind using Singles to store your Y and Y Velocity.

    Feel free to email me, or we can work via the message board, or via ICQ (130863581).
    "1 4m 4 1337 #4xz0r!'
    Janus

  5. #5
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221

    Thumbs up Code

    Public Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
    Public Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type

    ' For forms using ScaleMode 1 - Twips
    Public Function RectFromControlTwips(Ctl As Control) As RECT
    Dim CtlRect As RECT
    With CtlRect
    .Left = Ctl.Left \ Screen.TwipsPerPixelX
    .Top = Ctl.Top \ Screen.TwipsPerPixelY
    .Right = (Ctl.Left + Ctl.Width) \ Screen.TwipsPerPixelX
    .Bottom = (Ctl.Top + Ctl.Bottom) \ Screen.TwipsPerPixelY
    End With
    End Function

    ' For forms using ScaleMode 3 - Pixels
    Public Function RectFromControl(Ctl As Control) As RECT
    Dim CtlRect As RECT
    With CtlRect
    .Left = Ctl.Left
    .Top = Ctl.Top
    .Right = Ctl.Left + Ctl.Width
    .Bottom = Ctl.Top + Ctl.Bottom
    End With
    End Function
    "1 4m 4 1337 #4xz0r!'
    Janus

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39
    thanks

  7. #7
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221
    To check for collisions, try something like this:

    Dim NewRect as RECT
    If IntersectRect(RectFromControlTwips(Image1), RectFromControlTwips(Image2), NewRect) Then
    ' Collided
    End If
    "1 4m 4 1337 #4xz0r!'
    Janus

  8. #8

    Thread Starter
    Member
    Join Date
    Oct 2000
    Posts
    39
    i get error for using

    .Bottom = Ctl.Top + Ctl.Bottom

    It seems that my image had no properties of a bottom
    how to cure that?

    btw,
    which one is use for gravity?
    and u told me not to store single x and y variable
    can u tell me how to do that?
    thanx
    Last edited by nameJack; Oct 6th, 2001 at 05:37 PM.
    Code:
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    >>  ___      __ ____   ____     _         ____    <<
    >>  \  \    /  / _  | |  __|   | |       |  __|   <<
    >>   \  \  /  / |_| | | |__    | |       | |__    <<
    >>    \  \/  /|  _ <  |__  \   | |       |  __|   <<
    >>     \    / | |_| |  __)  )  | |___  _ | |__    <<
    >>      \__/  |_____| |____/   |_____||_||____|   <<
    >>		      			          <<
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
          Visual Basic 5 SP3 Learning Edition.
    
    Sub QuoteOfTheDay()
    If ASCII.ugly = True Then
      WhatTheHeck.ICare = True
    End If
    End Sub

  9. #9
    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
    Hum I'd do it the old VB way

    VB Code:
    1. If Img1.Left + Img1.Width >= Img2.Left And _
    2.   Img1.Top + Img1.Height >= Img2.Top And _
    3.   Img1.Left <= Img2.Left + Img2.Width And _
    4.   Img1.Top <= Img2.Top + Img2.Height Then
    5.     'We've got a collision!
    6. End If

    You can do this:

    1) Remember the position (Left/Top) of the image BEFORE you move it, using variables
    2) Move the image
    3) If it collides with a platform, move it back to the position you saved in the variables
    Last edited by Jotaf98; Oct 7th, 2001 at 02:44 PM.
    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."

  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
    Btw, you should have 1 variable (boolean) for each key; in the KeyDown event, you set it to True; in the KeyUp event, you set it to False. Then, in the Timer, for example, just check if the Left key is being pressed (the boolean variable is True) and move the image to the left
    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."

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