Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #created by Kris Occhipinti (AKA Metalx1000)
- #http://filmsbykris.com
- #Oct. 16th 2010
- #GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
- import pygame, sys
- from pygame.locals import *
- pygame.init()
- screen = pygame.display.set_mode((600,400))
- image = pygame.image.load("tux.png")
- tux = pygame.transform.scale(image, (64,64))
- clock = pygame.time.Clock()
- gravity = 10
- x = -100
- y = 300
- yr = 0
- yl = 0
- speed = 4
- force = 0
- jmp = 0
- def jump():
- global x,y,force
- if force > 0:
- x -= force
- force -= 1
- def move_right():
- global y,speed
- y += speed
- def move_left():
- global y,speed
- y -= speed
- while 1:
- clock.tick(60)
- x+=gravity
- screen.fill((0,0,0))
- screen.blit(tux,(y,x))
- pygame.display.update()
- if x > 400-64:
- x = 400-64
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- sys.exit()
- elif event.type == KEYDOWN and event.key == K_ESCAPE:
- sys.exit()
- elif event.type == KEYDOWN and event.key == K_SPACE:
- force = 25
- elif event.type == KEYDOWN and event.key == K_RIGHT:
- yr = 1
- elif event.type == KEYUP and event.key == K_RIGHT:
- yr = 0
- elif event.type == KEYDOWN and event.key == K_LEFT:
- yl = 1
- elif event.type == KEYUP and event.key == K_LEFT:
- yl = 0
- jump()
- if yr == 1:
- move_right()
- if yl == 1:
- move_left()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement