My fraternity president wants me to design a web page for him for a drinking game idea that he has with the following javascript program. I am supposed to be designing a page that allows the user to simulate a race between two dots.
So like the page at the top will have a text box called Race Length where the user can enter the length for the race. Lower in the page will betwo text boxes, one for the red dot and one for the blue dot that show where the red dot and blue dot are location wise in the race. Lower in the page will be a button called Take A step. Each time the user clicks the button called Take a Step each dot should move forward a random amount (one, two or three). When one of the dots crosses the finish line meaning that it’s position is greater than or equal to the goal distance an alert box should appear to identify the winner. I also want the code to be able to recognize a tied race and display an appropriate message in the alert box.
Here is what I need help with:
I’ve been absent from class for 2 weeks with a very bad sinus infection so I’m really unsure on how to create a function that does this. Could anyone help me? I don’t need any help with the textboxes and buttons, just the function to make it happen. I’ve created a picture in paint just to show what I’m talking about a little easier. I appreciate any help that is given. Thanks in advance.
Here is the picture to what they layout will look like:
[URL=”http://img172.imageshack.us/img172/7623/dotracehz1.jpg”]http://img172.imageshack.us/img172/7623/dotracehz1.jpg