Smiley Face
Author |
Message |
Andrewkiss
|
Posted: Tue Sep 22, 2009 8:11 am Post subject: Smiley Face |
|
|
Hey I need some help with turing, having trouble writing code for this.
1 Write a program called happy.t that uses a procedure called draw that draws a happy face. Allow the user to specify the centre coordinates, the radius and the color. Notice from the diagram that the eyes and mouth are positioned using the face?s radius. Use a loop in the main program to draw several different happy faces in on the screen. (Exit when the user presses any key.) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Tue Sep 22, 2009 8:33 am Post subject: RE:Smiley Face |
|
|
Well, what parts have you done so far? Have you made a Turing file (in the Turing editor) called happy.t? Have you created a procedure within it called draw()? Have you looked in the Turing help for things like Draw.Oval / Draw.FillOval?
We won't do your homework for you. Make an effort, run into a specific issue, and we can help you out with that issue. |
|
|
|
|
![](images/spacer.gif) |
Kharybdis
![](http://compsci.ca/v3/uploads/user_avatars/111642592477ec7e78e574.gif)
|
Posted: Tue Sep 22, 2009 2:13 pm Post subject: Re: Smiley Face |
|
|
Turing: |
%Khary
setscreen ("graphics")
drawfilloval (100, 100, 10, 10, black)
drawfilloval (125, 100, 10, 10, black)
drawoval (112, 75, 50, 50, black)
drawarc (112, 75, 20, 30, - 180, 360, black)
|
The above code is a hard coded illustration of a smiley face. Now all you have to do is make a function that does the same thing. |
|
|
|
|
![](images/spacer.gif) |
belarussian
|
Posted: Tue Nov 17, 2009 9:34 am Post subject: Re: Smiley Face |
|
|
I will Post the correct smiley face code soon and you will be able to change the face from happy to sad just click h or s and when you click esc you will exit is that good |
|
|
|
|
![](images/spacer.gif) |
Kharybdis
![](http://compsci.ca/v3/uploads/user_avatars/111642592477ec7e78e574.gif)
|
Posted: Tue Nov 17, 2009 5:53 pm Post subject: RE:Smiley Face |
|
|
wow. what have you been doing for the past 2 months.. this problem? |
|
|
|
|
![](images/spacer.gif) |
BigBear
|
Posted: Tue Nov 17, 2009 6:38 pm Post subject: Re: Smiley Face |
|
|
Kharybdis @ Tue Sep 22, 2009 2:13 pm wrote:
The above code is a hard coded illustration of a smiley face. Now all you have to do is make a function that does the same thing.
functions return values |
|
|
|
|
![](images/spacer.gif) |
andrew.
|
Posted: Tue Nov 17, 2009 7:00 pm Post subject: RE:Smiley Face |
|
|
So it might return the values for the coordinates for each draw command depending on what size you input or something. Or maybe they meant to make a procedure that draws it. |
|
|
|
|
![](images/spacer.gif) |
belarussian
|
Posted: Tue Nov 17, 2009 8:45 pm Post subject: Re: Smiley Face |
|
|
So here is the code and no i have done this in like 5 min and it was something i had to do for a friend so no loss there and here it is
View.Set ("graphics:500;600")
%Define Varaible
var happySad : char
var bye : char
const Title_Font := Font.New ("Arial:100:Bold")
View.Set ("graphics:500;600")
%Draw the face
Draw.FillBox (0, 0, maxx, maxy, grey)
%First Eye
Draw.FillOval (maxx div 2, maxy div 2, 175, 175, yellow)
Draw.FillOval (maxx div 2 - 75, maxy div 2 + 45, 50, 50, blue)
%Second Eye
Draw.FillOval (maxx div 2 + 75, maxy div 2 + 45, 50, 50, blue)
%Mouth
Draw.ThickLine (175, 200, 325, 200, 4, black)
loop
loop
happySad := getchar
exit when index ("hHsS", happySad) > 0 or happySad = KEY_ESC
end loop
if happySad = 'h' or happySad = 'H' then
Draw.FillOval (maxx div 2, maxy div 2, 175, 175, yellow)
Draw.FillOval (maxx div 2 - 75, maxy div 2 + 45, 50, 50, brightgreen)
Draw.FillOval (maxx div 2 + 75, maxy div 2 + 45, 50, 50, brightgreen)
Draw.Arc (maxx div 2, maxy div 2, 76, 100, 200, 340, black)
Draw.Arc (maxx div 2, maxy div 2, 75, 99, 200, 340, black)
Draw.Arc (maxx div 2, maxy div 2, 74, 98, 200, 340, black)
Draw.Arc (maxx div 2, maxy div 2, 73, 97, 200, 340, black)
elsif happySad = 's' or happySad = 'S' then
Draw.FillOval (maxx div 2, maxy div 2, 175, 175, yellow)
Draw.FillOval (maxx div 2 - 75, maxy div 2 + 45, 50, 50, black)
Draw.FillOval (maxx div 2 + 75, maxy div 2 + 45, 50, 50, black)
Draw.Arc (maxx div 2, maxy div 2 - 145, 125, 100, 40, 140, black)
Draw.Arc (maxx div 2, maxy div 2 - 145, 124, 99, 40, 140, black)
Draw.Arc (maxx div 2, maxy div 2 - 145, 123, 98, 40, 140, black)
Draw.Arc (maxx div 2, maxy div 2 - 145, 122, 97, 40, 140, black)
Draw.FillOval (maxx div 2 - 75, maxy div 2 + 45, 30, 30, red)
Draw.FillOval (maxx div 2 + 75, maxy div 2 + 45, 30, 30, red)
Draw.FillOval (maxx div 2 - 75, maxy div 2 + 45, 19, 19, brightred)
Draw.FillOval (maxx div 2 + 75, maxy div 2 + 45, 19, 19, brightred)
end if
exit when happySad = KEY_ESC
end loop
Draw.FillBox (0, 0, maxx, maxy, grey)
Draw.Text ("BYE", 85, 290, Title_Font, blue) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|
|