import sys, os
import pygame
from pygame.locals import *
from cgkit.cgtypes import vec3
def load_image(name
fullname = os.path.dirname
fullname = os.path.join(fu
fullname = os.path.join(fu
try:
image = pygame.image.lo
except pygame.error, message:
print 'Cannot load image:', fullname
raise SystemExit, message
image = image.convert()
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0
image.set_color
return image
class Spritesheet:
def __init__(self, filename):
self.sheet = pygame.image.lo
def imgat(self, rect, colorkey = None):
rect = Rect(rect)
image = pygame.Surface(
image.blit(self
if colorkey is not None:
if colorkey is -1:
colorkey = image.get_at((0
image.set_color
return image
def imgsat(self, rects, colorkey = None):
imgs = []
for rect in rects:
imgs.append(sel
return imgs
class AnimatedSprite:
def __init__(self, images, rect):
self.images = images
class Dragon:
def __init__(self):
self.surface = load_image("Dra
self.pos = vec3(0,0,0)
def main():
pygame.init()
screen = pygame.display.
pygame.display.
fnt = pygame.font.Fon
back = pygame.Surface(
back = back.convert()
back.fill((200,
keys = {K_a:False,K_d:
dragon = Dragon();
while True:
for event in pygame.event.ge
if event.type == QUIT:
sys.exit(0)
elif event.type == KEYDOWN:
keys[event.key] = True
elif event.type == KEYUP:
keys[event.key] = False
if keys[K_a]:
dragon.pos.x -= 1
if keys[K_d]:
dragon.pos.x += 1
if keys[K_w]:
dragon.pos.y -= 1
if keys[K_s]
code to load images, and pull images off of a sprite sheet
and it moves a dragon around on the screen
Sent at 4:58 PM on Tuesday
me: sweet
haha
Sent at 5:15 PM on Tuesday
me: meh
took me a while because i haven't actually opened Flash before
but i have a little placeholder
do you need transparency in the image?
it's a bmp right now
Sent at 5:30 PM on Tuesday
Thomas's new status message - I'm not here right now 5:36 PM
Thomas: I can do transparency on bitmaps now
didnt you read the code!
Sent at 5:55 PM on Tuesday
me: nope
haha
sorry
i will now
though
hang on
1 comment:
By the gods, not Pygame!
Post a Comment