Esempio n. 1
0
def enter():
	gfw.world.init(['background', 'missile', 'player'])	
	background.init(player)
	player.init()
	generator.init()
	gfw.world.add(gfw.layer.background, background)
	gfw.world.add(gfw.layer.player, player)
Esempio n. 2
0
def start():
    global game_num
    add()
    pl.init()
    while (pl.game_over() == 0):
        for item in pl.player_in_game:
            global now_player
            now_player = item
            if (item.dead == 1): continue
            item.wave()
            if (pl.game_over()):
                if (pl.gamer_pos != -1):
                    pl.player_in_game[pl.gamer_pos].get_in = [0, 0, 0, 0, 0, 0]
                in_game = 0
                for i in range(len(pl.player_in_game)):
                    tmp = pl.player_in_game[i]
                    if (tmp.dead == 0):
                        pl.score[tmp.pos] += 1
                for i in range(len(pl.player_in_game)):
                    tmp = pl.player_in_game[i]
                    if (tmp.dead == 0):
                        pl.country_score[tmp.country] += 1
                        break
                game_num += 1
                print("waaaa %d aaaaa" % (game_num))
                for item in pl.player_in_game:
                    print(item.name, pl.score[item.pos])
                break
Esempio n. 3
0
def init():
    player.init()
    rock.init()
    clouds.init()
    particles.init()
    tree.init()
    birds.init()
    coin.init()
Esempio n. 4
0
def enter():
    gfw.world.init(['bg', 'missile', 'player'])

    generator.init()

    bg.init(player)
    gfw.world.add(gfw.layer.bg, bg)

    player.init()
    gfw.world.add(gfw.layer.player, player)
Esempio n. 5
0
def enter():
    gfw.world.init([
        'bg', 'bg2', 'meteor', 'player', 'ui', 'rockethead', 'rocketbody',
        'rocketleft', 'rocketlight', 'shield'
    ])
    player.init()
    gfw.world.add(gfw.layer.player, player)
    global game_over_image  # 게임오버시
    game_over_image = gfw.image.load('res/game_over.png')

    global stage1clear  #스테이지1클리어시
    stage1clear = gfw.image.load('res/stage1clear.png')

    global font  # 폰트
    font = gfw.font.load('res/ConsolaMalgun.ttf', 40)

    global music_bg, wav_item, explosionsound, getitemsound  # 음악처리
    music_bg = load_music('res/background.mp3')  # 배경음만mp3
    wav_item = load_wav('res/getitem.wav')
    explosionsound = load_wav('res/explosion.wav')
    getitemsound = load_wav('res/item.wav')

    global state
    state = STATE_GAME_OVER  # 드로우에서 처리
    start_game()  # 게임시작상태

    #로켓그려주기
    global rockethead
    rockethead = gfw.image.load('res/rockethead.png')

    global rocketbody
    rocketbody = gfw.image.load('res/rocketbody.png')

    global rocketleft
    rocketleft = gfw.image.load('res/rocketleft.png')

    global rocketlight
    rocketlight = gfw.image.load('res/rocketlight.png')

    global shield
    shield = gfw.image.load('res/shieldora.png')

    # 무브

    global move
    move = Move()

    bg = VertScrollBackground('space.png')
    bg.speed = 100
    gfw.world.add(gfw.layer.bg, bg)

    bg = VertScrollBackground('spacedust.png')
    bg.speed = 150
    gfw.world.add(gfw.layer.bg2, bg)
Esempio n. 6
0
def enter():
    gfw.world.init(['background', 'missile', 'item', 'player'])
    generate.init()

    background.init()
    gfw.world.add(gfw.layer.background, background)
    player.init()
    gfw.world.add(gfw.layer.player, player)

    global game_over_image, font
    game_over_image = gfw.image.load('res/game_over.png')
    font = gfw.font.load('res/ConsolaMalgun.ttf', 35)
    global state, score
    state = STATE_IN_GAME
    score = 0
Esempio n. 7
0
def init():
    global window, clock, is_running

    # Pygame stuff
    pygame.init()
    pygame.display.set_caption(WINDOW_CAPTION)
    pygame.time.set_timer(player_event, 200)
    pygame.time.set_timer(food_event, 5000)

    window = pygame.display.set_mode((WORLD_WIDTH, WORLD_HEIGHT))
    clock = pygame.time.Clock()

    player.init()
    food.init()

    is_running = True
Esempio n. 8
0
def enter():
    gfw.world.init(['stage1bg', 'stage2bg', 'meteor', 'player', 'ui', 'rockethead','rocketbody','rocketleft','rocketlight'])
    player.init()
    gfw.world.add(gfw.layer.player, player)

    ##스테이지
    stage1bg.init()  # 스테이지1삽입
    gfw.world.add(gfw.layer.stage1bg, stage1bg)

    global game_over_image  # 게임오버시
    game_over_image = gfw.image.load('res/game_over.png')

    global font  # 폰트
    font = gfw.font.load('res/ConsolaMalgun.ttf', 40)

    global music_bg, wav_item, explosionsound  # 음악처리
    music_bg = load_music('res/background.mp3')  # 배경음만mp3
    wav_item = load_wav('res/item.wav')
    explosionsound = load_wav('res/explosion.wav')

    global state
    state = STATE_GAME_OVER  # 드로우에서 처리
    start_game()  # 게임시작상태


    #로켓그려주기
    global rockethead
    rockethead = gfw.image.load('res/rockethead.png')

    global rocketbody
    rocketbody = gfw.image.load('res/rocketbody.png')

    global rocketleft
    rocketleft = gfw.image.load('res/rocketleft.png')

    global rocketlight
    rocketlight = gfw.image.load('res/rocketlight.png')


    # 무브

    global move
    move = Move()
Esempio n. 9
0
def enter():
    gfw.world.init(['bg', 'missile', 'player', 'ui'])
    player.init()
    gfw.world.add(gfw.layer.player, player)
    bg.init()
    gfw.world.add(gfw.layer.bg, bg)

    global game_over_image
    game_over_image = gfw.image.load('res/game_over.png')

    global font
    font = gfw.font.load('res/ConsolaMalgun.ttf', 40)

    global music_bg, wav_item, wav_explosion
    music_bg = load_music('res/background.mp3')
    wav_item = load_wav('res/item.wav')
    wav_explosion = load_wav('res/explosion.wav')

    highscore.load()

    global state
    state = STATE_GAME_OVER
    start_game()
Esempio n. 10
0
def design():
    task_queue.clear()
    page = 1
    max_page = max(len(pl.player_list), len(gm.gamer_list)) // 14 + 1
    print(pl.scripts)
    for i in range(0, 14):
        if (i >= len(pl.player_list)): break
        item = pl.scripts[pl.player_list[i]]()
        pl.player_in_game.append(item)
    pl_alpha_init()
    pl.init()
    while (in_design):
        screen.fill(0)
        screen.blit(title_ground, [0, 0])
        for i in range(0, 14):
            if (i >= len(pl.player_in_game)): break
            item = pl.player_in_game[i]
            item.std_output(20 + (i % 7) * 140, 20 + (i // 7) * 180, 0)

        pygame.display.flip()
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                exit(0)
            if event.type == pygame.KEYDOWN:
                if event.key == K_q:
                    if (page > 1):
                        page -= 1
                        print("down")
                if event.key == K_q:
                    if (page < max_page):
                        page += 1
                        print("up")
            if event.type == MOUSEBUTTONDOWN:
                for item in task_queue:
                    if (item.check()):
                        item.response()
Esempio n. 11
0
import numpy as np

import nltk
import nlpy
import en

import psw
import gapi

import player

songPlayer = player.Player()
player.init()

import subprocess
from grooveshark import Client
songClient = Client()
songClient.init()

from sets import Set

def matchWord(tokens, words):
	s = Set(tokens).intersection(Set(words))
	if len(s)>0:
		return [(w,1.0,w) for w in s]
	else:
		from nltk.metrics import distance
		import operator
		result = []
		for token in Set(tokens):
			vals = {w : (1.0-float(distance.edit_distance(token, w))/float(max(len(token),len(w)))) for w in words}
Esempio n. 12
0
def create_player(sx,sy):
    pc = player.chargen()
    port(pc, sx,sy)
    player.init(pc)
    Ref.pc = pc
    return pc
Esempio n. 13
0
	def runOnce(self):
		
		#update time
		self.time += 1
		
		#update resource map with spontaneous resources
		self.updateResources()
				
		#effect players movement
		for player in self.players:
			player.act(self.time, self.rockets, self.healthPack1, self.healthPack2, self.healthPack3, self.healthPack4, self.quad)
			if self.isValidPoint([player.myX + player.currentAction[0], player.myY + player.currentAction[1]]):
				player.myX = player.myX + player.currentAction[0]
				player.myY = player.myY + player.currentAction[1]

			
			if self.isQuad(player):
				print '{bot} acquired quad'.format(bot = player.agent.name)
				self.pickQuad(player)
			if self.isHealth(player):
				print '{bot} acquired health'.format(bot = player.agent.name)
				self.pickHealth(player)
			if self.isRocket(player):
				print '{bot} acquired rockets'.format(bot = player.agent.name)
				self.pickRockets(player)
		
		for player in self.players:
			player.lastx = player.myX
			player.lasty = player.myY 
			
		
		rocketsToRemove = []
		#move rocket
		for rocket in self.firedRockets:
			rocketPos = rocket.getPos(True) #move and give pos
			#print 'rocket at {a},{b}'.format(a=rocketPos[0], b=rocketPos[1])
		
		#rocket explode
		#TODO - if any player and rocket are on same spot, rocket should explode
		#TODO - explosion not accurate on edges
			if (rocket.isAlive()==False or rocketPos[0] == self.GRID_SIZE+1 or rocketPos[1] == self.GRID_SIZE+1):
				print 'rocket exploded at {x},{y}'.format(x=rocketPos[0], y=rocketPos[1])
				mult = 4 if rocket.owner.quad else 1
				for i in range(-2,2):
					for j in range(-2, 2):
						rdx = rocketPos[0]+i #rdx = rocket damage x
						rdy = rocketPos[1]+j #rocket damage y
						for player in self.players:
							if(player.myX == rdx and player.myY == rdy):
								print 'player({x},{y}) health before explosion {h}'.format(x = rdx, y = rdy, h = player.health)
								player.health -= (rocket.DAMAGE[i+2][j+2] * mult) * self.DAMAGE_MULTIPLIER
								print 'player({x},{y}) health after explosion {h}'.format(x = rdx, y = rdy, h = player.health)
								if player.health <= 0:
									self.rockets[rdx][rdy] += self.ROCKET_PACK_SIZE #update for dropped rocket pack
									player.alive = False
				rocketsToRemove.append(rocket)	#TODO - check whether it is working fine - removing while iterating
		
		
		#remove rockets from live rockets
		for rocket in rocketsToRemove:
			self.firedRockets.remove(rocket)

		

		#effect players firing
		for player in self.players:
			if not (player.currentAction[2] == -1 or player.currentAction[3] == -1 or player.rockets < 1):
				rocket1 = Rocket(player.myX, player.myY, player.currentAction[2], player.currentAction[3], player, player.quad)
				self.firedRockets.append(rocket1)
				player.rockets -= 1
				print 'rocket aimed at {x}, {y}'.format(x = player.currentAction[2], y = player.currentAction[3])

		self.updateDisplay()

		#update frags
		for player in self.players:
			if not player.alive:
				player.opp.frags += 1
				player.init()
				
		#print score
		self.printScore()
		return not (self.player1.frags < self.FRAG_LIMIT and self.player2.frags < self.FRAG_LIMIT)
Esempio n. 14
0
import player
player.init()

try:
    #mainloop
    while True:
        player.humanPlayer.turn()
        player.aiPlayer.turn()

except player.Victory:
    if aiPlayer.playerDefeatFlag:
        print("Congratulations!")
    elif humanPlayer.playerDeafeatFlag:
        print("Maybe next time?")
except:
    raise Exception("I'm sorry. Something went wrong")
Esempio n. 15
0
    def main(self):
        """Play a midi file with sound samples
        """
        player.init()
        clock = pygame.time.Clock()
        old_time = 0
        p_done = False

        pitch_offset = 60
        need_update_display = True
        while not p_done:
            # events
            for ev in pygame.event.get():
                need_update_display = True
                menu_bar_screen = self.menu_bar.update(ev)
                if self.menu_bar:
                    self.menu_bar_info.set(self.get_menus_info_bar())
                    # self.menu_bar_info.update(ev)

                if self.menu_bar.choice:
                    try:
                        self.load_resource(self.menu_bar.choice_label[-1])
                    except Exception, e:
                        print "menu error:", e
                    # if have choice, continue event
                    continue

                if ev.type == MOUSEBUTTONUP:
                    if ev.pos[1] > 60:
                        continue
                    # enable/disable tracks
                    for track_idx in self.enabled_tracks:
                        sw = self.enabled_tracks_switch[track_idx]
                        if sw.collidepoint(ev.pos):
                            self.enabled_tracks[track_idx] = not self.enabled_tracks[track_idx]

                            idx = self.tracks_order_idx[track_idx]
                            note_color = self.piano.TRACK_COLORS[idx % len(self.piano.TRACK_COLORS)]
                            if self.enabled_tracks[track_idx]:
                                self.piano.screen.fill(note_color, sw)
                            else:
                                self.piano.screen.fill(self.piano.color_lines, sw)

                elif ev.type == MOUSEBUTTONDOWN:
                    if ev.button == 5: # scroll down
                        self.staff_offset_x += 40

                    elif ev.button == 4: # scroll up
                        self.staff_offset_x -= 40
                        if self.staff_offset_x < 0:
                            self.staff_offset_x = 0

                    elif ev.button == 3: # right button
                        self.is_pause = not self.is_pause

                    elif ev.button == 1:   # left button
                        if ev.pos[1] < 60: # progress bar can not click
                            continue
                        clicked_staff_number = int((ev.pos[1] - self.staff_top) / (self.piano.staff_total_lines * self.piano.staff_space_height))
                        wraped_staff_offset = 0
                        if clicked_staff_number > 0:
                            wraped_staff_offset += self.piano.lastbar_pos_in_line1
                        if clicked_staff_number > 1:
                            wraped_staff_offset += self.piano.lastbar_pos_in_line2 * (clicked_staff_number-1)

                        timestamp_offset_x = (
                            self.staff_offset_x +
                            ev.pos[0] +
                            wraped_staff_offset
                        ) * self.piano.timestamp_range / self.screen_rect.width

                        self.last_timestamp = -1
                        for idx, midi_line in enumerate(self.all_midi_lines):
                            cmd, pitch, volecity_data, track_idx, pitch_timestamp = midi_line[:5]
                            if timestamp_offset_x > pitch_timestamp:
                                if self.last_timestamp != pitch_timestamp:
                                    self.midi_cmd_idx = idx
                                    self.last_timestamp = pitch_timestamp
                            elif timestamp_offset_x < pitch_timestamp:
                                break

                        self.play_one_timestamp_while_paused = True
                        self.piano.reset_piano()


                elif ev.type == KEYUP:
                    if ev.key == K_ESCAPE:
                        p_done = True
                        break

                    # MENU Reload
                    elif ev.key == K_RETURN:
                        menus_in_bar, self.midi_filename_data = get_menu_data()
                        self.menu_bar.set(menus_in_bar)

                    # Stop
                    elif ev.key == K_s:
                        self.piano.reset_piano()
                        self.staff_offset_x = 0
                        self.midi_cmd_idx = 0
                        self.last_timestamp = -1
                        self.is_pause = True

                    # Pause/Play
                    elif ev.key == K_SPACE:
                        self.is_pause = not self.is_pause

                    # is_longbar_show
                    elif ev.key == K_c:
                        self.piano.is_longbar_show = not self.piano.is_longbar_show

                    elif ev.key == K_COMMA:
                        # Slower
                        parse_midi.g_mseconds_per_quarter = int(60000 / (
                            60000 / parse_midi.g_mseconds_per_quarter - 10))
                        if parse_midi.g_mseconds_per_quarter > 2000:
                            parse_midi.g_mseconds_per_quarter = 2000
                        self.menu_bar_info.set(self.get_menus_info_bar())
                    elif ev.key == K_PERIOD:
                        # Faster
                        parse_midi.g_mseconds_per_quarter = int(60000 / (
                            60000 / parse_midi.g_mseconds_per_quarter + 10))
                        if parse_midi.g_mseconds_per_quarter <= 200:
                            parse_midi.g_mseconds_per_quarter = 200
                        self.menu_bar_info.set(self.get_menus_info_bar())

                    #Page_Up/Page_Down
                    elif ev.key == K_DOWN:
                        self.staff_offset_x += self.piano.lastbar_pos_in_line1
                    elif ev.key == K_UP:
                        self.staff_offset_x -= self.piano.lastbar_pos_in_line1
                        if self.staff_offset_x < 0:
                            self.staff_offset_x = 0

                    # Previous/Next MIDI
                    elif ev.key in [K_LEFT, K_RIGHT]:
                        need_reload = False
                        if ev.key == K_LEFT:
                            if self.midi_filename_idx > 0:
                                self.midi_filename_idx -= 1
                                need_reload = True
                        elif ev.key == K_RIGHT:
                            if self.midi_filename_idx+1 < len(self.midi_filename_data):
                                self.midi_filename_idx += 1
                                need_reload = True
                        if need_reload:
                            midi_filename = self.midi_filename_data[self.midi_filename_idx]
                            self.load_resource(midi_filename)

                    # Metronome
                    elif ev.key == K_m:
                        if (1.0 - player.g_metronome_volume) / 2 < 0.1:
                            player.g_metronome_volume += 0.1
                        else:
                            player.g_metronome_volume += (1.0 - player.g_metronome_volume) / 2

                    # # Set Progress Percent
                    # elif ev.key in [K_0, K_1, K_2, K_3, K_4, K_5, K_6, K_7, K_8, K_9]:
                    #     self.piano.reset_piano()
                    #     self.midi_cmd_idx = self.all_midi_lines_length * (ev.key - 48) / 10
                    #     self.last_timestamp = -1

                    # Set Pitch Offset
                    elif ev.key in [K_v, K_b, K_n]:
                        pitch_offset = {K_v: 36,  K_b: 60,  K_n: 84}[ev.key]

                    elif ev.key == K_f:
                        player.g_volecity_adjust = (player.g_volecity_adjust+1) % len(player.g_volecity_list)
                        player.load_sounds([(midi_data[1], midi_data[2]) for midi_data in self.all_midi_lines],
                                           self.sounds)

                    elif ev.key == K_z:
                        if self.piano.staff_space_height > 2:
                            self.piano.staff_space_height /= 2
                        self.piano.timestamp_range = TIMESTAMP_RANGE * parse_midi.g_ticks_per_quarter / parse_midi.g_mseconds_per_quarter
                        self.piano.timestamp_range = self.piano.timestamp_range * self.piano.staff_space_height_base / self.piano.staff_space_height
                    elif ev.key == K_x:
                        if self.piano.staff_space_height < 128:
                            self.piano.staff_space_height *= 2
                        self.piano.timestamp_range = TIMESTAMP_RANGE * parse_midi.g_ticks_per_quarter / parse_midi.g_mseconds_per_quarter
                        self.piano.timestamp_range = self.piano.timestamp_range * self.piano.staff_space_height_base / self.piano.staff_space_height

                    # Play Piano with keys
                    elif ev.key in PITCH_OF_KEY_ON_KEYBOARD:
                        pitch = pitch_offset + PITCH_OF_KEY_ON_KEYBOARD.index(ev.key)
                        player.stop(pitch, 100, self.sounds)
                        player.load_sounds([(pitch, 100)], self.sounds)
                        cmd = "NOTE_OFF"
                        self.piano.show_keys_press(cmd, pitch)

                elif ev.type == KEYDOWN:
                    if ev.key in PITCH_OF_KEY_ON_KEYBOARD:
                        pitch = pitch_offset + PITCH_OF_KEY_ON_KEYBOARD.index(ev.key)
                        player.load_sounds([(pitch, 100)], self.sounds)
                        player.play(pitch, 100, self.sounds)
                        cmd = "NOTE_ON"
                        self.piano.show_keys_press(cmd, pitch)

            # must out of events loop
            if self.menu_bar or self.menu_bar.choice:
                self.gl_screen_blit()
                pygame.display.flip()
                clock.tick(10)
                continue

            # get cmd
            try:
                if (self.is_pause and not self.play_one_timestamp_while_paused):
                    raise Exception("paused")
                # repeat
                if self.midi_cmd_idx >= self.all_midi_lines_length:
                    raise Exception("repeat")

                midi_line = self.all_midi_lines[self.midi_cmd_idx]
                self.midi_cmd_idx += 1
                cmd, pitch, volecity_data, track_idx, pitch_timestamp = midi_line[:5]
                volecity = player.get_volecity(volecity_data)
                if pitch not in [0, 1] + player.g_grand_pitch_range:
                    continue
                if track_idx >= 0 and not self.enabled_tracks.get(track_idx, False):
                    continue
                if self.last_timestamp == -1:
                    # init last timestamp
                    self.last_timestamp = pitch_timestamp - 1
            except Exception, e:
                if need_update_display:
                    self.piano.show_notes_staff_in_page(self.enabled_tracks, self.tracks_order_idx,
                                            self.notes_in_all_staff, self.last_timestamp,
                                            self.staff_top,
                                            parse_midi.g_bar_duration,
                                            parse_midi.g_time_signature_n,
                                            self.staff_offset_x, self.is_pause)
                    has_stoped = player.real_stop(self.sounds)
                    self.gl_screen_blit()
                    pygame.display.flip()
                    need_update_display = False

                if self.midi_cmd_idx >= self.all_midi_lines_length:
                    if self.midi_repeat_count < TRAINING_REPEAT_TIMES:
                        self.midi_repeat_count += 1
                        self.staff_offset_x = 0
                        self.midi_cmd_idx = 0
                        self.last_timestamp = -1
                    else:
                        if self.midi_filename_idx+1 < len(self.midi_filename_data):
                            self.midi_filename_idx += 1
                        else:
                            self.midi_filename_idx = 0
                        midi_filename = self.midi_filename_data[self.midi_filename_idx]
                        self.load_resource(midi_filename)
                        self.is_pause = False

                clock.tick(40)
                continue
Esempio n. 16
0
File: main.py Progetto: lokkey/pyQ3
    def runOnce(self):

        #update time
        self.time += 1

        #update resource map with spontaneous resources
        self.updateResources()

        #effect players movement
        for player in self.players:
            player.act(self.time, self.rockets, self.healthPack1,
                       self.healthPack2, self.healthPack3, self.healthPack4,
                       self.quad)
            if self.isValidPoint([
                    player.myX + player.currentAction[0],
                    player.myY + player.currentAction[1]
            ]):
                player.myX = player.myX + player.currentAction[0]
                player.myY = player.myY + player.currentAction[1]

            if self.isQuad(player):
                print '{bot} acquired quad'.format(bot=player.agent.name)
                self.pickQuad(player)
            if self.isHealth(player):
                print '{bot} acquired health'.format(bot=player.agent.name)
                self.pickHealth(player)
            if self.isRocket(player):
                print '{bot} acquired rockets'.format(bot=player.agent.name)
                self.pickRockets(player)

        for player in self.players:
            player.lastx = player.myX
            player.lasty = player.myY

        rocketsToRemove = []
        #move rocket
        for rocket in self.firedRockets:
            rocketPos = rocket.getPos(True)  #move and give pos
            #print 'rocket at {a},{b}'.format(a=rocketPos[0], b=rocketPos[1])

            #rocket explode
            #TODO - if any player and rocket are on same spot, rocket should explode
            #TODO - explosion not accurate on edges
            if (rocket.isAlive() == False or rocketPos[0] == self.GRID_SIZE + 1
                    or rocketPos[1] == self.GRID_SIZE + 1):
                print 'rocket exploded at {x},{y}'.format(x=rocketPos[0],
                                                          y=rocketPos[1])
                mult = 4 if rocket.owner.quad else 1
                for i in range(-2, 2):
                    for j in range(-2, 2):
                        rdx = rocketPos[0] + i  #rdx = rocket damage x
                        rdy = rocketPos[1] + j  #rocket damage y
                        for player in self.players:
                            if (player.myX == rdx and player.myY == rdy):
                                print 'player({x},{y}) health before explosion {h}'.format(
                                    x=rdx, y=rdy, h=player.health)
                                player.health -= (
                                    rocket.DAMAGE[i + 2][j + 2] *
                                    mult) * self.DAMAGE_MULTIPLIER
                                print 'player({x},{y}) health after explosion {h}'.format(
                                    x=rdx, y=rdy, h=player.health)
                                if player.health <= 0:
                                    self.rockets[rdx][
                                        rdy] += self.ROCKET_PACK_SIZE  #update for dropped rocket pack
                                    player.alive = False
                rocketsToRemove.append(
                    rocket
                )  #TODO - check whether it is working fine - removing while iterating

        #remove rockets from live rockets
        for rocket in rocketsToRemove:
            self.firedRockets.remove(rocket)

        #effect players firing
        for player in self.players:
            if not (player.currentAction[2] == -1
                    or player.currentAction[3] == -1 or player.rockets < 1):
                rocket1 = Rocket(player.myX, player.myY,
                                 player.currentAction[2],
                                 player.currentAction[3], player, player.quad)
                self.firedRockets.append(rocket1)
                player.rockets -= 1
                print 'rocket aimed at {x}, {y}'.format(
                    x=player.currentAction[2], y=player.currentAction[3])

        #update frags
        for player in self.players:
            if not player.alive:
                player.opp.frags += 1
                player.init()

        #print score
        self.printScore()
        return not (self.player1.frags < self.FRAG_LIMIT
                    and self.player2.frags < self.FRAG_LIMIT)
Esempio n. 17
0
def enter():
    gfw.world.init(['bg', 'missile', 'player'])
    player.init()
    gfw.world.add(gfw.layer.player, player)
Esempio n. 18
0
    def init(self):
        for player in self.players:
            player.init()

        for room in self.rooms:
            room.init()