Connecting Tech Pros Worldwide Forums | Help | Site Map

random

cassyhoz's Avatar
Newbie
 
Join Date: Nov 2008
Posts: 7
#1: Nov 12 '08
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's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,195
#2: Nov 12 '08

re: random


Not if you don't tell us what platform you are using.
boxfish's Avatar
Expert
 
Join Date: Mar 2008
Location: California
Posts: 478
#3: Nov 12 '08

re: random


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?
cassyhoz's Avatar
Newbie
 
Join Date: Nov 2008
Posts: 7
#4: Nov 12 '08

re: random


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.
Expert
 
Join Date: Mar 2008
Location: Naperville, Illinois U.S.
Posts: 831
#5: Nov 12 '08

re: random


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.
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,195
#6: Nov 12 '08

re: random


Quote:

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.
cassyhoz's Avatar
Newbie
 
Join Date: Nov 2008
Posts: 7
#7: Nov 19 '08

re: random


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.
Reply