Пример #1
0
class Ball(Sprite):
    ball = EllipseAsset(69, 69, whiteline, yellow)
    
    def __init__(self, position):
        super().__init__(Ball.ball, position)
        self.vx = 20
        self.vy = 0
        self.thrust = 0
        self.thrustframe = 1
        self.center = (0.5, 0.5)
        self.scale = 0.2
        
    def step(self):
        self.x += self.vx * 0.7
        self.y += self.vy * 0.7
        
        collisionleft = self.collidingWith(myapp.borderleft) 
        collisionright = self.collidingWith(myapp.borderright)
        hitspaddle2 = self.collidingWith(myapp.paddle2)
        hitspaddle1 = self.collidingWith(myapp.paddle1)
        hitsbordertop = self.collidingWith(myapp.bordertop)
        hitsborderbott = self.collidingWith(myapp.borderbottom)
        
        rand = random.randint(0, 3)
    
        if hitspaddle2:
            self.vx = -30
            if rand == 0:
                self.vy = 3
            elif rand == 1:
                self.vy = -3
            elif rand == 2:
                self.vy = 6
            elif rand == 3:
                self.vy = -6
        
        elif hitspaddle1:
            self.vx = 30
            if rand == 0:
                self.vy = 3
            elif rand == 1:
                self.vy = -3
            elif rand == 2:
                self.vy = 7
            elif rand == 3:
                self.vy = -7
        
        elif collisionright:
            self.vx = 0
            self.visible = False
        
        elif collisionleft:
            self.vx = 0
            self.visible = False
        
        elif hitsbordertop:
            self.vy = self.vy*-1
        
        elif hitsborderbott:
            self.vy = self.vy*-1
Пример #2
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')
Пример #3
0
 def test_ellipseasset(self):
     e = EllipseAsset(40, 50, LineStyle(4, Color(0x113355, 0.6)),
                      Color(0x224466, 0.7))
     self.assertEqual(e.gfx.visible, False)
     self.assertEqual(e.gfx.ehw, 40)
     self.assertEqual(e.gfx.ehh, 50)
     self.assertEqual(e.gfx.x, 0)
 def __init__(self, x, y, color, app):
     super().__init__(
         EllipseAsset(12, 12, LineStyle(0, Color(0, 1.0)), color), (x, y))
     self.xdirection = 0
     self.ydirection = 0
     self.go = True
     self.pacisalive = True
     self.stopscore = False
Пример #5
0
class dish(Sprite):
    asset = EllipseAsset(5, 50, thin1line, white)

    def __init__(self, position):
        super().__init__(dish.asset, position)
        self.fxcenter = 0.5
        self.fycenter = 0.5
        self.vx = 0
        self.vy = 0
        self.rotation = math.atan2(450 - cpy, cpx - 100)
Пример #6
0
class Arm(Sprite):
    asset = EllipseAsset(4, 8, gridline, black)

    def __init__(self, position):
        super().__init__(Arm.asset, position)
        self.vx = 0
        self.vy = 0
        self.vr = 0
        self.fxcenter = .5
        #self.reverse=False
        self.spin = False

    '''    
Пример #7
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 \/  \/  \/

face = Color(0xFFD39B, 1.0)
white = Color(0xF0F8FF, 1.0)
eyes = Color(0x458B74, 1.0)
black = Color(0x000000, 1.0)
pink = Color(0xFF1493, 1.0)
thinline = LineStyle(1, black)
ellipse = EllipseAsset(64, 80, thinline, face)
Sprite(ellipse, (64, 80))

eye1 = CircleAsset(16, thinline, white)
Sprite(eye1, (90, 130))

eye2 = CircleAsset(16, thinline, white)
Sprite(eye2, (140, 130))

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

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

pupil2 = CircleAsset(3, thinline, black)
Пример #8
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()
Пример #9
0
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

# add your code here \/  \/  \/
red = Color(0xFF4040, 1.0)
blue = Color(0x40FFFF, 1.0)
green = Color(0x000000, 1.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))
Пример #10
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)

# Define a line style that is a thin (1 pixel) wide black line
thinline = LineStyle(5, black)
thicc = LineStyle(20, red)
x = LineStyle(14, green)
# A graphics asset that represents a rectangle
rectangle = RectangleAsset(1000, 500, thinline, blue)
Circle2 = CircleAsset(300, thinline,black)
Circle = CircleAsset(100, thinline,red)
Ellipse = EllipseAsset(230,35, thinline, green)
Ellipse2 = EllipseAsset(230,35, thinline, black)
Polygon = PolygonAsset(((10,70,), (30,50),(60,60)), thicc, red)
rectangle2 = RectangleAsset(100, 300, thicc, red)
Polygon2 = PolygonAsset(((10,70,), (30,5),(90,60)), thicc, blue)
Polygon3 = PolygonAsset(((10,70,), (30,5),(90,60)), thinline, blue)
Circle3 = CircleAsset(30, thicc,blue)
# Now display a rectangle
Sprite(rectangle)
Sprite(Circle2)
Sprite(Circle)
Sprite(Ellipse2, (320,320))
Sprite(Ellipse, (300,300))
Sprite(Polygon)
Sprite(rectangle2, (400,400))
Sprite(Polygon2, (100,400))
Пример #11
0
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)
leaves1 = RectangleAsset(2, 30, thinline7, green)
fish = EllipseAsset(45, 27, thinline4, orange)
tail = EllipseAsset(20, 10, thinline4, darkorange)
fins = EllipseAsset(15, 7, thinline4, darkorange)
fish2 = RectangleAsset(80, 80, thinline5, blue)
tail2 = PolygonAsset([(40, 40), (70, 20), (70, 60)], thinline5, blue)
line1 = PolygonAsset([(40, 60), (40, 12), (40, 60)], thinline2, black)
eye = CircleAsset(3, thinline5, black)
eye1 = CircleAsset(7, thinline5, white)
Пример #12
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)

Sprite(redrainbow, (775, 500))
Пример #13
0
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.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))
Пример #14
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()
Пример #15
0
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
roof2 = PolygonAsset([(0, 50), (250, 200), (600, 100), (400, 0), (230, 0)],
                     thinline, green)
Sprite(roof2, (350, 0))
#window top
windowtop = EllipseAsset(50, 30, thinline, black)
Sprite(windowtop, (300, 120))
Пример #16
0
from ggame import App, Color, LineStyle, Sprite
from ggame import RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

# color variabls
red = Color(0xff0000, 0.7)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
white = Color(0xffffff, 1.0)

# 1 Pixel wide line
thinline = LineStyle(1, black)
# rectangle
rectangle = RectangleAsset(50, 50, thinline, blue)
ellipse = EllipseAsset(25, 25, thinline, blue)
polygon = PolygonAsset([(15, 60), (75, 60), (90, 0), (45, -30), (0, 0)],
                       thinline, red)

# display the shapes
Sprite(rectangle, (0, 0))
Sprite(rectangle, (25, 25))
Sprite(ellipse, (100, 100))
Sprite(polygon, (80, 80))

myapp = App()
myapp.run()
Пример #17
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))
Пример #18
0
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

# add your code here \/  \/  \/
#from tutorial
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 = LineStyle(1, black)

trunk = RectangleAsset(10, 40, line, black)
orn1 = CircleAsset(5, line, red)
orn2 = CircleAsset(5, line, blue)
base = EllipseAsset(40, 10, line, black)
third = PolygonAsset([(25, 0), (0, 90), (50, 90), (25, 0)], line, green)
second = PolygonAsset([(25, 0), (0, 70), (50, 70), (25, 0)], line, green)
first = PolygonAsset([(25, 0), (0, 50), (50, 50), (25, 0)], line, green)
star = PolygonAsset([(25, 0), (15, 25), (40, 10), (10, 10), (35, 25), (25, 0)],
                    line, yellow)
pres = RectangleAsset(30, 30, line, red)
rib = RectangleAsset(10, 30, line, blue)
rib2 = RectangleAsset(30, 10, line, blue)

Sprite(trunk, (220, 130))
Sprite(third, (200, 50))
Sprite(second, (200, 50))
Sprite(first, (200, 50))
Sprite(orn1, (215, 75))
Sprite(orn2, (220, 100))
Пример #19
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
ellipse = EllipseAsset(100, 200, thinline, blue)
# Now display a rectangle
Sprite(ellipse)
myapp = App()
myapp.run()
Пример #20
0
ground_snow = RectangleAsset(1500, 275, thinline, blue)

#the snowman body
base = CircleAsset(80, thinline, light_blue)
middle = CircleAsset(50, thinline, light_blue)
head = CircleAsset(40, thinline, light_blue)
nose = PolygonAsset([(0, 0), (0, 15), (30, 12)], thinline, orange)
eyes = CircleAsset(5, thinline, black)
arm_left = PolygonAsset([(0, 0), (15, 5), (100, 90), (100, 100)], thinline,
                        black)
arm_right = PolygonAsset([(210, 0), (195, 5), (100, 90), (100, 100)], thinline,
                         black)

#accessories
hat_base = RectangleAsset(80, 20, thinline, black)
hat_top = EllipseAsset(25, 28, thinline, black)
buttons = CircleAsset(5, thinline, black)

# display
Sprite(ground_snow, (0, 400))
Sprite(base, (350, 240))
Sprite(middle, (380, 140))
Sprite(head, (390, 60))
Sprite(nose, (430, 100))
Sprite(eyes, (410, 80))
Sprite(eyes, (440, 80))
Sprite(arm_left, (280, 100))
Sprite(arm_right, (480, 100))
Sprite(hat_base, (390, 40))
Sprite(hat_top, (405, 4))
Sprite(buttons, (425, 200))
Пример #21
0
Sprite(rectangle, (350, 150))

#grass day
rectangle2 = RectangleAsset(475, 300, thinline, green)
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
Пример #22
0
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

# add your code here \/  \/  \/
from ggame import App, Color, LineStyle, Sprite
from ggame import RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

lightblue= Color(0x00bfff, 1.0)
green=Color(0x2e8b57,1.0)
brown=Color(0x8b4513, .8)
purple=Color(0x9370db, 1.0)
black = Color(0x000000, 1.0)
blue=Color(0x0000f,1.0)

line=LineStyle(1,black)

Petal=EllipseAsset(50,20,line, lightblue)
petal2=EllipseAsset(20,50,line, lightblue)
Circle=CircleAsset(30, line, purple)
stem=RectangleAsset(5,100,line,green)
pot=PolygonAsset([(300,500), (500,500), (450,600), (350,600), (300,500)], line, brown)

Sprite(Circle, (375,300))
Sprite(Petal, (300,300))
Sprite(Petal, (450,300))
Sprite(petal2, (380,225))
Sprite(stem, (380,400))
Sprite(petal2, (380,375))
petal3=Sprite(petal2,(315,245))
petal3.rotation=3.14/4
petal4=Sprite(petal2,(430,355))
petal4.rotation=3.14/4
Пример #23
0
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)
Sprite(trunk2, (135, 350))

tree2 = EllipseAsset(50, 100, line1, green)
Sprite(tree2, (100, 200))

# add your code here /\  /\  /\

myapp = App()
myapp.run()
Пример #24
0
rectangle37 = RectangleAsset(25, 140, thinline, yellow)
rectangle38 = RectangleAsset(100, 25, thinline, yellow)
rectangle39 = RectangleAsset(25, 115, thinline, yellow)
rectangle40 = RectangleAsset(25, 140, thinline, green)
rectangle41 = RectangleAsset(100, 50, thinline, green)
rectangle42 = RectangleAsset(50, 25, thinline, white)
rectangle43 = RectangleAsset(140, 140, thinline, blue)
rectangle44 = RectangleAsset(90, 90, thinline, white)
rectangle45 = RectangleAsset(25, 140, thinline, red)
rectangle46 = RectangleAsset(100, 50, thinline, red)
rectangle47 = RectangleAsset(50, 25, thinline, white)
rectangle48 = RectangleAsset(35, 35, thinline, red)
rectangle49 = RectangleAsset(35, 35, thinline, yellow)
rectangle50 = RectangleAsset(35, 35, thinline, green)
rectangle51 = RectangleAsset(35, 35, thinline, blue)
ellipse = EllipseAsset(12, 30, Thinline, black)
ellipse2 = EllipseAsset(50, 7, Thinline, black)
circle = CircleAsset(30, Thinline, blue)
circle1 = CircleAsset(40, Thinline, blue)
circle2 = CircleAsset(40, Thinline, blue)
circle3 = CircleAsset(35, thinline, yellow)
circle4 = CircleAsset(25, thinline, white)
circle5 = CircleAsset(30, thinline, black)
circle6 = CircleAsset(22, thinline, white)
circle7 = CircleAsset(30, thinline, blue)
circle8 = CircleAsset(22, thinline, white)
circle9 = CircleAsset(35, thinline, green)
circle10 = CircleAsset(35, thinline, green)
circle11 = CircleAsset(20, thinline, white)
circle12 = CircleAsset(20, thinline, white)
circle13 = CircleAsset(10, thinline, blue)
Пример #25
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()
Пример #26
0
from ggame import App, Color, LineStyle, Sprite, RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset

# add your code here \/  \/  \/
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 /\  /\  /\
Пример #27
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))
Sprite(eye, (1020, 190))
Sprite(shad, (1190, 600))

myapp = App()
myapp.run()
Пример #28
0
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
purple = Color(0xA642C9, 1.0)
white = Color(0xFFFFFF, 1.0)
yellowish = Color(0xF1F2D5, 1.0)
brown = Color(0x915643, 1.0)

thinline = LineStyle(1, black)
thinlinered = LineStyle(1, red)

sky = RectangleAsset(800, 400, thinline, black)
moon = CircleAsset(40, thinline, yellowish)
water = RectangleAsset(800, 400, thinline, blue)
fish = EllipseAsset(50, 20, thinlinered, red)
fin = PolygonAsset([(40, 470), (50, 440), (60, 470)], thinlinered, red)
eye = CircleAsset(2, thinline, black)
star = CircleAsset(2, thinline, white)
boat = EllipseAsset(60, 20, thinline, brown)
mast = RectangleAsset(4, 60, thinline, brown)
sail = PolygonAsset([(0, 0), (0, 40), (30, 40)], thinline, white)

Sprite(sky, (0, 0))
Sprite(water, (0, 400))
Sprite(moon, (200, 50))
Sprite(fish, (50, 480))
Sprite(fin, (0, 0))
Sprite(eye, (80, 480))
Sprite(star, (400, 40))
Sprite(star, (100, 80))
Пример #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()
Пример #30
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)
Sprite(Circle3, (600, 370))
Sprite(Circle3, (700, 370))
myapp = App()
myapp.run()