By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,433 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,433 IT Pros & Developers. It's quick & easy.

random

cassyhoz
P: 7
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
Nov 12 '08 #1
Share this Question
Share on Google+
6 Replies


Banfa
Expert Mod 5K+
P: 8,916
Not if you don't tell us what platform you are using.
Nov 12 '08 #2

boxfish
Expert 100+
P: 469
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?
Nov 12 '08 #3

cassyhoz
P: 7
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.
Nov 12 '08 #4

Expert 100+
P: 2,415
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.
Nov 12 '08 #5

Banfa
Expert Mod 5K+
P: 8,916
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.
Nov 12 '08 #6

cassyhoz
P: 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.
Nov 19 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.