User Tag List

Results 1 to 9 of 9

Thread: Code affecting speed?

  1. #1
    No Products Registered

    Join Date
    Oct 2006
    Location
    Canada
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Code affecting speed?

    Does all the code that you put into your games affect the speed? I mean: is 100 lines of code faster than 200?

  2. #2
    No Products Registered

    Join Date
    Jul 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code affecting speed?

    it probably would somewhat.. but I don't think you'd notice it. I always make sure I have "Only One action when event loops" where only 1 action is needed, which I'm sure would speed up everything a bit. I'd say it depends alot on whether it's actually processing all 200 of those events. But again, on faster systems (as in more than 1Ghz), it'd be barely noticeable.

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)

    Join Date
    Jun 2006
    Location
    Australia
    Posts
    682
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code affecting speed?

    depends on what happens in those 100 or 200 events.. I'd guess that more would happen in 200 events...

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Francois's Avatar
    Join Date
    Jul 2006
    Location
    Montpellier, France
    Posts
    6,920
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    Re: Code affecting speed?

    200 events is really small. You can go up to 700/800 without noticable speed loss. With a good machine of course.

  5. #5
    No Products Registered

    Join Date
    Jul 2006
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code affecting speed?

    Francois, is the order of events, both in the overall list, and the ordering of conditions in a single event, important?

    For example, if I had an action like:

    If object is overlapping something
    If 1 + 1 = 3

    Would it be more efficient to reorder that event, so the 1+1=3 (ie, a less complicated check) will cause the code to not be run faster?

    IE, short circuiting

  6. #6
    Clicker Multimedia Fusion 2 Developer

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

    Re: Code affecting speed?

    As a general rule, you should put whatever is more likely to fail first, so that less conditions are run. The only exception is "true events" which don't work properly or at all unless they are the first condition in a line, "On loop" "On click" "On collision" etc.

  7. #7
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Francois's Avatar
    Join Date
    Jul 2006
    Location
    Montpellier, France
    Posts
    6,920
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    Re: Code affecting speed?

    Yes, you usually put the true events first. In build 243, true events will be printed in RED, so that you can see exactly which one is a true of fake event.
    In your example, I think that the 1+1=3 would be faster than the collision detection, depending on the number of objects. The collision detection has to go through all the objects list to find out which is colliding, and it has to explore the objects pixel by pixel when the rectangle are interconnected.

  8. #8
    Clickteam Clickteam
    Anders's Avatar
    Join Date
    Jun 2006
    Location
    Denmark, Århus
    Posts
    3,456
    Mentioned
    5 Post(s)
    Tagged
    1 Thread(s)

    Re: Code affecting speed?

    A little off topic but a question for Francois: in the collision detection, does it simply go through all pixels in the intersecting rectangles or do you optimize it by accessing semi-random pixels in the rectangle? (like every 5x5 pixel is checked first) (that way the probability that a pixel will be colliding is bigger)

  9. #9
    Clickteam Clickteam

    Join Date
    Jun 2006
    Location
    France
    Posts
    14,022
    Mentioned
    279 Post(s)
    Tagged
    3 Thread(s)

    Re: Code affecting speed?

    It goes through all pixels in the intersecting rectangles until it detects a collision, but it tests up to 32 pixels at the same time (as there is one but per pixel in the collision mask), so it's very quick.

    Yves.

Similar Threads

  1. Multitouch object affecting multiple frames
    By TheChiller in forum iOS Export Module Version 2.0
    Replies: 6
    Last Post: 17th December 2013, 03:56 PM
  2. Objects affecting other variations of the same object?
    By Ibis in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 14th June 2012, 01:05 PM
  3. Change object's graphics w/o affecting actions
    By Aloan in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 5th August 2010, 06:09 PM
  4. Affecting only a single object instance
    By CrowbarSka in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 23rd January 2010, 02:35 PM
  5. objects affecting global value
    By rhoymand in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 3rd December 2006, 09:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •