def dispatch(self, message, game): """Function for determining what action to call depending on the message""" width, height = pygame.display.get_surface().get_size() if message.mtype == "message": # Set hovered object from a slot text, colour = message.args surface = draw_text(text, self.message_font, colour) animation = anime.Anime(surface, width // 2, 500) animation.set_filter('y', anime.filter.linear, 2) animation.set_filter('opacity', anime.filter.linear, 5) animation.y = 400 animation.opacity = 0 self.animations.append(animation) elif message.mtype == "battle-message": target, text, colour = message.args x = random.randint(-20, 20) y = random.randint(-20, 20) if target in game.party.players: index = game.party.players.index(target) x = x + 156 + 312 * index y = y + height - 100 elif game.encounter and target in game.encounter: index = game.encounter.index(target) num_enemies = len(game.encounter) x = x + width // (num_enemies + 1) * (index + 1) y = y + 200 surface = draw_text(text, self.battle_font, colour) animation = anime.Anime(surface, x, y) animation.set_filter('y', anime.filter.linear, 1) animation.set_filter('opacity', anime.filter.linear, 4) animation.y = y - 100 animation.opacity = 0 self.animations.append(animation)
def register_image(self, image, x, y, layer): """Create an image to keep track of.""" resource = {"layer": layer} resource["image"] = pygame.image.load(resource_filename( Requirement.parse('starlight'), image)) resource["anime"] = anime.Anime(resource["image"], x, y) self.images.append(resource) return resource["anime"]
def anime(self, anime_id): """Creates an instance of myanimelist.Anime with the given ID. :type anime_id: int :param anime_id: The desired anime's ID. :rtype: :class:`myanimelist.anime.Anime` :return: A new Anime instance with the given ID. """ return anime.Anime(self, anime_id)
def from_database_query(cls, result): """Creates an Anisong from db query result""" obj = cls() obj.anime = anime.Anime(result.anime, season=result.season) obj.type = result.type obj.number = str(result.number) obj.title = result.title obj.artist = result.artist obj.used_in_eps = result.used_in_eps obj.status = result.status obj.database_obj = result return obj
x = lambda t: math.sin(t) * (math.e**math.cos(t) - 2 * math.cos(4 * t) - math. sin(t / 12)**5) y = lambda t: math.cos(t) * (math.e**math.cos(t) - 2 * math.cos(4 * t) - math. sin(t / 12)**5) s = lambda phi: phi * 0.5 main_dir = os.path.split(os.path.abspath(__file__))[0] file = os.path.join(main_dir, 'images', 'image1.png') screen = pygame.display.set_mode((800, 600)) surf = pygame.image.load(file).convert_alpha() path = Parametric2D(x, y) spiral = Polar(s) pixels = deque(maxlen=MAX) a = anime.Anime(surf, 0, 0) a.set_renderer('w_ratio', anime.renderer.wratio_smooth_renderer) a.set_renderer('h_ratio', anime.renderer.hratio_smooth_renderer) a.w_ratio = 0.2 a.h_ratio = 0.2 playing = True counter = 0 def draw_pixel(pixel): pygame.gfxdraw.pixel(screen, round(pixel[0]), round(pixel[1]), (255, 255, 255)) while playing:
import pygame import anime import random pygame.init() screen = pygame.display.set_mode((800, 600)) test_surface = pygame.Surface((300, 300), pygame.SRCALPHA) test_surface2 = pygame.Surface((100, 100), pygame.SRCALPHA) test_surface.fill((0, 0, 0, 255)) test_surface2.fill((255, 0, 0, 255)) a = anime.Anime(test_surface, 400, 300) b = anime.Anime(test_surface2, 150, 150) a.set_filter('w_ratio', anime.filter.spring) a.set_filter('h_ratio', anime.filter.spring) a.set_filter('opacity', anime.filter.linear, 5) b.set_owner(a) counter = 2 other = 0 playing = True while playing: mx, my = pygame.mouse.get_pos() for e in pygame.event.get(): if e.type == pygame.QUIT: playing = False if e.type == pygame.MOUSEBUTTONDOWN: if b.collide_point(mx, my): counter = 4 if counter%4 else 2 if counter == 2: a.width = 200
import pygame import anime import random pygame.init() screen = pygame.display.set_mode((800, 600)) surfs = [pygame.Surface((100, 100), pygame.SRCALPHA) for i in range(9)] for s in surfs: s.fill((random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) animes = [anime.Anime(s, 0, 0) for s in surfs] for a in animes: a.set_filter('x', anime.filter.Spring(0.2, 0.6)) a.set_filter('y', anime.filter.Spring(0.2, 0.6)) playing = True offsetx = 0 offsety = 0 on_hand = None while playing: mx, my = pygame.mouse.get_pos() for e in pygame.event.get(): if e.type == pygame.QUIT: playing = False if e.type == pygame.MOUSEBUTTONDOWN: for a in animes: if a.collide_point(mx, my): animes.remove(a)
import pygame import anime import math from random import randint pygame.init() screen = pygame.display.set_mode((800, 600)) test_surface = pygame.Surface((50, 50), pygame.SRCALPHA) test_surface.fill((0, 0, 0, 255)) a = anime.Anime(test_surface, 400, 300) a.set_filter('x', anime.filter.exponential) a.set_filter('y', anime.filter.exponential) animes = [ anime.Anime(test_surface, randint(0, 800), randint(0, 600)) for i in range(200) ] playing = True holding = False while playing: mx, my = pygame.mouse.get_pos() for e in pygame.event.get(): if e.type == pygame.QUIT: playing = False elif e.type == pygame.MOUSEBUTTONDOWN: holding = True
#imports import anime import fresh_tomatoes #Instances of Anime class naruto = anime.Anime( "Naruto", "Action fiction, Adventure fiction, Fantasy", "http://img01.deviantart.net/22f9/i/2015/103/7/d/naruto_poster_by_youaraja-d8juwxp.jpg", #noqa "https://www.youtube.com/watch?v=mksl3tYdyK4") death_note = anime.Anime( "Death Note", "Thriller,Mystery,Horror,Fantasy", "http://assets-cf.gbeye.com/thumbnails/lightbox_100332_1456795786.jpg", #noqa "https://www.youtube.com/watch?v=HK3lkfhX_XY") code_geass = anime.Anime( "Code Geass", "Mecha Anime, Visual novel", "https://animexuniverse.files.wordpress.com/2014/09/1797842746.jpg", #noqa "https://www.youtube.com/watch?v=v-AGjx0N24U") sword_art = anime.Anime( "Sword Art Online", "Action fiction, Adventure, Science Fiction", "http://vignette2.wikia.nocookie.net/enanimanga/images/2/25/Sword-art-online-poster.jpg/revision/latest?cb=20120716181655", #noqa "https://www.youtube.com/watch?v=VNxxReVeVDI") shokugeki = anime.Anime( "shokugeki no soma", "Action, Food War, Adventure", "http://data.asiastarz.com/data/thumbs/full/13916/600/0/0/0/poster-for-shokugeki-no-soma-season-2.jpg", #noqa "https://www.youtube.com/watch?v=NBWwdXZyPEU") Pokemon = anime.Anime(
import pygame import anime import random import math import os pygame.init() screen = pygame.display.set_mode((800, 600)) main_dir = os.path.split(os.path.abspath(__file__))[0] file = os.path.join(main_dir, 'images', 'image1.png') surf = pygame.image.load(file).convert_alpha() a = anime.Anime(surf, 400, 300) a.set_renderer('w_ratio', anime.renderer.wratio_smooth_renderer) a.set_renderer('h_ratio', anime.renderer.hratio_smooth_renderer) holding = False mouse_down = False resetting = False playing = True offsetx = 0 offsety = 0 while playing: mx, my = pygame.mouse.get_pos() for e in pygame.event.get(): if e.type == pygame.QUIT: playing = False elif e.type == pygame.MOUSEBUTTONDOWN: mouse_down = True offsetx, offsety = mx, my if a.collide_point_alpha(mx, my, 0):