User Tag List

Results 1 to 6 of 6

Thread: Problem with Float Point, please help

  1. #1
    No Products Registered

    Join Date
    Sep 2009
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with Float Point, please help

    I want to move the X position by, let's say, 1.5, but it always count it as 1. This is my code:

    Repeat while (Joystick) Moved left
    Player: Set Pos X to -1.5

    Repeat while (Joystick) Moved right
    Player: Set Pos X to 1.5

    NO Repeat while (Joystick) Moved left
    NO Repeat while (Joystick) Moved right
    Player: Set Pos X to 0

    Always
    Player: Set X position to X("Player")+ Pos X ("Player")

    Where Pos X is Alternate Value A.

    Thanks

  2. #2
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with Float Point, please help

    This is because the X position of the player is only whole numbers, so when you add +/- 1.5 to it it always rounds the half out.

    You need to do it like this:
    Start of Frame:
    Player: Set alt Pos X to X("Player")

    Repeat while (Joystick) Moved left
    Player: Set alt Speed X to -1.5

    Repeat while (Joystick) Moved right
    Player: Set Speed X to 1.5

    NO Repeat while (Joystick) Moved left
    NO Repeat while (Joystick) Moved right
    Player: Set Speed X to 0

    Always
    Player: Set alt Pos X to alt Pos X("Player") + alt Speed X("Player")

    Always
    Player: Set X position to alt Pos X("Player")

  3. #3
    No Products Registered

    Join Date
    Sep 2009
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with Float Point, please help

    Excellent, it works. Thank you so much Dynasoft.

    Is there a problem if I let the movement like your code? Because some people prefer to make a fast loop in Left/Right Movement to avoid problems, but I don't know if there would be any problem. Thanks

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with Float Point, please help

    Use fast loop for speed in whole numbers.
    use float points for any # speed lower than whole numbers.

  5. #5
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with Float Point, please help

    The only problem is with stopping movement on collision. If you are moving at over 1px/frame, you can end up stuck slightly in whatever you collide with. You can then use a fast loop to pull out of it if you need it perfect.

    If you go faster than your size (e.g. bullets) then you can skip over other objects altogether, which forces you to use a fast loop for the movement to get a good result.

  6. #6
    No Products Registered

    Join Date
    Sep 2009
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Problem with Float Point, please help

    Quote Originally Posted by Dynasoft
    The only problem is with stopping movement on collision. If you are moving at over 1px/frame, you can end up stuck slightly in whatever you collide with. You can then use a fast loop to pull out of it if you need it perfect.

    If you go faster than your size (e.g. bullets) then you can skip over other objects altogether, which forces you to use a fast loop for the movement to get a good result.
    Hmm yes, there is problem with that :mad: I didn't noticed because I was making just a plane foreground. So now I have to change everything in fast loops... just when I was happy for making a lot of MegaMan X engine =/

    Anybody can help me in converting a piece of code in fast loop? I can post the code if someone help me with that. Thank you so much

Similar Threads

  1. connectin point example problem
    By Darkechibi in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 8th November 2013, 03:43 PM
  2. Decimal point on counters problem
    By Ryan in forum SWF/Flash Export Module Version 2.0
    Replies: 2
    Last Post: 12th April 2012, 09:25 AM
  3. Controller: Point of view problem
    By Solgryn in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 24th February 2012, 08:44 AM
  4. [BUG / Problem ]Float-value
    By Pharanygitis in forum SWF/Flash Export Module Version 2.0
    Replies: 5
    Last Post: 17th September 2011, 08:46 PM
  5. Help! - Moving from Point A to Point B - arched.
    By Conno in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 23rd April 2008, 07:15 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
  •