Example #1
0
    def __init__(self):
        Screen.registerturtle(self)
        self.currentcolor = self.black
        self.currentthinline = self.thinlineblack
        width = Screen.width
        height = Screen.height
        screencenter = (width / 2, height / 2
                        )  #finds a tuple for the center of the screen
        #self.newturtle(self.currentcolor, self.currentthinline)
        startturtle = PolygonAsset([(5, 5), (20, 13), (5, 21), (10, 13),
                                    (5, 5)], self.currentthinline,
                                   self.currentcolor)
        self.turtle = Sprite(startturtle, screencenter)
        self.rotationgoal = None
        self.forwardgoal = None
        self.bkgoal = None

        self.vr = 0
        self.turtle.fxcenter = 1
        self.turtle.fycenter = 1 / 2

        self.vx = 0
        self.vy = 0

        self.commandlist = []
        self.currentcmd = None

        self.distance = 0

        self.combinedhead = 0

        self.fdx = width / 2
        self.fdy = height / 2
Example #2
0
 def _buildAsset(self):
     pcenter = self.spposinputs.pos
     try:
         pradius = MathApp.distance(
             self.posinputs.pos(),
             self.nposinputs.radius()) * MathApp._scale
     except AttributeError:
         pradius = self.nposinputs.radius() * MathApp._scale
     style = self.stdinputs.style()
     fill = self.stdinputs.color()
     ymax = pcenter[1] + pradius
     ymin = pcenter[1] - pradius
     xmax = pcenter[0] + pradius
     xmin = pcenter[0] - pradius
     try:
         if ymin > MathApp.height or ymax < 0 or xmax < 0 or xmin > MathApp.width:
             return CircleAsset(pradius, style, fill)
         elif pradius > 2 * MathApp.width:
             # here begins unpleasant hack to overcome crappy circles
             poly = self._buildPolygon(pcenter, pradius)
             if len(poly):
                 passet = PolygonAsset(poly, style, fill)
                 return passet
     except AttributeError:
         return CircleAsset(pradius, style, fill)
     return CircleAsset(pradius, style, fill)
Example #3
0
 def __init__(self, arg):
     super().__init__(arg)
     self.image = ImageAsset("bunny.png")
     self.rocket = ImageAsset("ggimages/rocket.png")
     self.multiimage = ImageAsset("bunny.png", Frame(2, 2, 10, 14), 3,
                                  'horizontal', 2)
     color = 0x001122
     alpha = 0.5
     self.c = Color(color, alpha)
     pixels = 9
     self.l = LineStyle(pixels, color)
     self.rect = RectangleAsset(10, 20, LineStyle(3, Color(0x112233, 0.5)),
                                Color(0x223344, 0.6))
     self.circ = CircleAsset(30, LineStyle(3, Color(0x112233, 0.5)),
                             Color(0x223344, 0.6))
     self.ellipse = EllipseAsset(40, 50, LineStyle(4, Color(0x113355, 0.6)),
                                 Color(0x224466, 0.7))
     self.line = LineAsset(60, 70, LineStyle(5, Color(0x224466, 0.7)))
     self.poly = PolygonAsset([(10, 10), (20, 10), (15, 15), (10, 10)],
                              LineStyle(6, Color(0x665544, 0.9)),
                              Color(0x664422, 1.0))
     self.text = TextAsset("sample text",
                           style="20px Arial",
                           width=200,
                           fill=Color(0x123456, 1.0),
                           align='center')
Example #4
0
    def __init__(self, position):
        self.x1 = 30 + random.randint(-10, 10)
        self.y1 = 0 + random.randint(-10, 10)
        self.x2 = 60 + random.randint(-10, 10)
        self.y2 = 0 + random.randint(-10, 10)
        self.x3 = 90 + random.randint(-10, 10)
        self.y3 = 30 + random.randint(-10, 10)
        self.x4 = 90 + random.randint(-10, 10)
        self.y4 = 60 + random.randint(-10, 10)
        self.x5 = 60 + random.randint(-10, 10)
        self.y5 = 90 + random.randint(-10, 10)
        self.x6 = 30 + random.randint(-10, 10)
        self.y6 = 90 + random.randint(-10, 10)
        self.x7 = 0 + random.randint(-10, 10)
        self.y7 = 60 + random.randint(-10, 10)
        self.x8 = 0 + random.randint(-10, 10)
        self.y8 = 30 + random.randint(-10, 10)
        self.points = [(self.x1, self.y1), (self.x2, self.y2),
                       (self.x3, self.y3), (self.x4, self.y4),
                       (self.x5, self.y5), (self.x6, self.y6),
                       (self.x7, self.y7), (self.x8, self.y8)]
        self.poly = PolygonAsset(self.points, noline, black)

        super().__init__(self.poly, position, CircleAsset(45))
        self.speed = 1
        self.rotation = random.random() * 2 * math.pi
        self.vx = self.speed * math.sin(self.rotation)
        self.vy = self.speed * math.cos(self.rotation)
        self.vr = 0.02 * random.random()
        self.fxcenter = self.fycenter = 0.5
Example #5
0
    def __init__(self, position):
        self.x1 = 7.5 + random.randint(-3, 3)
        self.y1 = 0 + random.randint(-3, 3)
        self.x2 = 15 + random.randint(-3, 3)
        self.y2 = 0 + random.randint(-3, 3)
        self.x3 = 22.5 + random.randint(-3, 3)
        self.y3 = 7.5 + random.randint(-3, 3)
        self.x4 = 22.5 + random.randint(-3, 3)
        self.y4 = 15 + random.randint(-3, 3)
        self.x5 = 15 + random.randint(-3, 3)
        self.y5 = 22.5 + random.randint(-3, 3)
        self.x6 = 7.5 + random.randint(-3, 3)
        self.y6 = 22.5 + random.randint(-3, 3)
        self.x7 = 0 + random.randint(-3, 3)
        self.y7 = 15 + random.randint(-3, 3)
        self.x8 = 0 + random.randint(-3, 3)
        self.y8 = 7.5 + random.randint(-3, 3)
        self.points = [(self.x1, self.y1), (self.x2, self.y2),
                       (self.x3, self.y3), (self.x4, self.y4),
                       (self.x5, self.y5), (self.x6, self.y6),
                       (self.x7, self.y7), (self.x8, self.y8)]
        self.poly = PolygonAsset(self.points, noline, black)

        super().__init__(self.poly, position, CircleAsset(11.25))

        self.speed = 3
        self.rotation = random.random() * 2 * math.pi
        self.vx = self.speed * math.sin(self.rotation)
        self.vy = self.speed * math.cos(self.rotation)
        self.vr = 0.04 * random.random()
        self.fxcenter = self.fycenter = 0.5
Example #6
0
 def test_polygonasset(self):
     p = PolygonAsset(
         [(10, 10), (20, 10), (15, 15), (10, 10)],
         LineStyle(6, Color(0x665544, 0.9)),
         Color(0x664422, 1.0),
     )
     self.assertEqual(len(p.gfx.jpath), 8)
     self.assertEqual(p.gfx.jpath[4], 15)
     self.assertEqual(p.gfx.visible, False)
class Lander(Sprite):
    ship = PolygonAsset([(0,15), (7.5,0), (15,15), (7.5,7.5)], noline, black)
    
    def __init__(self, position):
        self.radius = 7
        super().__init__(Lander.ship, position, CircleAsset(self.radius))
        self.vx = 0
        self.vy = 0
        self.gravity = 0.01
        self.wind = 0
        self.thrust = 0.05
        self.vr = 0.1
        self.rotation = 0
        self.paused = True
        self.fxcenter = self.fycenter = 0.5
        self.speed = 0
        self.speedlimit = 0.75
        self.landed = False
        self.crashed = False
        self.thrusting = False
        
        MarsLanderGame.listenKeyEvent("keydown", "up arrow", self.thrustOn)
        MarsLanderGame.listenKeyEvent("keyup", "up arrow", self.thrustOff)
        MarsLanderGame.listenKeyEvent("keydown", "right arrow", self.rotateRight)
        MarsLanderGame.listenKeyEvent("keydown", "left arrow", self.rotateLeft)
        MarsLanderGame.listenKeyEvent("keydown", "space", self.togglePause)
        
    def thrustOn(self, event):
        self.thrusting = True
        
    def thrustOff(self, event):
        self.thrusting = False
        
    def rotateRight(self, event):
        if self.paused == False:
            self.rotation -= self.vr
        
    def rotateLeft(self, event):
        if self.paused == False:
            self.rotation += self.vr
        
    def togglePause(self, event):
        self.paused = not self.paused
        
    def step(self):
        if self.paused == False and self.landed == False and self.crashed == False:
            if self.thrusting:
                self.vx += -self.thrust * math.sin(self.rotation)
                self.vy += -self.thrust * math.cos(self.rotation)
            self.x += self.vx
            self.y += self.vy
            self.vy += self.gravity
            self.vx += self.wind * 0.001
            self.speed = (self.vx ** 2 + self.vy ** 2) ** 0.5
Example #8
0
 def __init__(self, x, y, vx, vy, radius):
     self.vx = vx
     self.vy = vy
     self.radius = radius + 1
     self.count = 0
     self.poly = [None] * int(self.radius * 3 / 4)
     for x in range(0,int(self.radius * 3 / 4)):
         self.poly[x] = PolygonAsset([(0,0), (self.radius, self.radius * 3 / 4 - x), (self.radius, -self.radius * 3 / 4 - x)], noline, black)
     super().__init__(self.poly[0], (x, y))
     self.rotation = 0
     self.fycenter = 0.5
Example #9
0
class ShipPiece(Sprite):
    tri = PolygonAsset([(7.5,0), (15,0), (0,15)], noline, black)
    
    def __init__(self, position, vx, vy):
        super().__init__(shipPiece.tri, position)
        self.vx = vx * random.random()
        self.vy = vy * random.random()
        self.vr = random.random() * 0.25
        self.rotation = 2 * math.pi * random.random()
        
    def step(self):
        self.x += self.vx
        self.y += self.vy
        self.rotation += self.vr
Example #10
0
 def newturtle(self, color, line):
     if self.turtle:
         x = self.turtle.x
         y = self.turtle.y
         r = self.turtle.rotation
         self.turtle.destroy()
     else:
         x = self.turtle.x
         y = self.turtle.y
         r = self.turtle.rotation
         startturtle = PolygonAsset([(5, 5), (20, 13), (5, 21), (10, 13),
                                     (5, 5)], self.currentthinline,
                                    self.currentcolor)
         self.turtle = Sprite(startturtle, screencenter)
         self.turtle.x = x
     self.turtle.fxcenter = 1
     self.turtle.fycenter = 1 / 2
Example #11
0
    def __init__(self, position, size):
        self.size = size
        self.xcoordinates = [30, 60, 90, 90, 60, 30, 0, 0]
        self.ycoordinates = [0, 0, 30, 60, 90, 90, 60, 30]
        self.range = 12
        self.radius = 50
        self.points = [None] * 8
        self.speed = 1
        if size == "big":
            self.xcoordinates = [x + random.randint(-self.range, self.range) for x in self.xcoordinates]
            self.ycoordinates = [y + random.randint(-self.range, self.range) for y in self.ycoordinates]
        elif size == "medium":
            self.speed = 2
            self.range = int(self.range / 2)
            self.radius = self.radius / 2
            self.xcoordinates = [x / 2 + random.randint(-self.range, self.range) for x in self.xcoordinates]
            self.ycoordinates = [y / 2 + random.randint(-self.range, self.range) for y in self.ycoordinates]
        else:
            self.speed = 3
            self.range = int(self.range / 2)
            self.radius = self.radius / 4
            self.xcoordinates = [x / 4 + random.randint(-self.range, self.range) for x in self.xcoordinates]
            self.ycoordinates = [y / 4 + random.randint(-self.range, self.range) for y in self.ycoordinates]
            
        for z in range(0,8):
            self.points[z] = (self.xcoordinates[z], self.ycoordinates[z])

        self.poly = PolygonAsset(self.points, noline, black)
        
        super().__init__(self.poly, position, CircleAsset(self.radius))
        

        self.rotation = random.random() * 2 * math.pi
        self.vx = self.speed * math.sin(self.rotation)
        self.vy = self.speed * math.cos(self.rotation)
        self.vr = 0.02 * random.random()
        self.fxcenter = self.fycenter = 0.5
Example #12
0
white = Color(0xFFFFFF, 1.0)
yellow = Color(0xFCE604, 1.0)

thinline = LineStyle(1, grey)
thinline1 = LineStyle(1, brown)
thinline2 = LineStyle(1, black1)
thinline3 = LineStyle(1, green)
thinline4 = LineStyle(1, darkorange)
thinline5 = LineStyle(1, darkorange1)
thinline6 = LineStyle(1, black2)
thinline7 = LineStyle(1, green1)

tank = RectangleAsset(900, 600, thinline2, lightblue)
pebbles = RectangleAsset(900, 45, thinline2, tan)
castle = RectangleAsset(350, 190, thinline, grey)
castletop = PolygonAsset([(40, 60), (80, -45), (120, 60)], thinline, red)
castletop1 = PolygonAsset([(40, 60), (62.5, -30), (85, 60)], thinline, red)
centertower = RectangleAsset(150, 140, thinline, grey)
centertower1 = RectangleAsset(45, 50, thinline, grey)
tower = RectangleAsset(80, 100, thinline, grey)
ridge = RectangleAsset(10, 25, thinline, lightblue)
ridge1 = RectangleAsset(8, 20, thinline, lightblue)
windows = RectangleAsset(130, 130, thinline, brown)
windows1 = RectangleAsset(40, 50, thinline, black)
windows2 = EllipseAsset(63, 80, thinline1, brown)
windows3 = RectangleAsset(20, 30, thinline1, black)
line = PolygonAsset([(40, 60), (40, -105), (40, 60)], thinline2, black)
doorknob = EllipseAsset(8, 8, thinline1, black)
plant = RectangleAsset(10, 250, thinline7, green)
plant1 = RectangleAsset(5, 110, thinline7, green)
leaves = EllipseAsset(8, 20, thinline7, green)
Example #13
0
See:
http://brythonserver.github.io/ggame/
for detailed information on ggame.

"""
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

# add your code here \/  \/  \/
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)

line = LineStyle(3, black)
triangle = PolygonAsset([(0, 0), (300, -400), (600, 0)], line, green)
Sprite(triangle, (100, 50))
longtriangle = PolygonAsset([(0, 0), (400, -350), (800, 0)], line, green)
Sprite(longtriangle, (250, 100))
bigtriangle = PolygonAsset([(0, 0), (275, -300), (750, 0)], line, green)
Sprite(bigtriangle, (250, 150))
hugetriangle = bigtriangle = PolygonAsset([(0, 0), (500, -500), (900, 0)],
                                          line, green)
Sprite(hugetriangle, (450, -50))
bigtriangle = PolygonAsset([(0, 0), (275, -300), (750, 0)], line, green)
Sprite(bigtriangle, (-150, 150))
sun = CircleAsset((200, 200), line, red)
Sprite(sun, (200, 200))

myapp = App()
myapp.run()
Example #14
0
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

# add your code here \/  \/  \/
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
gray = Color(0x000000, 0.3)
white = Color(0xffffff, 1.0)
yellow = Color(192 - 275 - 170, 1.0)
orange = Color(0xffbc53, 1.0)

thinline = LineStyle(1, black)
door = RectangleAsset(90, 170, thinline, yellow)
walls = RectangleAsset(300, 300, thinline, blue)
roof = PolygonAsset([(370, 200), (730, 200), (550, 50)], thinline, black)
bottom = CircleAsset(110, thinline, white)
mid = CircleAsset(90, thinline, white)
top = CircleAsset(70, thinline, white)
nose = PolygonAsset([(1000, 240), (1010, 210), (990, 210)], thinline, orange)
eye = CircleAsset(10, thinline, black)
shad = EllipseAsset(100, 50, thinline, gray)

Sprite(walls, (400, 200))
Sprite(door, (500, 330))
Sprite(roof)
Sprite(bottom, (1000, 530))
Sprite(mid, (1000, 350))
Sprite(top, (1000, 200))
Sprite(nose)
Sprite(eye, (980, 190))
Example #15
0
from ggame import App, Color, LineStyle, Sprite
from ggame import RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

red = Color(0xff0000, 0.5)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)

thinline = LineStyle(1, black)
rectangle = RectangleAsset(50, 20, thinline, blue)
ellipse = EllipseAsset(50, 30, thinline, blue)
polygon = PolygonAsset([(250, 70), (250, 130), (350, 130), (350, 70)],
                       thinline, red)

Sprite(rectangle)
Sprite(rectangle, (200, 50))
Sprite(rectangle, (225, 50))
Sprite(ellipse, (300, 100))
Sprite(polygon)

myapp = App()
myapp.run()
Example #16
0
sky = RectangleAsset(1500, 1000, line0, blue)
Sprite(sky)

grass = RectangleAsset(1500, 500, line1, green)
Sprite(grass, (0, 300))

house = RectangleAsset(200, 200, line1, red)
Sprite(house, (400, 200))

windowsky = RectangleAsset(80, 80, line1, white)
Sprite(windowsky, (420, 250))

window = RectangleAsset(80, 80, line1, blue)
Sprite(window, (420, 250))

roof = PolygonAsset([(0, 0), (100, -150), (200, 0)], line1, green)
Sprite(roof, (400, 50))

circlesky = CircleAsset(20, line1, white)
Sprite(circlesky, (480, 150))

circle = CircleAsset(20, line1, blue)
Sprite(circle, (480, 150))

trunk = RectangleAsset(30, 80, line1, red)
Sprite(trunk, (835, 350))

tree = EllipseAsset(50, 100, line1, green)
Sprite(tree, (800, 200))

trunk2 = RectangleAsset(30, 80, line1, red)
Example #17
0
pupil1 = CircleAsset(8, thinline, eyes)
Sprite(pupil1, (148, 138))

pupil1 = CircleAsset(8, thinline, eyes)
Sprite(pupil1, (98, 138))

pupil2 = CircleAsset(3, thinline, black)
Sprite(pupil2, (103, 143))

pupil2 = CircleAsset(3, thinline, black)
Sprite(pupil2, (153, 143))

mouth = CircleAsset(13, thinline, black)
Sprite(mouth, (119, 190))

nose = PolygonAsset([(24, 12), (24, 30), (50, 30)], thinline, face)
Sprite(nose, (122, 160))

hair = RectangleAsset(100, 25, thinline, pink)
Sprite(hair, (78, 80))

hair = RectangleAsset(75, 25, thinline, pink)
Sprite(hair, (90, 56))

hair = RectangleAsset(50, 25, thinline, pink)
Sprite(hair, (102, 32))
# add your code here /\  /\  /\

myapp = App()
myapp.run()
Example #18
0
from ggame import App, Color, LineStyle, Sprite
from ggame import RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

# Three primary colors with no transparency (alpha = 1.0)
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)

# Define a line style that is a thin (1 pixel) wide black line
thinline = LineStyle(1, black)
# A graphics asset that represents a rectangle
rectangle = EllipseAsset(50, 20, thinline, blue)
rectangle1 = PolygonAsset([(100,50), (100,200), (346,47),(54,56)], thinline, red)
# Now display a rectangle
Sprite(rectangle)
Sprite(rectangle1)

myapp = App()
myapp.run()
Example #19
0
purple = Color(0xA040FF, 1.0)
dblue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)

thickline = LineStyle(5, purple)
thinline = LineStyle(2.5, black)
noline = LineStyle(1, dblue)
redline = LineStyle(2, red)
pline = LineStyle(2, purple)
ellipse1 = EllipseAsset(250, 300, thickline, dblue)
ellipse2 = EllipseAsset(50, 70, thinline, green)
circle1 = CircleAsset(50, thinline, red)
circle2 = CircleAsset(50, thinline, purple)
grin1 = CircleAsset(30, thinline, green)
grin2 = CircleAsset(30, noline, dblue)
smile = PolygonAsset([(0, 75), (125, 30), (0, 50), (-125, 30)], thickline,
                     purple)
eb = RectangleAsset(150, 30, thickline, red)
eb2 = RectangleAsset(140, 30, thickline, green)
prunelle = CircleAsset(25, pline, black)
pupil = CircleAsset(26, redline, black)

Sprite(ellipse1, (800, 400))
Sprite(ellipse2, (800, 400))
Sprite(circle1, (700, 350))
Sprite(circle2, (900, 350))
Sprite(grin1, (950, 530))
Sprite(grin2, (940, 530))
Sprite(smile, (805, 500))
Sprite(eb, (620, 250))
Sprite(eb2, (820, 250))
Sprite(prunelle, (700, 350))
Example #20
0
# add your code here \/  \/  \/

#colors
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
#yellow = Color(0Xffff00, 1.0)

#line style
thinline = LineStyle(1, black)

rectangle = RectangleAsset(500, 600, thinline, blue)
circle = CircleAsset(50, thinline, red)
ellipse = EllipseAsset(60, 100, thinline, red)
triangle = PolygonAsset([(50, 50), (100, 200), (0, 80)], thinline, green)
rectangle2 = RectangleAsset(100, 100, thinline, blue)
circle2 = CircleAsset(250, thinline, black)
rectangle3 = RectangleAsset(50, 600, thinline, red)
ellipse2 = EllipseAsset(300, 100, thinline, green)
triangle2 = PolygonAsset([(50, 50), (100, 200), (500, 80)], thinline, red)
triangle3 = PolygonAsset([(89, 500), (300, 200), (0, 80)], thinline, blue)
triangle4 = PolygonAsset([(300, 100), (100, 260), (0, 80)], thinline, green)

#display the shapes
Sprite(rectangle, (600, 50))
Sprite(circle2, (900, 150))
Sprite(circle, (900, 150))
Sprite(ellipse, (400, 400))
Sprite(triangle, (500, 600))
Sprite(rectangle2, (200, 50))
Example #21
0
Sprite(rectangle2, (0, 400))

#grass night
rectangle5 = RectangleAsset(460, 350, thinline, darkgreen)
Sprite(rectangle5, (475, 400))

#door
rectangle3 = RectangleAsset(100, 100, thinline, red)
Sprite(rectangle3, (400, 300))

#doorknob
ellipse = EllipseAsset(5, 10, thinline, blue)
Sprite(ellipse, (425, 350))

#roof
triangle = PolygonAsset([(1, 100), (200, 1), (400, 100)], thinline, black)
Sprite(triangle, (275, 75))

#sun
circle = CircleAsset(50, thinline, yellow)
Sprite(circle, (0, 0))

#moonwhite
circle2 = CircleAsset(50, thinline, white)
Sprite(circle2, (800, 0))

#moondarkblue
circle3 = CircleAsset(40, thinline2, darkblue)
Sprite(circle3, (800, 0))

myapp = App()
Example #22
0
from ggame import App, Color, LineStyle, Sprite
from ggame import RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

# Three primary colors with no transparency (alpha = 1.0)
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)

# Define a line style that is a thin (1 pixel) wide black line
thinline = LineStyle(1, black)

ellipse = EllipseAsset(30, 20, thinline, blue)
polygon = PolygonAsset([(0, 0), (60, 0), (80, 50), (0, 40), (0, 0)], thinline,
                       red)

Sprite(polygon, (80, 30))
Sprite(ellipse, (80, 30))

# A graphics asset that represents a rectangle
rectangle = RectangleAsset(50, 20, thinline, blue)

# Now display a rectangle
Sprite(rectangle)

myapp = App()
myapp.run()
Example #23
0
yellow = Color(0xdbd781, 1.0)
gray = Color(0xa7a7a7, 1.0)
black = Color(0x000000, 1.0)
green = Color(0x82DA30, 1.0)
brown = Color(0x977200, 1.0)
orange = Color(0xE47B03, 1.0)
blue = Color(0x00B9FF, 1.0)
indigo = Color(0x0042FF, 1.0)
violet = Color(0x6400FF, 1.0)
white = Color(0xffffff, 1.0)

thinline = LineStyle(1, black)

circlecaverock = CircleAsset(150, thinline, gray)
rectanglesand = RectangleAsset(3000, 4000, thinline, yellow)
polygonhouse = PolygonAsset([(450, 450), (500, 450), (500, 400), (475, 375),
                             (450, 400)], thinline, red)
ellipsecaveentr = EllipseAsset(75, 125, thinline, black)
ellipsetrunk = EllipseAsset(10, 100, thinline, brown)
ellipseleaf = EllipseAsset(40, 12, thinline, green)
circleleaf = CircleAsset(8, thinline, brown)
rectangledoor = RectangleAsset(15, 30, thinline, black)
rectanglewindow = RectangleAsset(12, 12, thinline, black)
redrainbow = CircleAsset(460, thinline, red)
orangerainbow = CircleAsset(440, thinline, orange)
yellowrainbow = CircleAsset(420, thinline, yellow)
greenrainbow = CircleAsset(400, thinline, green)
bluerainbow = CircleAsset(380, thinline, blue)
indigorainbow = CircleAsset(360, thinline, indigo)
violetrainbow = CircleAsset(340, thinline, violet)
whiterainbow = CircleAsset(320, thinline, white)
Example #24
0
clearsh = Color(0xD1EEEE, 0.55)
dkgr = Color(0x474747, 0.82)
medgr = Color(0x525C65, 0.79)
wit = Color(0xFCFCFC, 1)

bl_line = LineStyle(3, black)
thinline = LineStyle(1, black)

car1 = RectangleAsset(120, 70, bl_line, Orange)
car2 = RectangleAsset(125, 60, bl_line, Lgreen)
wheel = CircleAsset(12, bl_line, black)
road = RectangleAsset(1200, 280, thinline, dkgr)
window = CircleAsset(10, thinline, clearsh)
stripe = RectangleAsset(990, 10, thinline, wit)
truck = RectangleAsset(210, 80, bl_line, purp)
trkfrt = PolygonAsset([(10, 0), (80, 0), (80, 90), (0, 91), (10, 0)], thinline,
                      brn)
bgwheels = CircleAsset(16, bl_line, medgr)
bgwinw = RectangleAsset(50, 55, thinline, clearsh)

Sprite(road, (15, 1))
Sprite(stripe, (117, 108))
my4app = App()
my4app.run()

import picture
picture.my2app.run()

Sprite(car1, (680, 40))
Sprite(car2, (820, 40))
Sprite(wheel, (700, 115))
Sprite(wheel, (780, 115))
Example #25
0
black = Color(0x000000, 1.0)
white = Color(0xf8f8ff, 1.0)
yellow = Color(0xffd700, 1.0)

# Define a line style that is a thin (1 pixel) wide black line
thinline = LineStyle(1, black)
ylwln = LineStyle(1, yellow)
# A graphics asset that represents a rectangle
frnt = RectangleAsset(200, 100, thinline, black)
cntr = RectangleAsset(200, 100, thinline, white)
back = RectangleAsset(200, 100, thinline, black)
toprim = RectangleAsset(200, 100, thinline, white)
wndw = RectangleAsset(190, 90, thinline, blue)
alarm = EllipseAsset(35, 25, thinline, red)
crcle = CircleAsset(25, thinline, black)
star = PolygonAsset([(20, 0), (0, 34.641), (-20, 0)], ylwln, yellow)
star2 = PolygonAsset([(20, 0), (0, -34.641), (-20, 0)], ylwln, yellow)
handle = RectangleAsset(35, 10, thinline, black)
# Now display a rectangle
Sprite(crcle, (600, 580))
Sprite(crcle, (1000, 580))
Sprite(frnt, (500, 480))
Sprite(cntr, (700, 480))
Sprite(back, (900, 480))
Sprite(toprim, (700, 380))
Sprite(wndw, (705, 385))
Sprite(alarm, (800, 355))
Sprite(star, (800, 530))
Sprite(star2, (800, 548))
Sprite(handle, (720, 490))
Example #26
0
# add your code here \/  \/  \/
treegreen = Color(0x458B00, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0f0fff, 1.0)
black = Color(0x000000, 1.0)
slategrey = Color(0x8B8878, 1.0)
white = Color(0xffffff, 1.0)
brown = Color(0xCD661D, 1.0)
khaki = Color(0xF0E68C, 1.0)
thinline = LineStyle(2, black)

rectangle = RectangleAsset(200, 100, thinline, khaki)
Sprite(rectangle, (200, 200))

roof = PolygonAsset([(305, 100), (210, 150), (407, 150)], thinline, slategrey)
Sprite(roof, (200, 150))

door = RectangleAsset(30, 60, thinline, blue)
Sprite(door, (255, 240))

doorwindow = RectangleAsset(24, 22, thinline, slategrey)
Sprite(doorwindow, (258, 244))

window = CircleAsset(22, thinline, slategrey)
Sprite(window, (318, 230))

path = PolygonAsset([(230, 300), (160, 360), (150, 360), (200, 300)], thinline,
                    brown)
Sprite(path, (204, 300))
Example #27
0
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
thinline = LineStyle(1, black)
#sky
rectangle2 = RectangleAsset(1000, 1000, thinline, blue)
Sprite(rectangle2)
#Grass
rectangle3 = RectangleAsset(1000, 500, thinline, green)
Sprite(rectangle3, (0, 300))
#house
rectangle = RectangleAsset(500, 200, thinline, red)
Sprite(rectangle, (100, 200))
#roof
triangle = PolygonAsset([(300, 50), (550, 200), (50, 200)], thinline, green)
Sprite(triangle, (100, 50))
#window
circle = CircleAsset(30, thinline, black)
Sprite(circle, (200, 280))
#window2
ellipse = EllipseAsset(30, 30, thinline, black)
Sprite(ellipse, (450, 280))
#door
rectangle4 = RectangleAsset(50, 100, thinline, black)
Sprite(rectangle4, (330, 300))
#wall
wall = PolygonAsset([(200, 500), (550, 400), (550, 200), (200, 300)], thinline,
                    red)
Sprite(wall, (600, 100))
#roof
Example #28
0
# Three primary colors with no transparency (alpha = 1.0)
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
orange = Color(0xffa500, 1.0)

# Define a line style that is a thin (1 pixel) wide black line
thinline = LineStyle(1, black)
# A graphics asset that represents a rectangle
rectangle = RectangleAsset(300, 200, thinline, green)

# Now display a rectangle
Sprite(rectangle, (100, 150))

poly = PolygonAsset([(100, 150), (400, 150), (245, 50), (100, 150)], thinline,
                    red)
rectangle = RectangleAsset(50, 100, thinline, blue)
Sprite(rectangle, (300, 250))
Sprite(poly)
Circle = CircleAsset(5, thinline, green)
Sprite(Circle, (340, 310))
Ellipse = EllipseAsset(20, 20, thinline, black)
Sprite(Ellipse, (170, 200))
Sprite(Ellipse, (325, 200))
Circle2 = CircleAsset(50, thinline, orange)
Sprite(Circle2, (550, 100))
rectangle2 = RectangleAsset(100, 50, thinline, blue)
Sprite(rectangle2, (600, 300))
rectangle3 = RectangleAsset(150, 35, thinline, blue)
Sprite(rectangle3, (575, 330))
Circle3 = CircleAsset(13, thinline, black)
Example #29
0
# Three primary colors with no transparency (alpha = 1.0)
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
yellow = Color(0x999900, 1.0)

# Define a line style that is a thin (1 pixel) wide black line
thinline = LineStyle(1, black)
# A graphics asset that represents a rectangle

#Main square of the house
house = RectangleAsset(300, 300, thinline, blue)

#Roof
roof = PolygonAsset([(0, 100), (200, 0), (400, 100), (0, 100)], thinline, red)

#sun
sun = EllipseAsset(70, 70, thinline, yellow)

#ellipse = EllipseAsset (50, 20, thinline, blue)
#hexagon = PolygonAsset ([(0, 0), (200, 0), (250, 250), (0, 0)], thinline, red)

#Sprites
Sprite(house, (250, 250))
Sprite(roof, (200, 150))
Sprite(sun)

myapp = App()
myapp.run()
Example #30
0
red = Color(0xff0000, 0.7)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
brown = Color(0xB45F04, 1.0)
tree = Color(0x04B404, 1.0)
sky = Color(0x2EFEF7, 1.0)
yellow = Color(0xF7FE2E, 1.0)

thinline = LineStyle(1, black)

background = RectangleAsset(1700, 600, thinline, sky)
hill = EllipseAsset(600, 100, thinline, tree)
treeleaves = CircleAsset(50, thinline, tree)
treetrunk = RectangleAsset(30, 100, thinline, brown)
sun = PolygonAsset([(0, 30), (0, 60), (30, 90), (60, 90), (90, 60), (90, 30),
                    (60, 0), (30, 0)], thinline, yellow)

Sprite(background, (-1, -1))
Sprite(hill, (90, 350))
Sprite(hill, (-300, 380))
Sprite(hill, (-100, 430))
Sprite(treetrunk, (200, 350))
Sprite(treeleaves, (165, 300))
Sprite(treetrunk, (500, 300))
Sprite(treeleaves, (465, 250))
Sprite(sun, (100, 100))
# add your code here /\  /\  /\

myapp = App()
myapp.run()