def main(): # Load image img = myimage("images/fly.png") img.display() img.display_lines() #Load characters char_list = [] for i in range(32, 127): if i != 96 and i != 126 and i != 39 and i != 46 and i != 44 and i != 34 and i != 64: char = character(i) #char.points = calculate_points(char.get_img()) char_list.append(char) #Gets the resolution of one of the characters(they are all the same) chr_height, chr_width = char.size() #Calculates the split image, its a list matrix with every block of the image blocks, blocks_per_row = img.split_up(chr_height, chr_width) blocks, every_block_lines = get_line_blocks(blocks) #Gets the best characters best_characters = get_best_characters(blocks, every_block_lines, char_list, blocks_per_row) #best_characters = get_best_characters(blocks, char_list) write_characters("output.txt", best_characters, blocks_per_row) #Transform a matrix of blocks into an image character_img = characters_to_image(best_characters, blocks_per_row) cv2.imshow('Image', character_img) cv2.waitKey(0) cv2.destroyAllWindows()
def update(self, tora, Camera, treasures, collectedTreasure, collectedTreasures, bigChest): global tempcollectedtreasures global score if tora.x + tora.width >= self.x and tora.x <= self.x + self.width and tora.y + tora.height + Camera.y >= self.y and tora.y + Camera.y <= self.y + self.height: if self.type == "bigTreasure": tora.bigTreasure = True treasures.remove(self) chest = loadImage("treasure.png") bigChest.currentimage = chest if self.type == "smallTreasure": treasures.remove(self) collectedTreasure.append( character( (tempcollectedtreasures % 2) * 65 + 569, (tempcollectedtreasures - tempcollectedtreasures % 2) * 18 + 266, 32, 32, "treasure.png", "blank")) collectedTreasures += 1 tempcollectedtreasures += collectedTreasures collectedTreasure[tempcollectedtreasures - 1].setup() print("item!") if self.type == "gems": treasures.remove(self) collectedTreasures += 1 collectedTreasure.append(1) score += 100 return tempcollectedtreasures
def save(self, connection): charac = character(self.nameInput.text(), self.classInput.currentText(), self.raceInput.currentText(), self.backgroundInput.currentText(), self.levelInput.text(), "2", "1") print(charac.name) charac.saveCharacter(connection.cursor()) connection.commit()
import character characters = [] char_data = open("char_data.txt","r") def get_got_followers(char = "GoT"): print "Doing twitter analysis on",char url = "https://twitter.com/search?f=users&q=" account_url="https://twitter.com" soup = BeautifulSoup(requests.get(url+char.replace(" ","%20")).content,"html.parser") results = soup.find_all("div",{"class":"ProfileCard js-actionable-user"}) followers = 0 handle = "" for res in results: handle = res.a['href'].encode("utf-8") print handle another_soup = BeautifulSoup(requests.get(account_url+handle).content,"html.parser") val = another_soup.find("span",{"class":"ProfileNav-value"}) if "K" in str(val): followers+=int(float(str(val.contents[0].split("K")[0])))*1000 print handle,followers else: followers+=int(str(val.contents[0].replace(",",""))) print handle,followers print char,":",followers got_followers = get_got_followers() for line in char_data: char = character(line,got_followers) print char.get_formatted_name()
import pygame as pg import sys import numpy as np from random import choice from dictionnaires import * from character2 import * from character import * perso = character(100, [], [], 100) pg.init() screen = pg.display.set_mode((1000, 700)) screen.fill((0, 0, 0)) clock = pg.time.Clock() font = pg.font.Font('freesansbold.ttf', 20) with open('map_finale.txt', 'r') as file: list_map = [] list_interactions = [] for line in file: list_map.append([x for x in line if x != '\n']) list_interactions.append([0 for x in line if x != '\n']) n = len(list_map) liste_endroits_possibles = [] liste_endroits_possibles_monstres = [] for i in range(n): for j in range(len(list_map[i])): if list_map[i][j] == ".": liste_endroits_possibles.append((i, j))
import pygame as pg import sys import numpy as np from random import choice, randint import os from dictionnaires import * from character2 import * from character import * pg.init() screen = pg.display.set_mode((1000, 700)) screen.fill((0, 0, 0)) clock = pg.time.Clock() perso = character(100, [], {}, 100) perso.name = "Ralf le Rouge" font = pg.font.Font('freesansbold.ttf', 20) levels = os.listdir("levels") running = True while running: clock.tick(10) nb_level = 0 while levels != [] and running: nb_level += 1 what_it_replaces = '.' with open("levels/" + levels[0], 'r') as file: list_map = [] list_interactions = []
cnt = -1 itemcnt = 0 charitem = 0 finishtime = 130 skill = 5 char = 0 track = mixer.Sound(sound_file) urgent = mixer.Sound(urgent_file) effect = mixer.Sound(bomb_file) timecnt = 0 if cnt == -1: cnt = Game_Start() ##첫화면 char = character() ##캐릭터선택화면 clock = pygame.time.Clock() class App: ## 화면크기설정 windowWidth = 700 windowHeight = 600 player = 0 def setname(self, name): self.name = name def __init__(self):
import numpy as np from random import choice, randint import os from dictionnaires import * from character2 import * from character import * pg.init() screen = pg.display.set_mode((1000, 700)) screen.fill((0, 0, 0)) clock = pg.time.Clock() perso = character(100, [], { 'casque': '', 'armure': '', 'arme': '', 'bouclier': '', 'anneau': '' }, 100) perso.name = "Ralf le Rouge" font = pg.font.Font('freesansbold.ttf', 20) levels = os.listdir("levels") running = True while running: clock.tick(15) nb_level = 0 while levels != [] and running: nb_level += 1 what_it_replaces = '.'
''' Created on Jan 11, 2016 @author: eduardo.torres ''' from character import * import time import random from distutils.tests.test_register import RawInputs print "Welcome to the game" print "Please choose your class (hero, not-hero, derp)" hero = character() while hero.type == None: Class = raw_input("Pick one?") if Class == 'hero': hero.type = "hero" print "gg buddy" elif Class == 'not-hero': hero.type = "not-hero" elif Class == 'derp': hero.type = "derp" else: print "You done goofed. Try again"
screen = pygame.display.set_mode((screen_width ,screen_height)) pygame.display.set_caption('LuckyGoGO') #load element bg = pygame.image.load('Ex/bg.jpg') char = [pygame.image.load('Ex/'+str(t)+'.png') for t in range(5,13)] tp = pygame.image.load('Ex/trap.png').convert() tp.set_colorkey((255 ,255 ,255)) #Sound effect hit_sound = pygame.mixer.Sound('Ex/hit.wav') pygame.mixer.music.load('Ex/music.mp3') pygame.mixer.music.play(-1) man = character(char ,250 ,600 ,64 ,64) traps = [] clock = pygame.time.Clock() bx = 0 bx1 = 1024 def renew(): global bx ,bx1,bones screen.blit(bg ,(bx ,0)) screen.blit(bg ,(bx1,0)) for bone in bones: screen.blit(bone ,(bones.index(bone) * 100 + 20 ,20)) for t in traps: t.action(screen)
def setUp(self): self.hero = character() self.opponent = character() self.modifier = {1:-5, 2:-4, 3:-4, 4:-3, 5:-3, 6:-2, 7:-2, 8:-1, 9:-1, 10:0, 11:0, 12:1, 13:1, 14:2, 15:3, 16:3, 17:3, 18:4, 19:4, 20:5}
from character import * from ennemy import * from romainFunctions import * from constantFight import * import functions as f import random personnage = character() windowInitialisation(personnage) #La fontion combat est celle appellé pour le déroulement d'un combat et des actions def combat() : player = f.player while f.player.life : #Tant que le personnage est en vie if ennemy.listEnnemy.count(0) == len(ennemy.listEnnemy) : #Si le nombre de 0 dans la liste vaut la taille de la liste victory() #Cela signifie que tous les ennemis sont morts break #On redessine l'écran pour être sur que tout soit à jour redrawBoard(player) pygame.display.flip #Pour chaque ennemi, on lui permet d'attaquer au prochain tour, et on descend son compteur d'action si il est utilisé for mechant in ennemy.listEnnemy : if type(mechant) == ennemy : mechant.apparition = True if mechant.count != 0 : mechant.count -= 1
}, "equipment": { "járn öxi": { "value": 12, "verd": 1200, "tegund": "vopn" }, "járn brynja": { "value": 12, "verd": 750, "tegund": "brynja" } } }, ] spilari = character(nafn, kyn) while True: if len(ovinir) <= 0: print("ÞÚ VANNST") break print(spilari) print() print("1. Halda áfram\n" "2. Fara í búð\n" "3. Birgðir\n" "4. Sofa(15 gull)") valmynd = input(">> ") print() # Bardagi if valmynd == "1":
from character import * from artifact import * xiao = character('xiao') xiao.elementType = Element.Anemo xiao.print() art1 = artifact("Viridescent Arrow Feather") art1.print()