New Posts  All Forums:Forum Nav:

Intro Java help

post #1 of 2
Thread Starter 
Who is good at java?
I am on my second program assignment for this class and don't even know where to begin on drawing this damn thing.
I am given:
http://pastebin.com/wCg1Vpn3
and
http://pastebin.com/h1xLeKkp
and this is my instructions:
http://pastebin.com/vEWjxsSK
and the example execution:
http://tinypic.com/r/20gbrkn/5

I know that I am supposed to use loops but how am I supposed to draw this damn thing?
I would rather you not do it for me but just point me in the right direction or a tutorial?

Thank you all so much
post #2 of 2
Quote:
Originally Posted by Jwright0291 View Post

Who is good at java?
I am on my second program assignment for this class and don't even know where to begin on drawing this damn thing.
I am given:
http://pastebin.com/wCg1Vpn3
and
http://pastebin.com/h1xLeKkp
and this is my instructions:
http://pastebin.com/vEWjxsSK
and the example execution:
http://tinypic.com/r/20gbrkn/5

I know that I am supposed to use loops but how am I supposed to draw this damn thing?
I would rather you not do it for me but just point me in the right direction or a tutorial?

Thank you all so much

Imagine that you erase all of each line except for the point that intersects with the border of your drawing area. Now you have a dotted square, so to speak. The dots are all evenly spaced around the perimeter of the square. To draw the tunnel, all you need to do is draw a line from the randomly-chosen coordinates to each perimeter point.


You need to compute the coordinates for each of those dots. You can use two loops to do this. Assuming the perimeter points are 20 pixels apart, code would look something like:
Code:
// Draw lines towards the top and bottom
for (int x = 0; x < width; x += 20) {
  drawLine(randX, randY, x, 0);
  drawLine(randX, randY, x, height);
}

// Draw lines towards the left and right
for (int y = 0; y < height; y += 20) {
  drawLine(randX, randY, 0, y);
  drawLine(randX, randY, width, y);
}

This code assumes the existence of a drawLine function. I think that if you search the documentation for the Java 2D API, a similar function is provided.
Cube
(9 items)
 
  
CPUMotherboardRAMHard Drive
i7-4930k EVGA X79 Dark Corsair Vengeance Pro Samsung 840 Pro 
CoolingMonitorPowerCase
Corsair H100i Viewsonic VP2770 EVGA SuperNova 1000P2 Corsair Air 540 
Mouse
Corsair M65 
  hide details  
Reply
Cube
(9 items)
 
  
CPUMotherboardRAMHard Drive
i7-4930k EVGA X79 Dark Corsair Vengeance Pro Samsung 840 Pro 
CoolingMonitorPowerCase
Corsair H100i Viewsonic VP2770 EVGA SuperNova 1000P2 Corsair Air 540 
Mouse
Corsair M65 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming