コード例 #1
0
green = Color(0x00ff00, 1)
black = Color(0, 1)

noline = LineStyle(0, black)

bg_asset = RectangleAsset(SCREEN_WIDTH, SCREEN_HEIGHT, noline, green)
bg = Sprite(bg_asset, (0,0))


# A ball! This is already in the ggame-tutorials repository
ball_asset = ImageAsset("images/orb-150545_640.png")
ball = Sprite(ball_asset, (0, 0))
# Original image is too big. Scale it to 1/10 its original size
ball.scale = 0.1
# custom attributes
ball.dir = 1
ball.go = True

#Sounds
pew1_asset = SoundAsset("sounds/pew1.mp3")
pew1 = Sound(pew1_asset)
pop_asset = SoundAsset("sounds/reappear.mp3")
pop = Sound(pop_asset)


def reverse(b):
    b.dir *= -1
    
    # Set up function for handling screen refresh
def step():
    if ball.go:
コード例 #2
0
ファイル: tutorial3.py プロジェクト: voidJeff/ggame-tutorials
black = Color(0, 1)
noline = LineStyle(0, black)
bg_asset = RectangleAsset(SCREEN_WIDTH, SCREEN_HEIGHT, noline, brown)
cover_asset = RectangleAsset(600, 440, noline, green)
bg = Sprite(bg_asset, (0, 0))
cover = Sprite(cover_asset, (20, 20))

# A ball! This is already in the ggame-tutorials repository
ball_asset = ImageAsset("images/orb-150545_640.png")
beach_asset = ImageAsset("images/beach-ball-575425_640.png")
ball = Sprite(ball_asset, (0, 0))
beach = Sprite(beach_asset, (40, 40))
# Original image is too big. Scale it to 1/10 its original size
ball.scale = 0.1
# custom attributes
ball.dir = 1
ball.go = True
beach.scale = 0.1
beach.dir = 2
beach.go = True


def reverse(b):
    b.dir *= -1
    pop.play()


# Set up function for handling screen refresh
def step():
    if ball.go:
        ball.x += ball.dir
コード例 #3
0
green = Color(0x00ff00, 1)
blue = Color(0x2EFEF7, 1)
black = Color(0, 1)
noline = LineStyle(0, black)
bg_asset = RectangleAsset(SCREEN_WIDTH, SCREEN_HEIGHT, noline, green)
bg = Sprite(bg_asset, (0,0))



ball_asset = ImageAsset("images/orb-150545_640.png")
ball = Sprite(ball_asset, (0, 0))

ball.scale = 0.07
ball.y = 200

ball.dir = 0.76
ball.go = True

def reverse(b):
    b.dir *= -0.76
    pop.play()

def step():
    if ball.go:
        ball.x += ball.dir
        if ball.x + ball.width > SCREEN_WIDTH or ball.x < 0:
            ball.x -= ball.dir
            reverse(ball)

def spaceKey(event):
    ball.go = not ball.go
コード例 #4
0
    "images/four_spaceship_by_albertov_with_thrust.png",
    Frame(227, 0, 292 - 227, 125), 4, 'vertical')
asteroid_asset = ImageAsset("images/asteroid_for_program.png", )
asteroid1 = Sprite(asteroid_asset, (300, 300))
asteroid2 = Sprite(asteroid_asset, (1120, 300))
asteroid1.scale = .5
asteroid1.xmov = 10
asteroid1.ymov = 10
asteroid2.scale = .5
asteroid2.x2mov = -10
asteroid2.y2mov = -10

spaceship = Sprite(spaceship_asset, (740, 405))
spaceship.fxcenter = spaceship.fycenter = 0.5
# Movement
spaceship.dir = 3
spaceship.bob = 3
spaceship.go = False
spaceship.ygo = False
spaceship.thrust = 0
spaceship.thrustframe = 1


def reverse(b):
    b.dir *= -1
    b.bob *= -1


def astryturn1(b):
    asteroid1.ymov *= -1
コード例 #5
0
# A ball! This is already in the ggame-tutorials repository
ball_asset = ImageAsset("images/dog-png-29.png")
ball = Sprite(ball_asset, (0, 0))
# Sounds
pew1_asset = SoundAsset("sounds/pew1.mp3")
pew1 = Sound(pew1_asset)
pop_asset = SoundAsset("sounds/reappear.mp3")
pop = Sound(pop_asset)
dog1_asset = SoundAsset("sounds/dog-panting-breathing-fast-daniel_simon.mp3")
dog = Sound(dog1_asset)
bark_asset = SoundAsset("sounds/Dog_woof.mp3")
bark = Sound(bark_asset)
# Original image is too big. Scale it to 1/10 its original size
ball.scale = 0.3
# custom attributes
ball.dir = 1
ball.go = True
def reverse(b):
    b.dir *= -1
def step():
    if ball.go:
        ball.x += ball.dir
        if ball.x + ball.width > SCREEN_WIDTH or ball.x < 0:
            ball.x -= ball.dir
            reverse(ball)
# Handle the space key
def spaceKey(event):
    ball.go = not ball.go
    dog.play()

# Handle the "reverse" key