def create(cls, name): if name == 'Mouse': return Mouse() elif name == 'Dragon': return Dragon() elif name == 'Snake': return Snake() else: return None
def test_dragons_eat_a_lot(): """If a dragon eats more than 3 times, it will no longer be hungry.""" regina = Dragon('Regina', 'Red', 'Rachel') assert regina.is_hungry() is True regina.eat() regina.eat() regina.eat() assert regina.is_hungry() is True regina.eat() assert regina.is_hungry() is False
def init_scene(self): self.add_entity(Sky(0, 0, self)) self.add_entity(Floor(0, 0, self)) self.generate_beams() self.generate_coins() self.generate_magnets() self.add_entity(Dragon(10, 450, self)) self.__mando = Mando(10, 0, self) self.add_entity(self.__mando)
def main(): sock = Dragon(CLIENT, CPORT) # generator = Generator() fake_frame = bytearray(614400) sock.bind(('', 6000)) sock.send(fake_frame) open("dragon_send_frame","wb").write(fake_frame) print(f"CLEAN") time.sleep(3) sock.close()
def run_game(): #Initialization of game and creation of object = screen pygame.init() ai_settings = Settings() screen = pygame.display.set_mode( (ai_settings.screen_width, ai_settings.screen_height)) screen_rect = screen.get_rect() pygame.display.set_caption("DraGame") #Creating button Game play_button = Button(ai_settings, screen, "Play Game") #Creating an object to capture statistical data stats = GameStats(ai_settings) #Creating a scoreboard points_txt = str(ai_settings.points) dragons_left_txt = str(stats.dragons_left) score_board = Score(ai_settings, screen, "lifes: " + dragons_left_txt, "Score: " + points_txt) #Creating the dragon. dragon = Dragon(ai_settings, screen) #Creating a group dedicated to store fireballs fireballs = Group() #creating a freezers group freezers = Group() #Starting the main loop of the game. while True: gf.check_events(ai_settings, screen, stats, play_button, dragon, fireballs) points_txt = str(ai_settings.points) dragons_left_txt = str(stats.dragons_left) if stats.game_active: dragon.update() time_1 = pygame.time.get_ticks() time_2 = int(time_1 / 10) if time_2 % 100 in range(0, 3): new_freezer = Freezer(ai_settings, screen) freezers.add(new_freezer) gf.update_freezers(ai_settings, stats, screen, dragon, freezers, fireballs, score_board) gf.update_fireballs(ai_settings, screen, dragon, freezers, fireballs) gf.update_screen(ai_settings, screen, stats, dragon, freezers, fireballs, play_button, score_board)
def createSoldiers(self, typeSoldiers, nSoldiers, dragonType=None): soldiers = [] for _ in range(nSoldiers): if typeSoldiers == Soldier.ARCHER: soldier = Archer() elif typeSoldiers == Soldier.DRAGON: soldier = Dragon(dragonType) elif typeSoldiers == Soldier.HUMAN_SOLDIER: soldier = HumanSoldier() elif typeSoldiers == Soldier.UNDEAD_SOLDIER: soldier = UndeadSoldier() else: soldier = None soldiers.append(soldier) return soldiers
def __init__(self): pygame.init() pygame.display.set_caption('Dungeon and Dragons') self.settings = Settings() self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height)) self.stats = GameStats(self) # Создание экземпляра для хранения игровой статистики self.hero = Hero(self) self.dragon = Dragon(self) self.fireballs = pygame.sprite.Group() self.snowballs = pygame.sprite.Group() self.crystals = pygame.sprite.Group() self.dragons = pygame.sprite.Group() self._create_crystals() # TODO Сделать так, чтобы повялялись новые кристаллы когда все пять фаерболов будет # выпущено в дракона # Создание кнопки Play self.play_button = Button(self, 'Play') self.scoreboard = Scoreboard(self)
def main(): sock = Dragon(SERVER, 6000) sock.bind(('', 7000)) data = b'' while True: try: tmp = sock.recv(1500) except KeyboardInterrupt: open("dragon_recv_frame", "wb").write(data) break if not tmp: break data += tmp # sock.send(b'Hello world!') sock.close()
is_bullet = False st = 0 st0 = st bullets = [] previous_time = 0 dragon_came = False KB = KBHit() time_for_fire = time.time() ccc = 1 ttt = 1 fir = 1 mando = Mando(i, j, 150) board = Board(55, 200, magnetss) # adjusting using the current screen size mando.add_to_board(board, st, st0, dragon_came) board.printboard(st, dragon_came) dragon = Dragon(41, 155) dragon_finished = False dragon_bullets = [] cursor_hide() while True: for cor in magnetss: for i in range(0, 3): for j in range(0, 3): board.set_grid(cor[0] + i, cor[1] + j, '#') if dragon_came: dragon.remove_from_board(board, st) dragon.chase(mando) if time.time() - time_for_fire >= 2 or ccc == 1: time_for_fire = time.time() dragon_bullet = dragon.fire()
time_diff = 0.10 change_time = 0 time_of_change = time.time() make_fast = 0 shield_cooloff_time = 0 shield_remaining_time = 0 prev_shield_time = 0 gun_shots = [] gun_shot_num = 0 gravity_time = 0 boss = Dragon(columns) boss.insert(game_board.grid) ice_balls = [] ice_ball_num = 0 prev_ice_ball_shoot = time.time() time_left = 110 prev_time_left = time.time() game_end = 0 for i in range(40, columns - 181, 70): # adding fire beams on the board random.shuffle(Rstart_pos1) random.shuffle(Rstart_pos2) random.shuffle(Rlength1) random.shuffle(Rorientation) random.shuffle(num_fire_beams)
def test_it_has_a_name_and_color(): """Test that a dragon has a name.""" tom = Dragon('Tom', 'Gold', 'Ben') assert tom.get_name() == 'Tom' assert tom.get_color() == 'Gold'
from board import Board from scene import Scene from manda import Manda from dragon import Dragon from alarmexception import AlarmException from getch import _getChUnix as getChar from shield import Shield from config import Time from bullet import Mandabullet, Dragonbullet import time import math board = Board(40, 500) scene = Scene(board) scene.make(board) manda = Manda(3, 35, board, scene) dragon = Dragon(485, 33, board, scene) manda.place_on_map() stime = time.time() mbullet = Mandabullet(board, scene, dragon) dbullet = Dragonbullet(board, scene, manda) timec = Time((board.get_width() - 170) / 2, 2, 0.5) shield = Shield() etime = 0 def gameover(message): os.system('clear') print("Score:" + str(manda.get_coins())) print(message) quit()
self.players = [] else: self.players = player def add_player(self, player): if player not in self.players: self.players.append(player) def remove_player(self, player): if player in self.players: self.players.remove(player) def show_players(self): for index, player in enumerate(self.players): print(f'No: {index + 1}: {player}') def __str__(self): return f'Size: {self.x_size}x{self.y_size}, {self.terrain.name}, Players: {len(self.players)}' ground = Scene() print(ground) dragon = Dragon('Drogo') ground.add_player(dragon) dragon2 = Dragon('Drogo2') ground.add_player(dragon2) dragon3 = Dragon('Drogo3') ground.add_player(dragon3) ground.show_players() print(ground)
from animal import Animal from dragon import Dragon from dog import Dog print '\n' animal = Animal('whooo') animal.walk().walk().walk().run().run().displayHealth() print '\n' dog = Dog('fido') dog.walk().walk().walk().run().run().pet().displayHealth() print '\n' dragon = Dragon('Draco') dragon.walk().run().fly().displayHealth() print '\n'
from coin import place_coins from powerup import place_powerup from dragon import Dragon from movement import playermove, boardmove, bulletmove from board import MAGNETS, BULLETS, DRAGONS, TIME, TIMEOUT from random import random from colorama import Back input( "\n\nControls:\n\t'w': Up\n\t'a': Left\n\t'd': Right\n\t'b': Shoot\n\t'space': Sheild\n\t'q': Quit\n\n\n\n\t\t\t\t\tPress ENTER to start: " + Back.LIGHTBLUE_EX) os.system('cls' if os.name == 'nt' else 'clear') brd = Board(28, 450) player = Jety(23, 9, brd) dragon = Dragon(10, 400, brd) brd.print_board(180, 0, 3, -1, 0, 10, 0) place_firebeam(brd) place_magnet(brd) place_powerup(brd) place_coins(brd) sleep(1) def printing(): stats = player.stats() drag_lives = -1
# Elimina el objeto cuando sale de la pantalla. if self.y < -300: self.eliminar() #creando fondo fondo = pilas.fondos.Fondo() fondo = pilas.fondos.Galaxia(dy=-10) enemigos = pilas.actores.Grupo() def crear_enemigo(): actor = Personaje(pilas) enemigos.agregar(actor) #cada 0,5 crea un enemigo pilas.tareas.siempre(0.5, crear_enemigo) pj = Dragon(pilas) pj.aprender(pilas.habilidades.LimitadoABordesDePantalla) pj.escala = 0.5 pj.definir_enemigos(enemigos, puntaje.aumentar) pilas.colisiones.agregar(pj, enemigos, pj.eliminar) pilas.actores.vincular(Dragon) pilas.ejecutar()
from dragon import Dragon app = Dragon(__name__) @app.route('/user/<username>') def show_user(username): return f'hello {username}' @app.route('/book/<bookname>') def show_book(bookname): return app.render_template('book.html', **{'bookname': bookname}) if __name__ == '__main__': from werkzeug.serving import run_simple run_simple('127.0.0.1', 5000, app, use_debugger=True, use_reloader=True)
def test_it_exists(): """Test that the object is created.""" dan = Dragon('Dan', 'Gold', 'James') assert type(dan) == Dragon
def create_dragon(self): '''Создание дракона''' self.dragon = Dragon(self.ai_settings, self.invasion_number); self.add_widget(self.dragon) self.add_widget(self.dragon.hp); self.add_widget(self.dragon.hp_label) self.dragon_is_true = True self.dragon.sound.play() #Звук летящего дракон
def test_dragons_are_born_hungry(): """When a dragon is born it is hungry.""" gretchen = Dragon('Gretchen', 'Yellow', 'Lacey') assert gretchen.is_hungry() is True
def test_it_has_a_rider(): """A dragon has a rider with a name.""" elise = Dragon('Elise', 'Green', 'Lessa') assert elise.get_rider() == 'Lessa'
from domador import Domador from dragon import Dragon from juego import Juego dragon1 = Dragon(0, 30, "Flofi") dragon2 = Dragon(10, 21, "Rufus") dragon3 = Dragon(15, 12, "Nicolas Harari") listaDragones = [dragon1, dragon2, dragon3] domador1 = Domador(10, 15, "Pablo") domador2 = Domador(20, 20, "Tania") domador3 = Domador(30, 30, "Renata") listaDomadores = [domador1, domador2, domador3] juego = Juego(100, listaDragones, listaDomadores) while not juego.estaTerminado(): juego.avanzarTurno()
def testIncreaseStrength(self): dragon = Dragon("Razil", 20, 30) dragon.setStrength(20) self.failUnlessEqual(40, dragon.getStrength())
if x not in coins: coins.append(Coin(x[0],x[1])) coins = sorted(coins,key = lambda x: x.get_pos()[0]) num_beams = 10 beams = [] beam_places_list = [np.array(range(board.get_bg_size()[0]+6,board.get_bg_size()[1]-board.get_window_size()[1],6)),np.array(range(din.get_ceil_ground()[1]+20,din.get_ceil_ground()[0]-10,6))] for i in range(num_beams): x = (int(np.random.choice(beam_places_list[0])),int(np.random.choice(beam_places_list[1]))) if x not in coins and x[0]: beams.append(Beam(x[0],x[1],np.random.choice([7,8,12]),np.random.choice([0,1,2]))) coins = sorted(coins,key = lambda x: x.get_pos()[0]) magnet = Magnet(np.random.randint(board.get_window_size()[0]+10,board.get_bg_size()[1]-board.get_window_size()[1])) dragon = Dragon(din,board) # board.set_current_pos(board.get_bg_size()[1] - board.get_window_size()[1]) kb.getch() while dragon.get_ended() == 0 and din.get_lives() > 0: board.update() if kb.kbhit(): c = kb.getch() if c == 'q': break if c == 'k': board.speed_up() if c == 'j': board.speed_down() din_ret = din.update(c) if c == 's': bullets.append(din_ret)
end_interval=0, fast=FASTPRINT) slowprint("A warning message will be added when this is the case.", end_interval=0, fast=FASTPRINT) NAME = slowinput("name> ", fast=FASTPRINT) print() slowprint("Please chose a title for you character.", end_interval=0, fast=FASTPRINT) slowprint("It will be used in letters.", fast=FASTPRINT) slowprint('It could be something like "{} The Great"'.format(NAME), fast=FASTPRINT) slowprint( "Note: You need to include your name, it is not added automaticaly.", end_interval=0, fast=FASTPRINT) TITLE = slowinput("title> ", fast=FASTPRINT) print() print() slowprint("----------------------------------------", fast=FASTPRINT) print() print() PLAYER = Dragon(name=NAME, title=TITLE) PLAYER.greet(fast=FASTPRINT) chapter1(PLAYER, fastprint=FASTPRINT)
#!/usr/bin/python2 from dragon import Dragon of = "test-05.png" d = Dragon(1) for i in range(19): print "\n### ROUND {} ###\n".format(i) d.iterate() d.write(of)
def app(): app = Dragon(__name__) return app
from dog import Dog from dragon import Dragon dog = Dog('Fiddo') dragon = Dragon("Trogdor") dragon.fly().walk().displayHealth() dog.walk().pet().displayHealth() print dragon
c1 = random.randint(2, 5) c2 = random.randint(3, 8) x = random.randint(1, 33) y = random.randint(30 + i * 20, 240 + i * 20) for j in range(c1): for k in range(c2): coin.place(board.matrix, x + j, y + k) magnet = Magnet() magnet.loadObstacle('magnet') x1 = 20 x2 = 200 magnet.place(board.matrix, x1, x2) mando = Mando() mando.loadMando(board.matrix, 'n', cnt) board.printBoard(cnt, config.dragon_lives) dragon = Dragon() dragon.loadObstacle('dragon') dragon.place(board.matrix, 20, 445) st = time.time() prev_gravity_time = time.time() dBtime = time.time() shield_time = time.time() gtime = time.time() flag = 'G' bullets = [] dragon_bullets = [] while True: p = user_input() if config.time <= 0: flag = 'T' break
import sys from input import user_input from board import Board from mando import Mando from coins import Coin from firebeam import Firebeam from magnet import Magnet from dragon import Dragon from time import time from bullet import Bullet from random import randint screen = Board(40, 10000) man = Mando(35, 3) man.place(screen) drag = Dragon(30, 500) drag.place(screen) for i in range(40): x = randint(5, 30) y = randint(25, 450) coin_p = Coin(x, y) coin_p.place(screen) for j in range(10, 30): x = randint(5, 30) y = randint(50, 350) beam = Firebeam(x, y) beam.place(screen) mag = Magnet(2, 80) mag.place(screen)