Computer Science Canada URGENT: Turing Paint Program >Stuck on color x/y cords. |
Author: | fmy [ Tue Oct 12, 2004 4:27 pm ] | ||
Post subject: | URGENT: Turing Paint Program >Stuck on color x/y cords. | ||
Hey guys, I'm new to this forum since I started my gr.11 programming class which just sticks to turing ![]() The user must change color/brush/size and I'm having trouble on the part where the use has to change the color. If anyone could help me out it would be a great help. I'm having trouble with the cords on where the button is selected. There is soemthing weird about how Turing gets it. But anyways, this is my program currently:
Thank you again. |
Author: | Cervantes [ Tue Oct 12, 2004 6:07 pm ] | ||
Post subject: | |||
fmy wrote: SO our assignment was to create a Pain Program and it's due tommorow!
looks like you'll have to go through a lot of pain tonight. Even if that was a type, that's still true ![]() well, hopefully you won't have to go through much pain. the key here is the use of whatdotcolour(x,y : int):int try this out:
|
Author: | fmy [ Wed Oct 13, 2004 1:58 pm ] | ||
Post subject: | On the brush section of the program | ||
Thank you very much Cervantes! [I love that game] yeaaa.. sorry for the typo lol! But my teacher gave our class another week to work on it! Hurray! So I finished the sizes currently on the palette and this is what i've currently come up with. I just really need help with the brushes. Im not sure how to go about it. Does anyone have any suggestions? Would be totally greatful! Well, here is what I currently have:
|
Author: | Cervantes [ Wed Oct 13, 2004 2:47 pm ] |
Post subject: | |
do basically the same thing as you did for sizes. have a variable that changes whn the user clicks on a star or circle or box or maple leaf and then use a case construct in the main loop to draw it. |
Author: | fmy [ Wed Oct 13, 2004 4:25 pm ] |
Post subject: | |
case construct? hey man, can you please help me with the rest of the program please? |
Author: | fmy [ Wed Oct 13, 2004 5:11 pm ] | ||
Post subject: | |||
Alright cervantes, I tried out that case structure but it didn't go as planned but I almost have it!! Known errors: -shape sizes can't be modifed -the circle can't be selected what am I doing wrong? what should I change?
|
Author: | wtd [ Wed Oct 13, 2004 5:37 pm ] | ||||
Post subject: | |||||
I apologize that I can't help more, but I can suggest one refactoring:
You use "x > 0 and x < maxx and y > 55 and y < maxy" repeatedly. Instead of repeating it, let's factor it out into a variable, so any changes in that code won't have to be made 4 times.
|
Author: | Cervantes [ Wed Oct 13, 2004 5:51 pm ] | ||||||
Post subject: | |||||||
good job, you got the case construct to work! The problems with your program aren't with your case construct, they are elsewhere: 1.) the resason you cannot select the circle is because the coordinates of this line are way off:
line 91. I think you are using the syntax of drawfillbox and drawfillstar and drawfillmaple leaf interchangably with drawfilloval. the line should be this:
also, you need to fix up you drawfillbox, drawfillstar, and drawfillmapleleaf lines in your case construct. You used them like you use drawfilloval: the first three don't use radii, they use x1, y1, x2, and y2. The case construct should look like this:
notice how you were repeating the same if statement inside each label? To save lines, that can be moved outside of the case construct. I hope that helps ![]() -Cervantes |
Author: | fmy [ Wed Oct 13, 2004 6:26 pm ] | ||
Post subject: | |||
Thank you guys soooo much! This helps alot! One thing though, I mean, everything works great! but, when I paint I dont want the user to be able to paint over the palette at the bottom of the program. I did that before but only with a small oval it didn't go over, not it will go over with the other sizes. How would I change this to make it so neither paint brush will go over the palette no matter what the size? Yet again, my final code! Thank you so much again! I learned alot about those case structures ![]()
|
Author: | fmy [ Wed Oct 13, 2004 6:34 pm ] |
Post subject: | |
hey cervantes, how do you get such the right cordinates for that circle? do you just guess or is there a way of doing it? |
Author: | Cervantes [ Wed Oct 13, 2004 7:21 pm ] | ||||||
Post subject: | |||||||
this line:
in the GUI brushes part at the beginning of the program told me the size of the circle, so i used that. You should incorporate your sizey variable in the following ifstatement:
I notice that you used 55, which is actually 5 pixels above the line that seperates your tools placce with your drawing board dealie. You can put it back to 50 and incorporate sizey.
that does it, but ifyou want to be really good and fix a little thing that isn't quite right: This was my fault; what you should do is take out all the div 2's in the case construct for where to draw the boxes, maple leaves, and stars. Because, when they are in there, the box has a side length of sizex (or sizey, they're the same). But, take it out, and the box has a side length of 2*sizex. The oval has a radius of sizex, so it has a diameter of 2*sizex. If you want to have your boxes and circles in the right proportions to each other, take that line out. It also serves to allow the box to be stamped all the way up to the dividing line between your tool pallette and your drawing board. hope you understood that gibberish ![]() -Cervantes |
Author: | fmy [ Wed Oct 13, 2004 8:21 pm ] |
Post subject: | |
I did! thank you very much man! youve been a great help! glad to see you live in the same neighbourhood too hehe. this program is definatly ready for presentation! class mates gonna be shocked! and Taylor, if your reading this, YOU BETTER NOT STEAL THIS! ![]() |