Example #1
0
def destination(place, file):
    thequestion=input("Welcome to {0}! You may: 1. Look around, 2. Attempt to Trade, 3. Stop to Rest, 4. See your health, 5. Review your items, 6. Go to the Store, 7. Continue on the hike".format(place))
    if thequestion is "1":
        picture=ImageAsset("images/" + file)
        picture_sprite=Sprite(picture, (0,0))
        myapp = App()
        myapp.run()
Example #2
0
class brickwall(Sprite)

def __init__(self, position):
    super().__init__(brick_asset.asset, position)
    
    wall.listenKey



myapp = App(SCREEN_WIDTH, SCREEN_HEIGHT)
myapp.run()
 def test_app(self):
     a3 = App(100, 100)
     # event handling
     a3.listenKeyEvent(KeyEvent.keydown, "space", self.spacehandler)
     a3.listenMouseEvent(MouseEvent.mousewheel, self.wheelhandler)
     key = keyevent('keydown', 32)
     a3._keyEvent(key)
     mouse = mouseevent('wheel', 1, 2, 99)
     a3._mouseEvent(mouse)
     # confirm no events after unlisten
     a3.unlistenKeyEvent(KeyEvent.keydown, "space", self.spacehandler)
     a3.unlistenMouseEvent(MouseEvent.mousewheel, self.wheelhandler)
     a3._keyEvent(key)
     a3._mouseEvent(mouse)
     # assert that each handler was executed only once
     self.assertEqual(self.keyevtx, 1)
     self.assertEqual(self.mouseevtx, 1)
     # run the app
     a3.run()
     # and destroy it
     a3._destroy()
Example #4
0
    def test_enfoldingcollision(self):
        def step():
            s1.x += 1
            s2.x -= 1
            c = s1.collidingWith(s2)
            self.assertTrue(c, msg="big sprite colliding with embedded sprite")
            c = s2.collidingWith(s1)
            self.assertTrue(c,
                            msg="small sprite colliding with enfolding sprite")

        s1 = Sprite(self.rocket, (10, 10))
        s2 = Sprite(self.image, (15, 15))

        a = App()
        a.run(step)

        for i in range(10):
            a._animate(1)

        s1.destroy()
        s2.destroy()
Example #5
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 #6
0
bg_asset = RectangleAsset(SCREEN_WIDTH, SCREEN_HEIGHT, noline, black)
bg = Sprite(bg_asset, (0, 0))


class SpaceShip(Sprite):
    """
    Animated space ship
    """
    asset = ImageAsset("images/four_spaceship_by_albertov_with_thrust.png",
                       Frame(227, 0, 292 - 227, 125), 4, 'vertical')

    def __init__(self, position):
        super().__init__(SpaceShip.asset, position)


class SpaceGame(App):
    """
    Tutorial4 space game example.
    """
    def __init__(self, width, height):
        super().__init__(width, height)
        black = Color(0, 1)
        noline = LineStyle(0, black)
        bg_asset = RectangleAsset(width, height, noline, black)
        bg = Sprite(bg_asset, (0, 0))


myapp = SpaceGame(SCREEN_WIDTH, SCREEN_HEIGHT)
myapp = App(SCREEN_WIDTH, SCREEN_HEIGHT)
myapp.run()
Example #7
0
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))
Sprite(wheel, (840, 100))
Sprite(wheel, (920, 100))
Sprite(window, (700, 60))
Sprite(window, (740, 60))
Sprite(window, (780, 60))
Sprite(window, (840, 65))
Example #8
0
"""
Trivial example of a minimal ggame App with Sprite.
"""
from ggame import App, ImageAsset, Sprite

# Create a displayed object at 100,100 using an image asset
Sprite(ImageAsset("bunny.png"), (100, 100))
# Create the app, with a default stage
APP = App()
# Run the app
APP.run()
Example #9
0
# Sierpinsky demo
from ggame import CircleAsset, Sprite, App, Color, LineStyle

GASKET_SIZE = 64
black = Color(0x000000, 1.0)
thinline = LineStyle(1, black)
asset = CircleAsset(0.25, thinline, black)

# Draw a Sierpinsky Gasket of width and height d,
# with upper left at (x, y).
def draw_sierpinsky(x, y, d):
    if d <= 1:
        Sprite(asset, (x, y))                 # base case
    else:
        # recurse on upper left quadrant
        draw_sierpinsky(x, y, d/2)
        # recurse on upper right quadrant
        draw_sierpinsky(x + d/2, y, d/2)
        # recurse on lower right quadrant
        draw_sierpinsky(x + d/2, y + d/2, d/2)

draw_sierpinsky(0, 0, GASKET_SIZE)

App().run()
Example #10
0
brn = Color(0x5C3317, 0.9)
pale = Color(0xFFFACD, 0.4)

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

brkhr = RectangleAsset(130, 32, bl_line, brn)
head = EllipseAsset(120, 100, bl_line, pale)
nose = PolygonAsset([(50, 60), (75, 40), (100, 60), (50, 60)], thinline, turqo)
eye = CircleAsset(20, thinline, Lgreen)
pupil = CircleAsset(8, thinline, purp)
mouth = PolygonAsset([(0, 0), (100, 0), (80, 20), (20, 20), (0, 0)], bl_line,
                     Orange)
hat = RectangleAsset(80, 20, thinline, turqo)
neck = EllipseAsset(60, 75, bl_line, pale)
arm = PolygonAsset([(30, 50), (125, 50), (145, 80), (30, 80)], thinline, brn)

Sprite(head, (150, 140))
Sprite(brkhr, (90, 10))
Sprite(nose, (75, 70))
Sprite(eye, (190, 80))
Sprite(eye, (110, 80))
Sprite(pupil, (190, 80))
Sprite(pupil, (110, 80))
Sprite(mouth, (100, 170))
Sprite(hat, (115, 15))
Sprite(neck, (150, 300))
Sprite(arm, (160, 180))

my2app = App()
my2app.run()
Example #11
0
"""
Patrick Daley
"""

from ggame import App, Color, LineStyle, Sprite, TextAsset
from ggame import RectangleAsset, CircleAsset, EllipseAsset, PolygonAsset, ImageAsset, Frame
from math import floor
myapp = App(1017,512)

blue = Color(0x2EFEC8, 1.0)
black = Color(0x000000, 1.0)
pink = Color(0xFF00FF, 1.0)
red = Color(0xFF5733, 1.0)
white = Color(0xFFFFFF, 1.0)
red = Color(0xff0000, 1.0)
green = Color(0x00ff00, 1.0)
blue = Color(0x0000ff, 1.0)
black = Color(0x000000, 1.0)
white = Color(0xffffff, 1.0)
grey = Color(0xC0C0C0, 1.0)

thinline = LineStyle(2, black)
blkline = LineStyle(1, black)
noline = LineStyle(0, white)
coolline = LineStyle(1, grey)
blueline = LineStyle(2, blue)
redline = LineStyle(1, red)
greenline = LineStyle(1, green)
gridline = LineStyle(1, grey)
grid=RectangleAsset(30,30,gridline,white)
Example #12
0
#Acts on actions lists to accomplish changes simultaneously
    for cell in birthcell:
        coord[cell] = 1
    for cell in agecell:
        coord[cell] = 2
    for cell in killcell:
        coord[cell] = 0
    display():

#Function called by mouse clicks to change cells manually
def change(info):
    x = int(info.x/10)
    y = int(info.y/10)
    if x >= mapsize or y >= mapsize or x <= 0 or y <= 0:
        return
    elif coord[(x,y)] == 0:
        coord[(x,y)] = 1
        Sprite(newcell,(x*10,y*10))
    else:
        coord[(x,y)] = 0
        Sprite(deadcell,(x*10,y*10))

display():

App.listenKeyEvent("keydown", "space", ticker)
App.listenMouseEvent("mousedown", change)

app = App()
app.run()
    
Example #13
0
thickgreen = LineStyle(7, green)
thinwhite = LineStyle(1, white)
thingreen = LineStyle(1, green)
ground = RectangleAsset(500, 20, thinline, brown)
Sprite((ground), (0, 220))
pipe1 = RectangleAsset(30, 50, thingreen, green)
Sprite((pipe1), (350, 180))
pipe2 = EllipseAsset(25, 10, thickgreen, black)
Sprite((pipe2), (337.5, 170))
block = RectangleAsset(15, 15, thinline, brown)
Sprite((block), (200, 100))
Sprite((block), (230, 100))
Sprite((block), (215, 100))
goomba = PolygonAsset([(0, 0), (10, -15), (20, 0), (0, 0)], thinbrown, brown)
Sprite((goomba), (215, 75))
geyes = CircleAsset(1, thinwhite, black)
Sprite((geyes), (222.5, 80))
Sprite((geyes), (226.5, 80))
gleg = RectangleAsset(1, 10, thinline, black)
Sprite((gleg), (222.5, 90))
Sprite((gleg), (227.5, 90))
#its ugly but its supposed to be a goomba, mario and a pipe
# add your code here \/  \/  \/
#no

Sprite(ImageAsset("Small-mariogood5.png"), (100, 200))
app = App(500, 500)
app.run()

# add your code here /\  /\  /\
from ggame import App, RectangleAsset, ImageAsset, Sprite, LineStyle, Color, Frame, CircleAsset
PrettyColors={'Green':'0x00ff00', 'Red':'0xff000', 'Blue':'0x0000ff'}
class Circle(App):
    def __init__(self, radius):
         super().__init__(radius)
    radius=int(input("Radius?"))
    black=Color(0,1)
    red=Color(0xA62A2A)
    ogline=Linestyle(1, black)
    Circle_Asset=CircleAsset(radius, ogline, red)
    Circle=Sprite(Circle_Asset, (100,100))
        
myapp = App(Circle)
myapp.run()
Example #15
0
            ace = 1
        elif o == AD:
            yourscore += 1
            ace = 1
        else:
            yourscore += 10
        if yourscore > 21.5:
            print("You busted")
            t = 3
            yb = 5
            allowbet = 1
            money = int(money) - int(bet)
            print("You have $" + str(money))
            print("Press space to start another round")
            bet = 0
            m = 2
            n = 2
    #changing you score


#Note: This game is for educational use only

myapp = App()
app = App(500, 500)
app.run(step)
myapp.listenKeyEvent('keydown', 'space', pauseplay)
myapp.listenKeyEvent('keydown', 's', stay)
myapp.listenKeyEvent('keydown', 'enter', begin)
myapp.listenKeyEvent('keydown', 'h', hit)
myapp.listenKeyEvent('keydown', 'b', betting)
myapp.listenKeyEvent('keydown', 'r', rules)
Example #16
0
def map(file,scale):
    picture=ImageAsset("images/" + file)
    picture_sprite=Sprite(picture, (0,0))
    picture_sprite.scale = scale
    myapp = App()
    myapp.run()