random

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cassyhoz
    New Member
    • Nov 2008
    • 7

    random

    can somebody explain me in plain laguage, how to make random lines crossing from top to botton of screen? it's for simulating thunders attacking a city in a game
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Not if you don't tell us what platform you are using.

    Comment

    • boxfish
      Recognized Expert Contributor
      • Mar 2008
      • 469

      #3
      I'm not quite sure exactly how these lines are supposed to go, but what I'm imagining is you pick a random place on the top of the screen and a random place on the bottom of the screen and you draw a line connecting the two. Am I right?

      Comment

      • cassyhoz
        New Member
        • Nov 2008
        • 7

        #4
        I'm sorry, the language is C.
        What I'm trying to do is that game "defender". The thunders come down from the top of the screen as straight lines, and I'm supposed to prevent them from reaching the city with a little bar.

        Should look something like this...

        ............... ............... ..............|
        ............... ............... ..............|
        ............... ............... ..............|
        ............... ............... .............\|/
        ............... ............... ............___


        CITY CITY CITY CITY CITY CITY CITY CITY CITY CITY CITY CITY CITY CITY CI




        so the thunder should be random and the speed has to increase, but what I need to know right now is how to make the thunder appear and then make it random and automatic.

        Comment

        • donbock
          Recognized Expert Top Contributor
          • Mar 2008
          • 2427

          #5
          Your example suggests that these lines are always vertical. If so, then you only need one random number corresponding to the x coordinate of the vertical line. If the lines can be slanted then as boxfish said in post #3, you need two random numbers, the x coordinates of the top and bottom points of the line.

          Comment

          • Banfa
            Recognized Expert Expert
            • Feb 2006
            • 9067

            #6
            Originally posted by cassyhoz
            I'm sorry, the language is C.
            I didn't say what language, I said what platform.

            I shall assume you are using a console app, there is no way to draw lines on a console app so what you ask can not be done.

            Comment

            • cassyhoz
              New Member
              • Nov 2008
              • 7

              #7
              Thank you donbock, a friend of mine is already helping me with the task.
              The lines are done now we only need to make them dissapear once they've het the bar.

              Comment

              Working...