Exemple #1
0
def main():
    global MAINCLOCK, DISPLAYSURF, FONT, BIGFONT, BGIMAGE
    global mousex, mousey
    global WINDOWWIDTH, WINDOWHEIGHT
    global sf30

    print("pygame.init")
    pygame.init()
    print("get the clock")
    MAINCLOCK = pygame.time.Clock()

    sf30 = SF30.SF30()
    while not sf30.joystick_detected:
        time.sleep(1.0)
        print("Waiting for joystick ")
    print("Joystick detected")

    mousex, mousey = leftTopCoordsOfBox(mouseX, mouseY)

    #print ("Wait 10 seconds")
    #time.sleep (10)
    print("set width/height")
    DISPLAYSURF = pygame.display.set_mode((480, 320))
    print("toggle full screen mode")
    print("time.sleep (3))")
    time.sleep(3)
    pygame.display.toggle_fullscreen()

    pygame.display.set_caption('Flippy')
    FONT = pygame.font.Font('freesansbold.ttf', 16)
    BIGFONT = pygame.font.Font('freesansbold.ttf', 32)

    # Set up the background image.
    boardImage = pygame.image.load('flippyboard.png')
    # Use smoothscale() to stretch the board image to fit the entire board:
    boardImage = pygame.transform.smoothscale(
        boardImage, (BOARDWIDTH * SPACESIZE, BOARDHEIGHT * SPACESIZE))
    boardImageRect = boardImage.get_rect()
    boardImageRect.topleft = (XMARGIN, YMARGIN)
    BGIMAGE = pygame.image.load('flippybackground.png')
    # Use smoothscale() to stretch the background image to fit the entire window:
    BGIMAGE = pygame.transform.smoothscale(BGIMAGE,
                                           (WINDOWWIDTH, WINDOWHEIGHT))
    BGIMAGE.blit(boardImage, boardImageRect)

    runGame()
Exemple #2
0
# Star Pusher (a Sokoban clone)
# By Al Sweigart [email protected]
# http://inventwithpython.com/pygame
# Released under a "Simplified BSD" license

import random, sys, copy, os, pygame
from pygame.locals import *
import SF30

sf30 = SF30.SF30()

FPS = 30  # frames per second to update the screen
WINWIDTH = 480  # width of the program's window, in pixels
WINHEIGHT = 320  # height in pixels
HALF_WINWIDTH = int(WINWIDTH / 2)
HALF_WINHEIGHT = int(WINHEIGHT / 2)

# The total width and height of each tile in pixels.
TILEWIDTH = 50
TILEHEIGHT = 85
TILEFLOORHEIGHT = 40

CAM_MOVE_SPEED = 5  # how many pixels per frame the camera moves

# The percentage of outdoor tiles that have additional
# decoration on them, such as a tree or rock.
OUTSIDE_DECORATION_PCT = 20

BRIGHTBLUE = (0, 170, 255)
WHITE = (255, 255, 255)
BGCOLOR = BRIGHTBLUE