All pastes #906978 Raw Edit

Untitled

public text v1 · immutable
·published 2008-02-17 03:34 UTC
rendered paste body
%The Face
%Written by Sayed Khader

%This Program Will Actively Draw A Face
%According to user-based input


%VARIABLE SECTION STARTS
%Declare Variables For Face
var centerfacex, centerfacey, faceRadiusx, faceRadiusy : int %Center of the face (x, y of oval)
centerfacex := maxx div 2
centerfacey := maxy div 2
faceRadiusx := 120
faceRadiusy := 150

%Current Face Part Being Worked on
var facePart : string

%Program Status |CHECK TO SEE IF USER WANTS TO QUIT|
var PROSTATUS : boolean
PROSTATUS := false

%Dummy Proofing Variables
var FACEPARTWORKED : boolean
FACEPARTWORKED := true
%Eye Detail Variables
var eyeShape, eyeColor, eyeSelect : string

%Nose Detail Variables
var noseShape, noseColor, noseSelect : string

%Mouth Detail Variables
var mouthShape, mouthColor, mouthSelect : string

%Memory For Face Shapes
var mouthColornum, noseColornum, eyeColornum : int
%VARIABLE SECTION ENDS

%%Prepare Base Face


%%Prompt for Eye Shape
put "Let's get a base-face together."
loop %Dummy Proof
    put "What shape would you like the eyes to be, round or wide?(This message will repeat if you enter invalid input)"
    get eyeShape
    exit when eyeShape = "round"
    exit when eyeShape = "wide"
end loop
cls
%% Prompt for Eye Color
loop
    put "Now, what eye color would you like?(This message will repeat if you enter invalid input)"
    get eyeColor
    exit when eyeColor = "red"
    exit when eyeColor = "blue"
    exit when eyeColor = "green"
    exit when eyeColor = "purple"
    exit when eyeColor = "yellow"
end loop
cls

%%Process eye-color
if eyeColor = "red"
        then
    eyeColornum := 12
elsif eyeColor = "blue"
        then
    eyeColornum := 9
elsif eyeColor = "yellow"
        then
    eyeColornum := 14
elsif eyeColor = "green"
        then
    eyeColornum := 10
elsif eyeColor = "purple"
        then
    eyeColornum := 13
end if

%% Prompt for Nose Shape

loop
    put "Now, what nose shape would you like? Round, square or triangle?(This message will repeat if you enter invalid input)"
    get noseShape
    exit when noseShape = "round"
    exit when noseShape = "triangle"
    exit when noseShape = "square"
end loop
cls

%%Prompt for Nose Color
loop
    put "Now, let's select a nose color.(This message will repeat if you enter invalid input)"
    get noseColor
    exit when noseColor = "red"
    exit when noseColor = "blue"
    exit when noseColor = "yellow"
    exit when noseColor = "purple"
    exit when noseColor = "green"
end loop
cls
%%Process Nose Colors
if noseColor = "red"
        then
    noseColornum := 12
elsif noseColor = "blue"
        then
    noseColornum := 9
elsif noseColor = "yellow"
        then
    noseColornum := 14
elsif noseColor = "green"
        then
    noseColornum := 10
elsif noseColor = "purple"
        then
    noseColornum := 13
end if

%%Prompt For Mouth Shape
loop
    put "Now, let's select a mouth shape (round or square).(This message will repeat if you enter invalid input)"
    get mouthShape
    exit when mouthShape = "round"
    exit when mouthShape = "square"
end loop

%%Prompt For Mouth Color

loop
    put "Now, let's select a color for your mouth.(This message will repeat if you enter invalid input)"
    get mouthColor
    exit when mouthColor = "red"
    exit when mouthColor = "blue"
    exit when mouthColor = "yellow"
    exit when mouthColor = "purple"
    exit when mouthColor = "green"
end loop
cls
%%Process Mouth Colors
if mouthColor = "red"
        then
    mouthColornum := 12
elsif mouthColor = "blue"
        then
    mouthColornum := 9
elsif mouthColor = "yellow"
        then
    mouthColornum := 14
elsif mouthColor = "green"
        then
    mouthColornum := 10
elsif mouthColor = "purple"
        then
    mouthColornum := 13
end if

cls
%%Let him wait for a second
put "Processing request. . ."
delay (200)

%Main Function int main(void)
loop
    exit when PROSTATUS = true
    put "Here is your base face"

    drawfilloval (centerfacex, centerfacey, faceRadiusx, faceRadiusy, 66)     %Outer Face Oval

    %Draw the eyes
    if eyeShape = "wide"
            then
        drawfilloval (275, 250, 40, 20, eyeColornum)     %Left Eye
        drawfilloval (370, 250, 40, 20, eyeColornum)     %Right Eye
    elsif eyeShape = "round"
            then
        drawfilloval (275, 250, 32, 32, eyeColornum) %Left Eye
        drawfilloval (370, 250, 32, 32, eyeColornum) %Right Eye
    end if

    %Draw The Nose

    if noseShape = "triangle"
            then
        drawline (300, 180, 340, 180, black)
        drawline (300, 180, 320, 230, black)
        drawline (340, 180, 320, 230, black)
        drawfill (310, 181, noseColornum, black)
    elsif noseShape = "square"
            then
        drawfillbox (285, 175, 350, 220, noseColornum)
    elsif noseShape = "round"
            then
        drawfilloval ((maxx div 2), (maxy div 2), 30, 30, noseColornum)
    end if

    %Draw The Mouth

    if mouthShape = "round"
            then
        drawfilloval (320, 120, 80, 20, mouthColornum)
    elsif mouthShape = "square"
            then
        drawfillbox (260, 100, 380, 150, mouthColornum)
        drawfillbox (265, 100, 275, 150, white)
        drawfillbox (290, 100, 300, 150, white)
        drawfillbox (320, 100, 330, 150, white)
        drawfillbox (340, 100, 350, 150, white)
        drawfillbox (360, 100, 370, 150, white)
    end if

    %Now Change the Face Around

    loop
        put "To add or change a part of the face, name that part. Or to Quit, type 'exit'"
        get facePart
        cls

        %Check if user wants to quit
        if facePart = "quit"
                then
            PROSTATUS := true
        else
            PROSTATUS := false
        end if
        exit when PROSTATUS = true

        %Check what User Wants to edit LOOPS DUMMY PROOF

        if facePart = "nose" %Everything about the nose
                then
            loop
                put "Would you like to change the color or the shape of your nose?(This message will repeat if you enter invalid input)"

                get noseSelect
                cls
                if noseSelect = "shape"
                        then
                    loop

                        put "Would you like the nose to be round, square, or triangle?(This message wil repeat if you enter invalid input)"
                        get noseShape
                        cls
                        exit when noseShape = "round"
                        exit when noseShape = "sqaure"
                        exit when noseShape = "triangle"
                    end loop
                elsif noseSelect = "color"
                        then
                    loop
                        put "What nose color would you like?(This message will repeat if you enter invalid input)"
                        get noseColor
                        cls
                        exit when noseColor = "red"
                        exit when noseColor = "blue"
                        exit when noseColor = "yellow"
                        exit when noseColor = "purple"
                        exit when noseColor = "green"
                    end loop
                else
                    put "I don't know that feature of the nose!"
                end if
                exit when noseSelect = "shape"
                exit when noseSelect = "color"
            end loop
            % EVERYTHING ABOUT THE EYES
        elsif facePart = "eyes"
                then
            loop %Dummy Proof
                put "Would you like to change the color or the shape of the eyes?(This message will repeat if you enter invalid input)"
                get eyeSelect
                cls
                exit when eyeSelect = "shape"
                exit when eyeSelect = "color"
            end loop
            if eyeSelect = "shape"
                    then
                    loop
                put "What eye shape would you like? wide or round?(This message will repeat if you enter invalid input)"
                get eyeShape
                cls
                exit when eyeShape = "round"
                exit when eyeShape = "wide"
                end loop
            elsif eyeSelect = "color"
                    then
                loop
                    put "What eye color would you like?(This message will repeat if you enter invalid input)"
                    get eyeColor
                    cls
                    exit when eyeColor = "red"
                    exit when eyeColor = "blue"
                    exit when eyeColor = "green"
                    exit when eyeColor = "purple"
                    exit when eyeColor = "yellow"
                end loop
            else
                put "I don't know that feature of the eyes!"
            end if

            %EVERYTHING about the mouth
        elsif
                facePart = "mouth"
                then
            loop
                put "Would you like to change the color or the shape of your mouth?(This message will repeat if you enter invalid input)"
                get mouthSelect
                cls
                exit when mouthSelect = "shape"
                exit when mouthSelect = "color"
            end loop
            if mouthSelect = "shape"
                    then
                loop
                    put "What mouth shape would you like? Round, or wide?(This message will repeat if you enter invalid input)"
                    get mouthShape
                    cls
                    exit when mouthShape = "wide"
                    exit when mouthShape = "round"
                end loop
            elsif mouthSelect = "color"
                    then
                loop
                    put "What mouth color would you like?"
                    get mouthColor
                    cls
                    exit when mouthColor = "red"
                    exit when mouthColor = "blue"
                    exit when mouthColor = "yellow"
                    exit when mouthColor = "purple"
                    exit when mouthColor = "green"
                end loop
            else
                put "I don't know that feature of the mouth!"
            end if


        elsif facePart = "exit"
                then
            quit

        else
            put "I don't know that face part, please enter a different one or check your spelling"
            FACEPARTWORKED := false
        end if

        exit when facePart = "quit"


        %DECODE COLORS
        %%Process Mouth Colors
        if mouthColor = "red"
                then
            mouthColornum := 12
        elsif mouthColor = "blue"
                then
            mouthColornum := 9
        elsif mouthColor = "yellow"
                then
            mouthColornum := 14
        elsif mouthColor = "green"
                then
            mouthColornum := 10
        elsif mouthColor = "purple"
                then
            mouthColornum := 13
        end if

        %%Process Nose Colors
        if noseColor = "red"
                then
            noseColornum := 12
        elsif noseColor = "blue"
                then
            noseColornum := 9
        elsif noseColor = "yellow"
                then
            noseColornum := 14
        elsif noseColor = "green"
                then
            noseColornum := 10
        elsif noseColor = "purple"
                then
            noseColornum := 13
        end if

        %%Process eye-color
        if eyeColor = "red"
                then
            eyeColornum := 12
        elsif eyeColor = "blue"
                then
            eyeColornum := 9
        elsif eyeColor = "yellow"
                then
            eyeColornum := 14
        elsif eyeColor = "green"
                then
            eyeColornum := 10
        elsif eyeColor = "purple"
                then
            eyeColornum := 13
        end if
        exit when FACEPARTWORKED = true

    end loop



end loop
cls

%Show the face for a final time
put "Here is your final face... Ew.."
drawfilloval (centerfacex, centerfacey, faceRadiusx, faceRadiusy, 66)         %Outer Face Oval

%Draw the eyes
if eyeShape = "wide"
        then
    drawfilloval (275, 250, 40, 20, eyeColornum)         %Left Eye
    drawfilloval (370, 250, 40, 20, eyeColornum)         %Right Eye
elsif eyeShape = "round"
        then
    drawfilloval (275, 250, 32, 32, eyeColornum)     %Left Eye
    drawfilloval (370, 250, 32, 32, eyeColornum)     %Right Eye
end if

%Draw The Nose

if noseShape = "triangle"
        then
    drawline (300, 180, 340, 180, black)
    drawline (300, 180, 320, 230, black)
    drawline (340, 180, 320, 230, black)
    drawfill (310, 181, noseColornum, black)
elsif noseShape = "square"
        then
    drawfillbox (285, 175, 350, 220, noseColornum)
elsif noseShape = "round"
        then
    drawfilloval (centerfacex, centerfacey, 30, 30, noseColornum)
end if

%Draw The Mouth

if mouthShape = "round"
        then
    drawfilloval (320, 120, 80, 20, mouthColornum)
elsif mouthShape = "square"
        then
    drawfillbox (260, 100, 380, 150, mouthColornum)
    drawfillbox (265, 100, 275, 150, white)
    drawfillbox (290, 100, 300, 150, white)
    drawfillbox (320, 100, 330, 150, white)
    drawfillbox (340, 100, 350, 150, white)
    drawfillbox (360, 100, 370, 150, white)
end if



%Animate a little bit