예제 #1
0
 def __init__ (self, scalar2):
     small = loadImage("Assets\\images\\smallasteroids.gif")
     small.set_colorkey((255,255,255))
     small = spriteSheetBreaker(small, 40, 40, 0, 0, 1, 4)
     medium = loadImage("Assets\\images\\mediumasteroids.gif")
     medium.set_colorkey((255,255,255))
     medium = spriteSheetBreaker(medium, 50, 50, 0, 0, 1, 4)
     large = loadImage("Assets\\images\\largeasteroids.gif")
     large.set_colorkey((255,255,255))
     large = spriteSheetBreaker(large, 80, 80, 0, 0, 1, 4)
     fillerlist = ["4", "5", "6", "7", "8", "9"]
     asteroidlist = small + fillerlist + medium + fillerlist + large + fillerlist
     for i in range(len(asteroidlist)):
         if not isinstance(asteroidlist[i], str):
             asteroidlist[i] = scaleImage(asteroidlist[i], scalar2)
     Asteroid.asteroidlist = asteroidlist
     Asteroid.scalar2 = scalar2
예제 #2
0
def rotationCachingHelper(filepath, spritesheetWidth, spritesheetHeight,
                          spritesheetRows, spritesheetColumns, idIntercept,
                          scalar2):
    asteroids = loadImage(filepath)
    asteroids.set_colorkey((255, 255, 255))
    asteroids = spriteSheetBreaker(asteroids, spritesheetWidth,
                                   spritesheetHeight, 0, 0, spritesheetRows,
                                   spritesheetColumns)
    for i in range(len(asteroids)):
        asteroids[i] = scaleImage(asteroids[i], scalar2)
    for i in range(len(asteroids)):
        Images.addRotate(idIntercept + i, asteroids[i])
예제 #3
0
def setup():
    pygame.init()

    scrInfo = pygame.display.Info()
    suggestedRes = scrInfo.current_w, scrInfo.current_h
    if suggestedRes[0] < 0 or platform.system() == "Darwin":
        suggestedRes = pygame.display.list_modes()[0]

    widthBox = InputGetter([(110, 75), str(suggestedRes[0]), 1.5], "int")
    heightBox = InputGetter([(230, 75), str(suggestedRes[1]), 1.5], "int")

    logo = loadImage("Assets\\images\\earth2.png")
    logo.set_colorkey((255, 0, 0))
    pygame.display.set_icon(logo)
    pygame.display.set_caption("Kessler First Time Setup")
    clock = pygame.time.Clock()
    screen = pygame.display.set_mode([600, 450])

    Texthelper.width = 600
    Texthelper.height = 450
    Texthelper.scalar = 1.5
    Texthelper.SAFEASPECT = (4, 3)

    full = True

    color = (20, 110, 230)

    running = True
    while running:
        clock.tick(100)
        screen.fill(color)

        Texthelper.write(screen,
                         [("center", 20), "Welcome to Kessler Syndrome", 1.4])
        Texthelper.write(
            screen, [("center", 50), "Resolution reported by your system:", 1])
        widthBox.update(screen)
        Texthelper.write(screen, [(190, 75), "by", 1.5])
        heightBox.update(screen)
        Texthelper.write(
            screen,
            [("center", 110), "Please change to your desired resolution", 0.9])

        Texthelper.write(screen, [(50, 170), "Fullscreen:", 1.5])
        if Texthelper.writeButton(screen, [(240, 170), str(full), 1.5]):
            full = not full
        Texthelper.write(
            screen, [(2, 200), "Note: If you are going to do fullscreen,", 1])
        Texthelper.write(
            screen, [(2, 215), "the resolution set should be the same", 1])
        Texthelper.write(screen, [(27, 230), "as your monitors resolution", 1])

        if Texthelper.writeButton(screen, [("center", 270), "Continue", 1.25]):
            contents = filehelper.get(0)
            contents[0] = widthBox.getText()
            contents[1] = heightBox.getText()
            contents[2] = full
            filehelper.set(contents, 0)
            running = False

        collect_inputs()

        pygame.display.flip()
        for event in AllEvents.TICKINPUT:
            if event.type == pygame.QUIT:
                running = False
                pygame.quit()
                raise SystemExit

    pygame.quit()
예제 #4
0
def init(d_asteroids, d_parts, d_sats, graphlist, scalar2, scalar3,
         scalarscalar):
    #adding all asteroid images/rotations
    rotationCachingHelper("Assets\\images\\smallasteroids.gif", 40, 40, 1, 4,
                          70, scalar2)
    rotationCachingHelper("Assets\\images\\mediumasteroids.gif", 50, 50, 1, 4,
                          80, scalar2)
    rotationCachingHelper("Assets\\images\\largeasteroids.gif", 80, 80, 2, 4,
                          90, scalar2)

    #adding all satellites and parts images/rotations
    pixelStuff = d_parts + d_sats
    for i in range(len(pixelStuff)):
        surf = graphlist[pixelStuff[i] - 10]
        Images.addRotate(pixelStuff[i], surf)

    #adding images for info bars
    Images.add(
        "fuelpic",
        scaleImage(loadImage("Assets\\images\\fuelcanister.tif"),
                   2 * scalarscalar))
    Images.add(
        "armorpic",
        scaleImage(loadImage("Assets\\images\\armor.tif"), scalarscalar))
    Images.add("shotpic",
               scaleImage(loadImage("Assets\\images\\missile.png"),
                          scalarscalar),
               colorkey=(255, 255, 255))

    #adding other icons
    Images.add(
        "infinity",
        scaleImage(loadImage("Assets\\images\\infinity.tif"), scalarscalar))
    Images.add(
        "pygamebadge",
        scaleImage(loadImage("Assets\\images\\pygame-badge-SMA-unscaled.png"),
                   2.5 * scalarscalar))

    #adding miscellaneous other object images
    Images.add(
        0, scaleImage(loadImage("Assets\\images\\zvezda.tif"),
                      2 * scalarscalar))
    Images.add(
        200,
        scaleImage(loadImage("Assets\\images\\fuelstation.tif"),
                   2 * scalarscalar))
    Images.addRotate(
        7,
        scaleImage(loadImage("Assets\\images\\alienMines.tif"),
                   2 * scalarscalar))
    Images.add(
        9,
        scaleImage(loadImage("Assets\\images\\ionBlast.tif"),
                   .5 * scalarscalar))

    #aliens
    Images.addRotate(120,
                     scaleImage(loadImage("Assets\\images\\aliendrone.gif"),
                                2 * scalarscalar),
                     colorkey=(255, 255, 255))
    Images.addRotate(121,
                     scaleImage(loadImage("Assets\\images\\spiker.gif"),
                                2 * scalarscalar),
                     colorkey=(255, 255, 255))
    Images.addRotate(122,
                     scaleImage(loadImage("Assets\\images\\alienshot.gif"),
                                scalarscalar),
                     colorkey=(255, 255, 255))
    #aliens - alien mines
    imageList = spriteSheetBreaker(loadImage("Assets\\images\\alienbomb.gif"),
                                   19, 19, 0, 0, 1, 6)
    for i in range(len(imageList)):
        image = imageList[i]
        image.set_colorkey((255, 255, 255))
        image = scaleImage(image, 2 * scalarscalar)
        if i == 0:
            Images.addRotate(123, image)  #reference image at 123 for hitboxes
        Images.addRotate(123 + (i + 1) / 100, image)

    #adding different types of stars
    base_star = loadImage("Assets\\images\\star.gif")
    base_star_unscaled = base_star
    base_star.set_colorkey((255, 255, 255))
    base_star = scaleImage(base_star, scalarscalar)
    Images.add(100, base_star)
    Images.add(
        101,
        change_color(base_star, (255, 216, 0, 255), (255, 160, 0, 255), True))
    Images.add(
        102,
        change_color(base_star, (255, 216, 0, 255), (255, 130, 0, 255), True))
    base_star = scaleImage(base_star_unscaled, 2 * scalarscalar)
    Images.add(103, base_star)
    Images.add(
        104,
        change_color(base_star, (255, 216, 0, 255), (255, 160, 0, 255), True))
    Images.add(
        105,
        change_color(base_star, (255, 216, 0, 255), (255, 130, 0, 255), True))

    #adding ship, no rotation because it rotates in real time
    #loads up spritesheet and loads them all up under separate IDs
    imageList = spriteSheetBreaker(loadImage("Assets\\images\\ships.png"), 24,
                                   60, 0, 0, 1, 5)
    for i in range(len(imageList)):
        imageList[i].set_colorkey((255, 255, 255))
        imageList[i] = scaleImage(imageList[i], scalar3)
    Images.add(1.1, imageList[0])
    Images.add(1.2, imageList[1])
    Images.add(1.3, imageList[2])
    Images.add(1.4, imageList[3])
    Images.add(1.5, imageList[4])

    #adding downed fighters
    imageList = spriteSheetBreaker(loadImage("Assets\\images\\fighters.gif"),
                                   42, 22, 0, 0, 2, 2)
    for i in range(len(imageList)):
        imageList[i].set_colorkey((255, 255, 255))
        imageList[i] = scaleImage(imageList[i], 1.1 * scalarscalar)
        Images.addRotate(130 + i, imageList[i])

    #adding derelict ship, no rotation because it's always in the same orientation
    image = scaleImage(loadImage("Assets\\images\\derelict.gif"), scalarscalar)
    image.set_colorkey((255, 255, 255))
    change_color(image, (0, 0, 0, 255), (25, 25, 25, 255))
    Images.add(110, image)

    #adding president's ship
    Images.addRotate(666,
                     scaleImage(loadImage("Assets\\images\\protoprez3.gif"),
                                scalarscalar),
                     colorkey=(255, 255, 255))