A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 30

Thread: Gaming Problem - Boncy walls

  1. #1
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870

    Car Bondary! Game!

    i am trying to create a basic driving game, but i got this problem with it's movements: The car just DRIVE OUT OF THE SCREEN!Dose anyone know how to make a MC that stops the car moving when it reaches the end of it's frame.
    Last edited by tongxn; 10-03-2005 at 02:08 PM.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  2. #2
    Flasher
    Join Date
    Jun 2005
    Posts
    1,365
    Yes. It's possible. Try the "if" action and use the y/x variables to tell Flash to stop the MC when it gets to a certain x/y location. Sorry don't have the time to write the script right now....

  3. #3
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    but i really need to write the script.. anyway, just give me a tip on the main script
    PLZPLZPLZPLZ
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  4. #4
    Your Mom Is A Registered User
    Join Date
    Jul 2004
    Posts
    42
    //before movement
    last_x = _x
    last_y = _y
    //after movement
    if (_x > 550) {
    _x = last_x
    }
    if (_y > 400) {
    _y = last_y
    }
    if (_x < 0) {
    _x = last_x
    }
    if (_y < 0) {
    _y = last_y
    }

  5. #5
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Maybe i should change that...
    //before movement
    last_x = _x
    last_y = _y
    //after movement
    if (_x > 800) {
    _x = last_x
    }
    if (_y > 600) {
    _y = last_y
    }
    if (_x < 0) {
    _x = last_x
    }
    if (_y < 0) {
    _y = last_y
    }

    Is this right?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  6. #6
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Em..where should i put the actionscript on? the car, the frame, or the background?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  7. #7
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    nope, that don't help, any other ideas about Hittest or something eles?
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  8. #8
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Ohh.. any other ideas???!
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  9. #9
    Flash, Mans greatest invention
    Join Date
    Jul 2005
    Posts
    382
    the script is right

    you attach it to the main timeline

    urm hitTest you could just to find if the car over laps something then use some kind of stop action but i would really suggest the script you were already given.

  10. #10
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    u can use hittest and have the action be that it moves in the opposite direction from the wall or whatever the same # as what the movement speed is...if u understood that

    :]
    Z¡µµ¥ D££

    Soup In A Box

  11. #11
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    no
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  12. #12
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    sory
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  13. #13
    Junior Member
    Join Date
    Oct 2005
    Posts
    2
    will this work here as well?
    http://www.ill-conceived.com/media/3...e-roomtst.html

    I cant seem to get hitTest to keep me from walking thorugh the walls.

    The walls are built out of a separeate class, where I can specify the size and # of sides (if this helps)

    Let me know,
    Thanks

  14. #14
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    Thanks for the idea, but i seem to make a 2D car game, and i don't get the idea about the roomtst?
    Sory
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  15. #15
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    I really thank the person who would give me the right answer though....
    But it seemed no1 have the solution...
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  16. #16
    Junior Member
    Join Date
    Oct 2005
    Posts
    2
    Quote Originally Posted by tongxn
    Thanks for the idea, but i seem to make a 2D car game, and i don't get the idea about the roomtst?
    Sory
    I was asking how to get the code they supplied to work in that project. hitTest doesnt seem to work, this code may, but I havnt got it to yet.... any one know?

  17. #17
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    not me, and would u mind move that thread out of my Post?
    Thank you.
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  18. #18
    Flash, Mans greatest invention
    Join Date
    Jul 2005
    Posts
    382
    You have been given the anwser over and over you just keep ignoring it

    hitTest or simply make it so the cars x and y go past a certain position it goes in the reverse x/y

  19. #19
    XRave tongxn's Avatar
    Join Date
    Apr 2005
    Location
    Somewhere near Here
    Posts
    870
    it don't work for me i think!
    When you actually know what "OMG I have so much homework!" means, you won't want to be me.
    Xrave

  20. #20
    Spaghetti-Code Extraordinaire
    Join Date
    Sep 2005
    Location
    Chattanooga, TN.
    Posts
    53
    hittest would work if you say:

    PHP Code:
    movementSpeed;

    if(
    car.hitTest(rightWall)){
         
    car._x -= z;
    }

    if(
    car.hitTest(leftWall)){
         
    car._x += z;
    }

    if(
    car.hitTest(topWall)){
         
    car._y += z;
    }

    if(
    car.hitTest(bottomWall)){
         
    car._y -= z;

    This is just an idea of how i use hitTest to stop things. Hope this helps...
    Last edited by hippofungus; 10-14-2005 at 03:55 PM.

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

HTML5 Development Center