Results 1 to 10 of 10

Thread: Got a game that doesn't collide right...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82

    Exclamation Got a game that doesn't collide right...

    Hi, im back with my "diamonds" game. I've fixed most of the problems i had before, but now i've come across a whole new prolem. My game doesn't quite collide right. If the ball collides with 2 or more walls, or it collides from the side, then the ball simply goes through the wall. I've tried everything that i can think of, but nothing seems to work right. Any help here would be hot.
    Attached Files Attached Files
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  2. #2
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    I did not look at the game (is the source included?)
    so I really do not know how you work your collisions, but it kind of sounds like you move your object an than check for collision. You have to check for collision and move afterwards... (well in some ways its the same, but well if you look at you code you might know what I mean in case you did it wrong)
    than there is some other important thing about collision
    it is not enough to check if the destination point of a movement is collision free but the whole way there needs to be free of obstacles...

    (I try to put it into ASCII):
    x----->x
    this shows a movement to the right with the speed of 5 pixels
    now it is not enough to check if the second x is a square you can move to but all the - in between need to be free, too.
    Sanity is a full time job

    Puh das war harter Stoff!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    i hadn't thought of that before. I'll give it a try and check back tomarrow.

    PS- source code is included, so check it out.
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  4. #4
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    yeah well it is 6 am here I will do that after getting some sleep
    good luck!
    Sanity is a full time job

    Puh das war harter Stoff!

  5. #5
    Junior Member
    Join Date
    Mar 2002
    Location
    Porsgrunn,NORWAY
    Posts
    30
    Maybe this can help. You need to rename my dim's though :=)

    select case mball.x
    case < scaleleft
    mball.xway=-mball.xway
    mball.x=mball.x+mball.width*speed 'to get it away from wall..
    (used speed here in case you have different speed modes.
    when ball is at great speed it can jump across wall.)
    case > scalewidth
    mball.xway=-mball.xway
    mball.x=mball.x-mball.width*speed
    end select

    select case mball.y
    case < scaletop
    mball.yway=-mball.yway
    mball.y=mball.y+mball.width*speed
    case > scaleheight
    mball.yway=-mball.yway
    mball.y=mball.y-mball.width*speed
    end select

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    USA all the way!
    Posts
    82
    thnx for the help, but unfortunately I haven't been able to try any of your methods due to me having to take a stoopid driving course for my license. But I think the last one, by Kennethj will work the best. See, the ball only moves sideways when the player is pressing the keys, but it is always moving up and down.
    Often talked of, never seen,
    Ever coming, never been,
    Daily looked for, never here,
    Still approaching, coming near,
    Thousands for its visit wait,
    But alas for their fate,
    Tho' they expect me to appear,
    They will never find me here.

    What's this about?

  7. #7
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    that works great for side collision but not for obstacles somewhere in the screen if the velocity is so big that a step would be longer than the obstacle.
    I hope you got what I said, I am not sure if I would if I wouldn't know what I mean
    Sanity is a full time job

    Puh das war harter Stoff!

  8. #8
    Junior Member
    Join Date
    Mar 2002
    Location
    Porsgrunn,NORWAY
    Posts
    30
    /\/\isanThr0p give me an example of yours. Relating to the obstacles you mentioned.

  9. #9
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    well if you have a game where there is fixed boundaries like in a pong game the ball can never be any further than let's say 500 so it's enough to check if ballx > 500 than collide

    but if there is an obstacle it's not that easy. (sorry I will explain later, my pc is about to crash... )
    Sanity is a full time job

    Puh das war harter Stoff!

  10. #10
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    alright I am save I guess...

    so here a little example:
    you move with a speed with 5 pixels/time

    x----->
    ok now you got an obstacle beeing 2 pixels wide
    if you move with the speed of five there are following possibilities:
    x----|| now you see that the object (the x) has hit the the obstacle after moving 5 pixels so you know you got a collision.
    it is more difficult if you got something like that:
    x-||--> now you kind of jumped over the obstacle, because you moved further than it's width. so now if you check you destination point is ok, but you could have never gotten there that way, so it is not enough to check if your destination point is free, but all the points in between need to be checked too.
    Sanity is a full time job

    Puh das war harter Stoff!

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