def __init__(self): Scene.__init__(self, SIZE) bg = spyral.Image(size=SIZE) bg.fill(BG_COLOR) self.background = bg font = spyral.Font(None, FONT_SIZE, FG_COLOR) self.title = TextSprite(self, font) self.title.anchor = 'center' self.title.pos = (SIZE[0] / 2, 30) self.title.render("N") self.block = Sprite(self) self.block.image = spyral.Image(size=(40, 40)) self.block.image.fill(FG_COLOR) self.block.y = 300 self.index = 0 self.set_animation() instructions = TextSprite(self, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("n: next example p: previous example q: quit") # Register all event handlers spyral.event.register('system.quit', spyral.director.quit) spyral.event.register('input.keyboard.down.p', self.previous) spyral.event.register('input.keyboard.down.n', self.next) spyral.event.register('input.keyboard.down.q', spyral.director.quit) spyral.event.register('input.keyboard.down.escape', spyral.director.quit)
def __init__(self): Scene.__init__(self) self.camera = self.parent_camera.make_child(SIZE) self.group = Group(self.camera) font = spyral.Font(None, FONT_SIZE, FG_COLOR) self.title = TextSprite(self.group, font) self.title.anchor = 'center' self.title.pos = (SIZE[0] / 2, 30) self.title.render("N") self.block = Sprite(self.group) self.block.image = spyral.Image(size=(40, 40)) self.block.image.fill(FG_COLOR) self.block.y = 300 self.index = 0 self.set_animation() instructions = TextSprite(self.group, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("n: next example p: previous example q: quit")
def set_face(self): #PET LOCATION (TOP LEFT HAND CORNER) PET_X = 230 PET_Y = 150 self.group.remove(self.cookie) self.bg = Sprite(self.group) self.bg.image = spyral.Image(size=(200, 200)) self.bg.image.fill(color=BG_COLOR) self.arms.image = spyral.Image( filename=ARMS[TYPES[self.t]][NOM_INDEX[self.nomIndex][2]]) self.recolor(COLOR_TAN, COLORS[self.i], ARMS_LAYER) self.arms.layer = ARMS_LAYER self.head.image = spyral.Image( filename=HEADS[TYPES[self.t]][NOM_INDEX[self.nomIndex][0]]) self.recolor(COLOR_TAN, COLORS[self.i], HEAD_LAYER) self.head.layer = HEAD_LAYER if self.t <= 1: self.face.image = spyral.Image(filename=CD_FACES[self.j]) elif self.t >= 2: self.face.image = spyral.Image(filename=DB_FACES[self.j]) self.face.layer = FACE_LAYER self.cookie = Sprite(self.group) self.cookie.image = spyral.Image(filename=COOKIES[self.eatIndex]) self.cookie.layer = COOKIE_LAYER self.cookie.x = COOKIE_POINTS[self.eatIndex][ self.cookieIndex][0] + PET_X self.cookie.y = COOKIE_POINTS[self.eatIndex][ self.cookieIndex][1] + PET_Y
class AnimationExamples(Scene): def __init__(self): Scene.__init__(self, SIZE) bg = spyral.Image(size=SIZE) bg.fill(BG_COLOR) self.background = bg font = spyral.Font(None, FONT_SIZE, FG_COLOR) self.title = TextSprite(self, font) self.title.anchor = 'center' self.title.pos = (SIZE[0] / 2, 30) self.title.render("N") self.block = Sprite(self) self.block.image = spyral.Image(size=(40,40)) self.block.image.fill(FG_COLOR) self.block.y = 300 self.index = 0 self.set_animation() instructions = TextSprite(self, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("n: next example p: previous example q: quit") # Register all event handlers self.register('system.quit', sys.exit) self.register('input.keyboard.down.p', self.previous) self.register('input.keyboard.down.n', self.next) self.register('input.keyboard.down.q', sys.exit) self.register('input.keyboard.down.escape', sys.exit) def set_animation(self): self.title.render(ANIMATIONS[self.index][0]) self.block.stop_all_animations() self.block.y = 300 # Reset the y-coordinate. a = ANIMATIONS[self.index][1] + DELAY a.loop = True self.block.animate(a) def next(self): self.index += 1 self.index %= len(ANIMATIONS) self.set_animation() def previous(self): self.index -= 1 self.index %= len(ANIMATIONS) self.set_animation()
class AnimationExamples(Scene): def __init__(self): Scene.__init__(self, SIZE) bg = spyral.Image(size=SIZE) bg.fill(BG_COLOR) self.background = bg font = spyral.Font(None, FONT_SIZE, FG_COLOR) self.title = TextSprite(self, font) self.title.anchor = 'center' self.title.pos = (SIZE[0] / 2, 30) self.title.render("N") self.block = Sprite(self) self.block.image = spyral.Image(size=(40, 40)) self.block.image.fill(FG_COLOR) self.block.y = 300 self.index = 0 self.set_animation() instructions = TextSprite(self, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("n: next example p: previous example q: quit") # Register all event handlers spyral.event.register('system.quit', spyral.director.quit) spyral.event.register('input.keyboard.down.p', self.previous) spyral.event.register('input.keyboard.down.n', self.next) spyral.event.register('input.keyboard.down.q', spyral.director.quit) spyral.event.register('input.keyboard.down.escape', spyral.director.quit) def set_animation(self): self.title.render(ANIMATIONS[self.index][0]) self.block.stop_all_animations() self.block.y = 300 # Reset the y-coordinate. a = ANIMATIONS[self.index][1] + DELAY a.loop = True self.block.animate(a) def next(self): self.index += 1 self.index %= len(ANIMATIONS) self.set_animation() def previous(self): self.index -= 1 self.index %= len(ANIMATIONS) self.set_animation()
def __init__(self): Scene.__init__(self) self.camera = self.parent_camera.make_child(SIZE) self.group = Group(self.camera) font = spyral.Font(None, FONT_SIZE, FG_COLOR) self.title = TextSprite(self.group, font) self.title.anchor = 'center' self.title.pos = (SIZE[0] / 2, 30) self.title.render("N") self.block = Sprite(self.group) self.block.image = spyral.Image(size=(40,40)) self.block.image.fill(FG_COLOR) self.block.y = 300 self.index = 0 self.set_animation() instructions = TextSprite(self.group, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("n: next example p: previous example q: quit")
def __init__(self): Scene.__init__(self, SIZE) bg = spyral.Image(size=SIZE) bg.fill(BG_COLOR) self.background = bg font = spyral.Font(None, FONT_SIZE, FG_COLOR) self.title = TextSprite(self, font) self.title.anchor = 'center' self.title.pos = (SIZE[0] / 2, 30) self.title.render("N") self.block = Sprite(self) self.block.image = spyral.Image(size=(40,40)) self.block.image.fill(FG_COLOR) self.block.y = 300 self.index = 0 self.set_animation() instructions = TextSprite(self, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("n: next example p: previous example q: quit") # Register all event handlers self.register('system.quit', sys.exit) self.register('input.keyboard.down.p', self.previous) self.register('input.keyboard.down.n', self.next) self.register('input.keyboard.down.q', sys.exit) self.register('input.keyboard.down.escape', sys.exit)
def __init__(self): Scene.__init__(self) self.camera = self.parent_camera.make_child(SIZE) self.group = spyral.Group(self.camera) self.font = pygame.font.SysFont(None, FONT_SIZE) self.head = Sprite(self.group) self.head.image = spyral.Image(filename=OVEN) self.head.x = 200 self.head.y = 100 instructions = TextSprite(self.group, self.font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("s: taste") self.heading = TextSprite(self.group, self.font) self.heading.anchor = 'midbottom' self.heading.x = 330 self.heading.y = 50 self.heading.render("BAKING")
class AnimationExamples(Scene): def __init__(self): Scene.__init__(self) self.camera = self.parent_camera.make_child(SIZE) self.group = Group(self.camera) font = spyral.Font(None, FONT_SIZE, FG_COLOR) self.title = TextSprite(self.group, font) self.title.anchor = 'center' self.title.pos = (SIZE[0] / 2, 30) self.title.render("N") self.block = Sprite(self.group) self.block.image = spyral.Image(size=(40, 40)) self.block.image.fill(FG_COLOR) self.block.y = 300 self.index = 0 self.set_animation() instructions = TextSprite(self.group, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("n: next example p: previous example q: quit") def on_enter(self): bg = spyral.Image(size=SIZE) bg.fill(BG_COLOR) self.camera.set_background(bg) def render(self): self.group.draw() def set_animation(self): self.title.render(ANIMATIONS[self.index][0]) self.block.stop_all_animations() self.block.y = 300 # Reset the y-coordinate. a = ANIMATIONS[self.index][1] + DELAY a.loop = True self.block.animate(a) def next(self): self.index += 1 self.index %= len(ANIMATIONS) self.set_animation() def previous(self): self.index -= 1 self.index %= len(ANIMATIONS) self.set_animation() def update(self, dt): for event in self.event_handler.get(): if event['type'] == 'QUIT': spyral.quit() sys.exit() if event['type'] == 'KEYDOWN': if event['ascii'] == 'p': self.previous() elif event['ascii'] == 'n': self.next() elif event['ascii'] == 'q': spyral.quit() sys.exit() self.group.update(dt)
def __init__(self, group, font): Sprite.__init__(self, group) self.font = font
def __init__(self): Scene.__init__(self) self.camera = self.parent_camera.make_child(SIZE) self.group = spyral.Group(self.camera) self.counter = 0 self.font = pygame.font.SysFont(None, FONT_SIZE) self.nomIndex = 0 self.cookieIndex = 0 self.eatIndex = 0 #PET LOCATION (TOP LEFT HAND CORNER) PET_X = 230 PET_Y = 150 self.j = 1 self.i = STUDENT_PET[0] # Color self.t = STUDENT_PET[1] # Type self.head = Sprite(self.group) self.head.image = spyral.Image( filename=HEADS[TYPES[self.t]][NOM_INDEX[self.nomIndex][0]]) self.head.layer = HEAD_LAYER self.head.x = PET_POINTS[1][0] + PET_X self.head.y = PET_POINTS[1][1] + PET_Y self.arms = Sprite(self.group) self.arms.image = spyral.Image( filename=ARMS[TYPES[self.t]][NOM_INDEX[self.nomIndex][2]]) self.arms.layer = ARMS_LAYER self.arms.x = PET_POINTS[3][0] + PET_X self.arms.y = PET_POINTS[3][1] + PET_Y self.face = Sprite(self.group) if self.t <= 1: self.face.image = spyral.Image(filename=CD_FACES[self.j]) elif self.t >= 2: self.face.image = spyral.Image(filename=DB_FACES[self.j]) self.face.layer = FACE_LAYER self.face.x = PET_POINTS[2][0] + PET_X self.face.y = PET_POINTS[2][1] + PET_Y self.cookie = Sprite(self.group) self.cookie.image = spyral.Image(filename=COOKIES[self.cookieIndex]) self.cookie.layer = COOKIE_LAYER self.cookie.x = COOKIE_POINTS[self.eatIndex][ self.cookieIndex][0] + PET_X self.cookie.y = COOKIE_POINTS[self.eatIndex][ self.cookieIndex][1] + PET_Y self.set_color() instructions = TextSprite(self.group, self.font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("s: quit") self.heading = TextSprite(self.group, self.font) self.heading.anchor = 'midbottom' self.heading.x = 320 self.heading.y = 50 self.heading.render("TASTING")
def __init__(self): Scene.__init__(self) self.camera = self.parent_camera.make_child(SIZE) self.group = spyral.Group(self.camera) font = pygame.font.SysFont(None, FONT_SIZE) #BEGIN MONEY MATRIX self.M00 = Sprite(self.group) self.M00.image = spyral.Image(filename=MONIES[1]) self.M00.layer = 1 self.M00.x = MONEY_POINTS[0][0] self.M00.y = MONEY_POINTS[0][1] self.M10 = Sprite(self.group) self.M10.image = spyral.Image(filename=MONIES[2]) self.M10.layer = 1 self.M10.x = MONEY_POINTS[1][0] self.M10.y = MONEY_POINTS[1][1] self.M20 = Sprite(self.group) self.M20.image = spyral.Image(filename=MONIES[3]) self.M20.layer = 1 self.M20.x = MONEY_POINTS[2][0] self.M20.y = MONEY_POINTS[2][1] self.M01 = Sprite(self.group) self.M01.image = spyral.Image(filename=MONIES[4]) self.M01.layer = 1 self.M01.x = MONEY_POINTS[3][0] self.M01.y = MONEY_POINTS[3][1] self.M11 = Sprite(self.group) self.M11.image = spyral.Image(filename=MONIES[0]) self.M11.layer = 1 self.M11.x = MONEY_POINTS[4][0] self.M11.y = MONEY_POINTS[4][1] self.M21 = Sprite(self.group) self.M21.image = spyral.Image(filename=MONIES[1]) self.M21.layer = 1 self.M21.x = MONEY_POINTS[5][0] self.M21.y = MONEY_POINTS[5][1] self.M02 = Sprite(self.group) self.M02.image = spyral.Image(filename=MONIES[2]) self.M02.layer = 1 self.M02.x = MONEY_POINTS[6][0] self.M02.y = MONEY_POINTS[6][1] self.M12 = Sprite(self.group) self.M12.image = spyral.Image(filename=MONIES[3]) self.M12.layer = 1 self.M12.x = MONEY_POINTS[7][0] self.M12.y = MONEY_POINTS[7][1] self.M22 = Sprite(self.group) self.M22.image = spyral.Image(filename=MONIES[4]) self.M22.layer = 1 self.M22.x = MONEY_POINTS[8][0] self.M22.y = MONEY_POINTS[8][1] #END MONEY MATRIX self.i = STUDENT_PET[0] # Color self.t = STUDENT_PET[1] # Type #PET LOCATION (TOP LEFT HAND CORNER) PET_X = 430 PET_Y = 200 self.head = Sprite(self.group) self.head.image = spyral.Image(filename=HEADS[TYPES[self.t]][0]) self.head.layer = HEAD_LAYER self.head.x = PET_POINTS[1][0] + PET_X self.head.y = PET_POINTS[1][1] + PET_Y self.body = Sprite(self.group) self.body.image = spyral.Image(filename=BODIES[TYPES[self.t]][0]) self.body.layer = BODY_LAYER self.body.x = PET_POINTS[8][0] + PET_X self.body.y = PET_POINTS[8][1] + PET_Y self.arms = Sprite(self.group) self.arms.image = spyral.Image(filename=ARMS[TYPES[self.t]][0]) self.arms.layer = ARMS_LAYER self.arms.x = PET_POINTS[3][0] + PET_X self.arms.y = PET_POINTS[3][1] + PET_Y self.legs = Sprite(self.group) self.legs.image = spyral.Image(filename=LEGS[TYPES[self.t]][0]) self.legs.layer = LEGS_LAYER self.legs.x = PET_POINTS[5][0] + PET_X self.legs.y = PET_POINTS[5][1] + PET_Y self.tail = Sprite(self.group) self.tail.image = spyral.Image(filename=TAILS[TYPES[self.t]][0]) self.tail.layer = TAIL_LAYER self.tail.x = PET_POINTS[9][0] + PET_X self.tail.y = PET_POINTS[9][1] + PET_Y self.j = 1 self.face = Sprite(self.group) if self.t <= 1: self.face.image = spyral.Image(filename=CD_FACES[self.j]) elif self.t >= 2: self.face.image = spyral.Image(filename=DB_FACES[self.j]) self.face.layer = FACE_LAYER self.face.x = PET_POINTS[2][0] + PET_X self.face.y = PET_POINTS[2][1] + PET_Y self.p = 0 self.pointer = Sprite(self.group) self.pointer.image = spyral.Image(filename=POINTER) self.pointer.layer = 2 self.pointer.x = POINTER_POINTS[self.p][0] self.pointer.y = POINTER_POINTS[self.p][1] self.set_pointer() self.set_face() self.set_color() #self.set_type() instructions = TextSprite(self.group, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("MAIN MENU (p: pick s: select)") self.qbutton = Sprite(self.group) self.qbutton.image = spyral.Image(size=(150, 50)) self.qbutton.image.fill(color=(0, 0, 0)) self.qbutton.x = 430 self.qbutton.y = 60 self.qbutton.layer = 0 quitbutton = TextSprite(self.group, font) quitbutton.anchor = 'midbottom' quitbutton.x = 480 quitbutton.y = 100 quitbutton.render("QUIT")
def __init__(self): Scene.__init__(self) self.camera = self.parent_camera.make_child(SIZE) self.group = spyral.Group(self.camera) font = pygame.font.SysFont(None, FONT_SIZE) self.t = 0 #PET LOCATION (TOP LEFT HAND CORNER) PET_X = 230 PET_Y = 200 self.head = Sprite(self.group) self.head.image = spyral.Image(filename=HEADS[TYPES[self.t]][0]) self.head.layer = HEAD_LAYER self.head.x = PET_POINTS[1][0] + PET_X self.head.y = PET_POINTS[1][1] + PET_Y self.body = Sprite(self.group) self.body.image = spyral.Image(filename=BODIES[TYPES[self.t]][0]) self.body.layer = BODY_LAYER self.body.x = PET_POINTS[8][0] + PET_X self.body.y = PET_POINTS[8][1] + PET_Y self.arms = Sprite(self.group) self.arms.image = spyral.Image(filename=ARMS[TYPES[self.t]][0]) self.arms.layer = ARMS_LAYER self.arms.x = PET_POINTS[3][0] + PET_X self.arms.y = PET_POINTS[3][1] + PET_Y self.legs = Sprite(self.group) self.legs.image = spyral.Image(filename=LEGS[TYPES[self.t]][0]) self.legs.layer = LEGS_LAYER self.legs.x = PET_POINTS[5][0] + PET_X self.legs.y = PET_POINTS[5][1] + PET_Y self.tail = Sprite(self.group) self.tail.image = spyral.Image(filename=TAILS[TYPES[self.t]][0]) self.tail.layer = TAIL_LAYER self.tail.x = PET_POINTS[9][0] + PET_X self.tail.y = PET_POINTS[9][1] + PET_Y self.j = 1 self.face = Sprite(self.group) if self.t <= 1: self.face.image = spyral.Image(filename=CD_FACES[self.j]) elif self.t >= 2: self.face.image = spyral.Image(filename=DB_FACES[self.j]) self.face.layer = FACE_LAYER self.face.x = PET_POINTS[2][0] + PET_X self.face.y = PET_POINTS[2][1] + PET_Y self.i = 0 self.set_face() self.set_color() self.set_type() instructions = TextSprite(self.group, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("i: color j: emote t: type s: select") heading = TextSprite(self.group, font) heading.anchor = 'midbottom' heading.x = 320 heading.y = 70 heading.render("CHESTER PETS")
class AnimationExamples(Scene): def __init__(self): Scene.__init__(self) self.camera = self.parent_camera.make_child(SIZE) self.group = Group(self.camera) font = spyral.Font(None, FONT_SIZE, FG_COLOR) self.title = TextSprite(self.group, font) self.title.anchor = 'center' self.title.pos = (SIZE[0] / 2, 30) self.title.render("N") self.block = Sprite(self.group) self.block.image = spyral.Image(size=(40,40)) self.block.image.fill(FG_COLOR) self.block.y = 300 self.index = 0 self.set_animation() instructions = TextSprite(self.group, font) instructions.anchor = 'midbottom' instructions.x = 320 instructions.y = 470 instructions.render("n: next example p: previous example q: quit") def on_enter(self): bg = spyral.Image(size=SIZE) bg.fill(BG_COLOR) self.camera.set_background(bg) def render(self): self.group.draw() def set_animation(self): self.title.render(ANIMATIONS[self.index][0]) self.block.stop_all_animations() self.block.y = 300 # Reset the y-coordinate. a = ANIMATIONS[self.index][1] + DELAY a.loop = True self.block.animate(a) def next(self): self.index += 1 self.index %= len(ANIMATIONS) self.set_animation() def previous(self): self.index -= 1 self.index %= len(ANIMATIONS) self.set_animation() def update(self, dt): for event in self.event_handler.get(): if event['type'] == 'QUIT': spyral.quit() sys.exit() if event['type'] == 'KEYDOWN': if event['ascii'] == 'p': self.previous() elif event['ascii'] == 'n': self.next() elif event['ascii'] == 'q': spyral.quit() sys.exit() self.group.update(dt)
def change (self): self.image.fill(color=BG_COLOR) self.layer=0 Sprite.__del__(self)
def erase (self): Sprite.__del__(self)
def __init__(self, scene, font): Sprite.__init__(self, scene) self.font = font
def change(self): self.image.fill(color=BG_COLOR) self.layer = 0 Sprite.__del__(self)
def erase(self): Sprite.__del__(self)