This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# draws a bunch of Christmas trees | |
# writen by Yuhang Wang for A2PyKids | |
import canvas | |
from math import sin, cos, pi | |
# draws a star | |
def draw_star(x, y, inner_r, outer_r, jags): | |
canvas.set_fill_color(1,1,0.2) | |
canvas.move_to(x, y + outer_r) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = 'bob is cool, really?' | |
print s | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An more interesting Pyhthonista 'Hello World' program | |
# Written by Yuhang Wang for A2PyKids | |
import console | |
import canvas | |
from random import random | |
import speech | |
# Ask for your name and then write it in random color on screen | |
canvas.set_size(1000, 600) | |
canvas.set_fill_color(random(), random(), random()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rabbit with a spining propeller | |
from scene import * | |
from random import random | |
class MyScene (Scene): | |
def setup(self): | |
# This will be called before the first frame is drawn. | |
# Set up the root layer and one other layer: | |
self.root_layer = Layer(self.bounds) | |
center = self.bounds.center() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example father's day card with animation and sound | |
import canvas | |
import speech | |
from time import sleep | |
sleepfor = 0.1 # the number of seconds to sleep for | |
canvas.set_size(1000,600) | |
canvas.draw_image('_family', 0, 0, 1000, 600) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import canvas | |
# This functions draws a filled semicircle with center at (center_x, center_y) | |
# and radius = radius | |
# Note that it actually draws 64 curve segments to approximate the semicircle | |
# You can use this function to draw the top part of a mushroom | |
def draw_filled_semicircle(center_x, center_y, radius): | |
import math | |
canvas.move_to(center_x-radius, center_y) | |
n = 64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scene import * | |
from random import random | |
class MyScene (Scene): | |
counter = 0 | |
centers = [] | |
radius = 30 | |
def setup(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scene import * | |
class MyScene (Scene): | |
rabbit_centers = [] | |
wolf_centers = [] | |
def setup(self): | |
# This will be called before the first frame is drawn. | |
pass | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scene import * | |
import math | |
from random import random | |
class MyScene (Scene): | |
circles = [] | |
max_score = 0 | |
game_began = False | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scene import * | |
import math | |
from random import random | |
class MyScene (Scene): | |
circles = [] | |
max_score = 0 | |
game_began = False | |
speed = 1 |
OlderNewer