POLALA.COM
welcome to my space
X
Welcome to:polala.com
Search:  
NAVIGATION: Home >>

bouncing problem with my golf game :(

Published by: rose 2010-03-16
  • I have got a problem with the little golf game I am making. It's still pretty early and I haven't coded some things but the ball does not bounce when it hits the wall. It kind of like rolls along the side. I've attached the .fla for MX If anyone could help me figure out why the ball does not bounce, I would love yew :love:


  • I have the code that if it hits a left wall for example it multiples xmove by -1

    i have no idea whats wrong :'(


  • omg thats weird... when i put the == in the statements there the initial ball placement doesn't work : but it works right with just = there... doesn't solve the problem though :(


  • anyone :'( ?


  • Roger that... I'll post all the code :)

    Code for the arrow(gauge)

    onClipEvent (load) {
    this._visible = 0;
    fire;
    scale = 0;
    powerpick = 0;
    anglepick = 0;
    angle = 0;
    speed = 0;
    }
    onClipEvent (enterFrame) {
    if (_root.ball.spot == 1) {
    this._visible = 1;
    this._x = _root.ball._x;
    this._y = _root.ball._y;
    if (powerpick == 0) {
    scale = _root._xmouse - _root.ball._x;
    if (scale > 40) {
    scale = 40;
    }
    if (scale < 5) {
    scale = 5;
    }
    this._xscale = scale;
    speed = scale/5;
    }
    if (powerpick == 1 and anglepick == 0) {
    var dx = _parent._xmouse - this._x;
    var dy = _parent._ymouse - this._y;
    angle = Math.atan2(dy, dx);
    this._rotation = angle*180/Math.PI;
    }
    if (fire == 1) {
    this._visible = 0;
    _root.ball.xmove = Math.cos(angle)*speed;
    _root.ball.ymove = Math.sin(angle)*speed;
    speed -= .05;
    if (speed < 0) {
    speed = 0;
    fire = 0;
    }
    }
    }
    }



    Code on the ball

    onClipEvent (load) {
    spot = 0;
    this._x = _root.base._x;
    this._y = _root.base._y;
    California (CA) : Los Angeles/Pasadena [Archive] - Page 2 ::
    100+ posts - Last post: Mar 6, 2007We're in Pasadena, at a place called Game Empire (formerly Gamezone). My problem with draft was that I walked in knowing what deck I
    http://www.vsrealms.com/forum/archive/index.php/t-40380-p-2.html
    HOME
    this day in history [Archive] - Page 2 - FileCabi.net Forum::
    Funny, I was talking with my Grandmother the other day about Frances Farmer. the windshield of a car with a golf club, screaming "You cut me off!
    http://filecabi.net/forum/archive/index.php/t-8372-p-2.html
    HOME
    xmove = 1;
    ymove = 1;
    }
    onClipEvent (enterFrame) {
    //initial ball location
    if (spot == 0) {
    if (xmove = 1) {
    this._x = _root._xmouse;
    }
    if (ymove = 1) {
    this._y = _root._ymouse;
    }
    if (this._x < 38) {
    xmove = 0;
    this._x = 38;
    }
    if (this._x > 72) {
    xmove = 0;
    this._x = 72;
    }
    if (this._y < 38) {
    ymove = 0;
    this._y = 38;
    }
    if (this._y > 102) {
    ymove = 0;
    this._y = 102;
    }
    }
    //wall hitTests
    if (this.hitTest(_root.left1) this.hitTest(_root.left2) this.hitTest(_root.left3)) {
    xmove *= -1;
    }
    if (this.hitTest(_root.right1)) {
    xmove *= -1;
    }
    if (this.hitTest(_root.top1) this.hitTest(_root.top2)) {
    ymove *= -1;
    }
    if (this.hitTest(_root.bottom1) this.hitTest(_root.bottom2)) {
    ymove *= -1;
    }
    if (_root.gauge.fire == 1) {
    this._x += xmove;
    this._y += ymove;
    }
    }
    onClipEvent (mouseDown) {
    if (_root.gauge.powerpick == 1) {
    _root.gauge.anglepick = 1;
    _root.gauge.fire = 1;
    }
    if (_root.gauge.powerpick == 0 and spot == 1) {
    _root.gauge.powerpick = 1;
    }
    if (spot == 0) {
    spot = 1;
    mouse.hide();
    }
    }


  • Didn't get a chance to look at it too much.. But I'm going to take a guess that your movement variable needs to be flipped.


  • I don't think it has anything to do with your formula there... I haven't done cos and sin in a while for games.. But I know that should be correct... (thinks about it for a minute)... Yes.. That is correct...

    So... Hmm... Post some more code.. I'd look at the file.. But I'm working on literally 3 things right now.. ;)


  • Alright I just tried that and when it hit the left wall I set it so that the _x would be += to 100. It would hit the wall and then move out the 100 then would continue to go back in the direction and "hump" the wall yet again :

    Do you think it would have something to do with the formula I am using?

    scale is a variable for the power of the ball, ball is the movie clip where xmove and ymove are stored...


    speed = scale/5;
    _root.ball.xmove = Math.cos(angle)*speed;
    _root.ball.ymove = Math.sin(angle)*speed;


    It's really starting to get annoying now :


  • Thats exactly what I was thinking it was doing. That is a good idea about shooting it out a little. I have been trying to use a setInterval so that it won't hitTest for about a second or so that way itll have time to leave.

    Needless to say I didn't get that to work :P

    I'll try your idea quick


  • hmmm, I see xmove and ymove being set to zero if certain conditions are met, and then on hittest those zeros are multiplied by -1 giving zero again. Looks like you need an else statement to reset the value of xmove and ymove after collision, otherwise it "kind of like rolls along the side."


  • There is something obvious I'm overlooking then... So... I'm going to let someone else ook at the code... Because. It's probably obvious..But my brain has been racked over 20 different things today.. Sorry bud :)


  • Hmm... Make sure that the ball isn't going "in" the wall then.. If if goes into the wall.. It may keep testing that and keep rotating it around.. Everytime the ball hits a wall. If it is on the left.. Maybe jerk the ball out a little to the right after it hits the wall. :)


  • Okay... Let's address things problem by problem...

    First problem..

    //initial ball location
    if (spot == 0) {
    if (xmove = 1) {
    this._x = _root._xmouse;
    }
    if (ymove = 1) {
    this._y = _root._ymouse;
    }


    That should have == instead of = in the if statement causes... See if that helps out any





  • Where's The Advantage In Windows Genuine Advantage?
    Stocks Bounce After S&P Joins Bear Market
    You are looking at:polala.com's bouncing problem with my golf game :(, click polala.com to home
    #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about bouncing problem with my golf game :( , Please add it free.
  • what do you think of a jeep commander
  • what tires do i need for a lexus ls400
  • were are some places in lincoln nebraska were they dont card you for stuff like cigs
  • change lexus es350 to the metric system
  • what is the most autc way to install hid headlamps on a lexus is
  • jeep cooling fan issues
  • what is the difference between a v8 4 7 liter and a v8 5 3 liter
  • is it ok to tow a 3500lbs boat with a jeep grand cherokee with a 3 lift
  • lincoln town car leak above block everything 039 s dry no loose hoses no room can 039 t see anything
  • which year lincoln makes a good daily driver
  • my jeep started making a clunking noise while sitting
  • i have a 2002 lincoln lse and i want to know how to remove the headlight can anyone help me out
  • can i put a fuel pump from a 96 jeep grand cherokee in a 98 jeep grand cherokee
  • spare tire on my 2006 lexus is250 broke what can i look for at junkyards
  •  
  • oil leak on liberty jeep crd diesel
  • 1995 jeep gc laredo help transmission
  • anybody get financing from lexus finance for a 2008 gx teir 1 is it better to get loan somewhere else
  • 2000 jeep wrangler tj
  • i bedazzled my lexus
  • what is wrong with my 2000 v8 lincoln ls
  • shall i buy a lexus es 350 or shall i wait because of the current financial crisis
  • does anyone know where i can find a remote control jeep wrangler that runs off of gas
  • how can i make my lexus is 250 faster
  • why does my jeep say the back door is open when it is not
  • is insurance on jeeps more expensive
  • no heat in 90 lincoln towncar
  • jeep cherokee fuel injector upgrades
  • About us |Contact us |Advertisement |Site map |Exchange links
    Copyright© 2008polala.com All Rights Reserved