944,116 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4534
  • Java RSS
Nov 4th, 2004
0

Parallel Lines Illusions: Very Tricky!!!

Expand Post »
Okay, if I could, I would shoot my CS teacher, and then shoot myself.

Reality check. Done.

Anyways, check out this yucky program right here...I don't even know where to begin...we need to create a new drawing pad; and by using two methods, we would have to create this illusion image by using only parallel lines and shaded "rectangles". Here's the link to the assignment, since I can't copy or save his files:

Click on Assignment dated 10/25/04, practice with For Loops

Username: cs2
password: 89106

I know I'm asking you guys to go through alot, but I really need help on this. This is a challenging program, and most of the older kids in my class are having BIG trouble solving this assignment...

I'm going to work on it now and see what stuff I can come up with. But please, if you got spare time, take a quick look at the program and see if you can help. Thanks ALOT!!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Eclipse is offline Offline
6 posts
since Oct 2004
Nov 8th, 2004
0

Re: Parallel Lines Illusions: Very Tricky!!!

Given the date of the assignment, I think I can assume that it's already been due so I suppose I could try and answer it.
I kind of mixed basic and c++ code structures, but I think something like this would work. The only slightly tedious part is the row's offset. It's just nested loops, nothing really tricky here.

Java Syntax (Toggle Plain Text)
  1. offset = 0
  2. flag = 0
  3. for y = 0 to 7
  4. for x = 0 to 13 step 2
  5. pen.setPosition(x*40 + offset,y*40)
  6. pen.fillRect(40,40)
  7.  
  8. pen.setPosition(0 ,(y+1)*40)
  9. pen.drawLine(0,endOfScreen)
  10. next x
  11. //determine whether to increase or decrease the offset of the row
  12. //offsets by 3 each time
  13. if flag = 0 and offset = 6
  14. {
  15. flag = 1
  16. }
  17. if flag = 1 and offset = 0
  18. {
  19. flag = 0
  20. }
  21. if flag = 0 then offset += 3
  22. if flag = 1 then offset -= 3
  23. next y

As for the circles, I don't know what its suppose to look like.
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004
Nov 8th, 2004
0

Re: Parallel Lines Illusions: Very Tricky!!!

Hmm...thanks for replying JUST in time. Luckily, this is due tomorrow, so at least I got some help for now.

I got the circles part myself...lemme see if your code works, Phaelax. and Thanks ALOT!! ^^
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Eclipse is offline Offline
6 posts
since Oct 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Borders
Next Thread in Java Forum Timeline: JBuilder Gui textArea Help!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC