Help creating randomly falling sprites with lingo

Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default Re: Help creating randomly falling sprites with lingo

    Attach the following behavior to each sprite that's to fall. Adjust the
    pSpeed parameter to make the objects fall faster or slower. Adjust the
    pInterval to determine how long an object waits at the top of the screen
    before it starts falling. The setting of the locH is restricted to the width
    of the stage so you might want to change that in the two places it's done if
    you want the objects falling within a certain range of the stage other than
    the whole stage.

    property pS, spriteNum, pInterval, pStartPause, pMode, pSpeed

    on beginSprite me
    pS = sprite (spriteNum)
    pInterval = random (3) -- seconds
    pStartPause = the ticks
    pMode = #wait
    pSpeed = random (20) + 5
    pS.locV = - pS.height
    pS.locH = random (the stageRight - the stageLeft)
    end

    on exitFrame me
    case pMode of
    #wait:
    if the ticks > pStartPause + pInterval * 60 then
    pMode = #falling
    end if
    #falling:
    if pS.top < the stageBottom then
    pS.locV = pS.locV + pSpeed
    else
    pMode = #reset
    end if
    #reset:
    pS.locV = - pS.height
    pS.locH = random (the stageRight - the stageLeft)
    pMode = #wait
    pStartPause = the ticks
    end case
    end


    --
    Craig Wollman
    Word of Mouth Productions
    phone 212 724 8302
    fax 212 724 8151
    [url]www.wordofmouthpros.com[/url]
    "Opyuse" <webforumsuser@macromedia.com> wrote in message
    news:bh59af$njg$1@forums.macromedia.com...
    > I have to make a game with randomly falling sprites but I can't work out
    the lingo to get this to happen.
    >
    > Any help you can give will be great?
    >
    > Thank you
    >
    >
    >

    Word of Mouth Productions Guest

  2. Similar Questions and Discussions

    1. lingo to put sprites on stage
      what is the lingo syntax to put a sprite on stage other than using OOP methods??
    2. Need a way to control de rotation (angle) of sprites through Lingo
      I'm setting up a system made of wheels which have to rotate at variable speeds. I'm planning to control this using the angle of the sprite, but...
    3. Using lingo to resize sprites
      I have a cast of 52 cards (it is sprites of a deck of cards). I was wondering if there was a way that on preparemovie or on beginsprite I could use...
    4. Using Lingo to stop sprites from scrolling at a certain point.
      Hi All, I have a project I'm working on. Basically, I have 10 sprites that move horizontally left or right when moused over. The problem I have...
    5. More Help needed with the randomly falling sprites
      Eariler I asked for help with randomly falling sprites and I was given the code below. However now I'm getting the following error message when I...
  3. #2

    Default Re: Help creating randomly falling sprites with lingo

    Thanks alot thats great


    Opyuse webforumsuser@macromedia.com Guest

  4. #3

    Default Re: Help creating randomly falling sprites with lingo

    Sorry about this but when I entered the code you gave this error message appeared

    Variable used before assigned a value
    case pMode of?

    How do I get rid of this error?


    Opyuse webforumsuser@macromedia.com Guest

  5. #4

    Default Re: Help creating randomly falling sprites with lingo

    On 10 Aug 2003, "Opyuse" [email]webforumsuser@macromedia.com[/email] wrote:
    > Variable used before assigned a value
    > case pMode of?
    >
    > How do I get rid of this error?
    You forgot the line of code that declares the property variables. Put this
    at the top of the script (outside of any handlers)

    property pS, spriteNum, pInterval, pStartPause, pMode, pSpeed



    --
    Mark A. Boyd
    Keep-On-Learnin' :)
    Mark A. Boyd Guest

  6. #5

    Default Re: Help creating randomly falling sprites with lingo

    Thanks Mark

    --
    Craig Wollman
    Word of Mouth Productions
    phone 212 724 8302
    fax 212 724 8151
    [url]www.wordofmouthpros.com[/url]
    "Mark A. Boyd" <mblists@sanDotrr.com> wrote in message
    news:Xns93D367CFACE5FmblistssanDotrrcom@65.57.83.2 09...
    > On 10 Aug 2003, "Opyuse" [email]webforumsuser@macromedia.com[/email] wrote:
    >
    > > Variable used before assigned a value
    > > case pMode of?
    > >
    > > How do I get rid of this error?
    >
    > You forgot the line of code that declares the property variables. Put this
    > at the top of the script (outside of any handlers)
    >
    > property pS, spriteNum, pInterval, pStartPause, pMode, pSpeed
    >
    >
    >
    > --
    > Mark A. Boyd
    > Keep-On-Learnin' :)

    Word of Mouth Productions Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139