"""
By: CodeFanDot - Fox Valley Girls Coding Club
Demonstrates Functions and Events
Demonstrates Color Names and Hex Values
Skeleton "Song" is based on the traditional spritual "Them Bones"
"""
stage.set_background("hauntedhouseinterior")
logo = codesters.Sprite("FVGCCLogo_56f", 175, 130)
logo.set_size(.2)
coding_club_name = codesters.Text("F\nV\nG\nC\nC", 220, 140)
coding_club_name.set_color("fuchsia")
# image from https://publicdomainvectors.org/tn_img/Skeleton-With-Arms-Out.png
billy_bones = codesters.Sprite("SkeletonT_f31", -130, 0)
billy_bones.set_size(.7)
# image from https://publicdomainvectors.org/tn_img/Skeleton2.png
dusty= codesters.Sprite("SkeletonStanding_cf2", 50, 0)
skeleton = codesters.Sprite("frankenstein", -30, -50)
sound = codesters.Sound("drum_clap")
#Colors are defined by assigning a value from 0 to 256 to RED, to GREEN, AND to BLUE (RGB)
#Colors can be assigned by name; each name represents a specific RGB value
#https://www.w3schools.com/colors/colors_names.asp
speech_color = "cyan" #RGB(0,255,255) No red, max green, max blue
#Color can also be assigned by Hexadecimal values, allowing even more possible hues
#https://www.w3schools.com/colors/colors_hex.asp
#Start the HEX string with the # character; followed by 3 Hex bytes
#a HEX byte hold a value from 00 to FF; 00 = 0 and FF = 255
#The first HEX byte represents RED, next 2 GREEN, last 2 BLUE
#00FF88 has 0 Red, 255 (the maximum) Green saturation, and 136 Blue
bone_color = "#00FF88"
#Define a function to recite bone name and connection
#Function Name: connect_bones
#Parameter Name:"bone" Expected Type: String
#Parameter Name: "connect" Expected Type: Boolean
#When the function is called each parameter will be
#assigned the value of the argument passed in
def connect_bones(bone, connect):
sound.play()
skeleton.say(bone.upper() + " BONE", 1, bone_color)
if connect:
skeleton.say("The " + bone.lower() + " bone's connected to the....", 1, speech_color)
skeleton.turn_left(360)
skeleton.say("Bone-jour!", 3, speech_color)
skeleton.say("Let's have fun-fun-fun-functional fun!", 3, speech_color)
# Call the function multiple times to complete the recitation
connect_bones("toe", True)
connect_bones("foot", True)
connect_bones("heel", True)
connect_bones("ankle", True)
connect_bones("shin", True)
connect_bones("knee", True)
connect_bones("thigh", True)
connect_bones("hip", True)
connect_bones("back", True)
connect_bones("shoulder", True)
connect_bones("neck", True)
connect_bones("head", False)
# Another approach to accomplish the same thing is to define
# separate functions for each bone and chain them together by
# calling each successive function from within the preceding one
#
def toe_bone():
sound.play()
skeleton.say("TOE BONE", 1, bone_color)
skeleton.say("The Toe Bone's connected to the....", 1, speech_color)
skeleton.turn_left(360)
foot_bone()
def foot_bone():
sound.play()
skeleton.say("FOOT BONE", 1, bone_color)
skeleton.say("The Foot Bone's connected to the...", 1, speech_color)
skeleton.turn_right(360)
heel_bone()
def heel_bone():
sound.play()
skeleton.say("HEEL BONE!", 1, bone_color)
skeleton.say("The Heel Bone's connected to the..", 1, speech_color)
skeleton.turn_left(360)
ankle_bone()
def ankle_bone():
sound.play()
skeleton.say("ANKLE BONE!", 1, bone_color)
skeleton.say("The Ankle Bone's connected to the...", 1, speech_color)
skeleton.turn_right(360)
shin_bone()
def shin_bone():
sound.play()
skeleton.say("SHIN BONE!", 1, bone_color)
skeleton.say("The Shin Bone's connected to the...", 1, speech_color)
skeleton.turn_left(360)
knee_bone()
def knee_bone():
sound.play()
skeleton.say("KNEE BONE!", 1, bone_color)
skeleton.say("The Knee Bone's connected to the...", 1, speech_color)
skeleton.turn_right(360)
thigh_bone()
def thigh_bone():
sound.play()
skeleton.say("THIGH BONE!", 1, bone_color)
skeleton.say("The Thigh Bone's connected to the...", 1, speech_color)
skeleton.turn_left(360)
hip_bone()
def hip_bone():
sound.play()
skeleton.say("HIP BONE!", 1, bone_color)
skeleton.say("The Hip Bone's connected to the...", 1, speech_color)
skeleton.turn_right(360)
back_bone()
def back_bone():
sound.play()
skeleton.say("BACK BONE!", 1, bone_color)
skeleton.say("The Back Bone's connected to the...", 1, speech_color)
skeleton.turn_left(360)
shoulder_bone()
def shoulder_bone():
sound.play()
skeleton.say("SHOULDER BONE!", 1, bone_color)
skeleton.say("The Shoulder Bone's connected to the...", 1, speech_color)
skeleton.turn_right(360)
neck_bone()
def neck_bone():
sound.play()
skeleton.say("NECK BONE!", 1, bone_color)
skeleton.say("The Neck Bone's connected to the...", 1, speech_color)
skeleton.turn_left(360)
head_bone()
def head_bone():
sound.play()
skeleton.set_say_color(bone_color)
skeleton.say("HEAD BONE!")
skeleton.turn_right(360)
#Start off the chain of function calls with the toe_bone()
#the other functions will be called from within functions
skeleton.say("Wicked fun!", 2, speech_color)
skeleton.say("Let's do it one more time using chained functions..", 3, speech_color)
toe_bone()
#if we want the recitation to be event-driven, is there an
# advantage to one approach over the other?
# Here we will use the chained functions but for a challenge
# think of how you might encapsulate the list of separate functions
# into something that you can call with one statement
def skeleton_click(sprite):
sprite.say("Bone-Jour!\nYou clicked me!", 3)
sprite.say("Let's kick this off again with the toe bone!", 3)
toe_bone()
skeleton.event_click(skeleton_click)