def button(msg, font_size, Surface, xpos, ypos, w, h, ic, ac, action=None): #global HudiSurf, costo, Budget, crashed mouse = pygame.mouse.get_pos() #meto en una lista la posicion del mouse click = pygame.mouse.get_pressed() crashed = False if xpos + w > mouse[0] > xpos and ypos + h > mouse[1] > ypos: pygame.draw.rect(Surface, ac, (xpos, ypos, w, h)) pygame.mixer.music.load('./70_SOUNDS/Click.mp3') pygame.mixer.music.play(0) #pygame.time.wait(500) if click[0] == 1 and action != None: if action == "Play": map.map() elif action == "Quit": pygame.quit() quit() elif action == "Seismic": plotseis(x, y) costo += 100 elif action == "Nextfield": crashed = True else: pygame.draw.rect(Surface, ic, (xpos, ypos, w, h)) smallText = pygame.font.Font("freesansbold.ttf", font_size) textSurf, textRect = text_objects(msg, smallText) textRect.center = ((xpos + (w / 2)), (ypos + (h / 2))) Surface.blit(textSurf, textRect) return crashed
def __init__(self, gameID, hostID): self.gameID = gameID self.hostID = hostID self.guestID = None self.hostMap = map() self.guestMap = map() self.FSMsymbols = {} self.FSM = StateMachine(self.FSMsymbols) self.FSM.add_state('init', self.st_init) self.FSM.set_state('init')
def colorSave(file): color.color(file, 1) color.color(file, 2) color.color(file, 3) gray.gray(file) map.map(file) rgb.rgb(file) var.var(file) #colorSave("fruit")
def new_map(self, widget, event): print "new map" dialog = gtk.Dialog("New blank Map", None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) labelh = gtk.Label("Height (pixels)") inputh = gtk.Entry(4) labelw = gtk.Label("Width (pixels)") inputw = gtk.Entry(4) hboxh = gtk.HBox(True, 0) hboxh.pack_start(labelh) hboxh.pack_end(inputh) hboxw = gtk.HBox(True, 0) hboxw.pack_start(labelw) hboxw.pack_end(inputw) dialog.vbox.pack_start(hboxh) dialog.vbox.pack_end(hboxw) hboxh.show() hboxw.show() inputh.show() inputw.show() labelh.show() labelw.show() response = dialog.run() roundh = (int(inputh.get_text()) / 8) * 8 roundw = (int(inputw.get_text()) / 8) * 8 self.ui.m = map(roundh, roundw) self.ui.maparea.set_size_request(self.ui.m.w * 16, self.ui.m.h * 16) dialog.destroy() self.ui.queue_draw()
def main(): args = getargv() #quantify output matrix_map = map.map(args['fi']) matrix_inten_Top = TopInten(matrix_map, args['method'], args['n'], args['rank']) tag = args['method'] + '_' + str(args['n']) + '_' + args['rank'] writematrix(matrix_inten_Top, args, tag) #probe information probe_fo = args['fopath'] + args[ 'label'] + '_probe_information.txt' if 'label' in args else args[ 'fopath'] + 'probe_information.txt' annot_dir = probe(matrix_map, probe_fo) annot_file = args['fopath'] + args[ 'label'] + '_annotation.txt' if 'label' in args else args[ 'fopath'] + 'annotation.txt' label = args['label'] if 'label' in args else '' annotate(annot_dir, annot_file, label) print('Done!')
def setGame(self): pygame.mixer.music.load('.\\data\\game start.wav') pygame.mixer.music.play() self.hsLabel = self.myfont2.render('',1,[255,255,255]) self.hsLabelAnnounc = self.myfont2.render('',1,[25,75,0]) self.hsBG = pygame.Rect(0,0,0,0) self.username = '' self.level = 1 self.score = 0 self.lowestTime = self.size/2 self.milliseconds = 0 self.allowed = self.size self.seconds = self.allowed self.pathway = map([self.size,self.size]) self.player = playerSquare(self.playerColor,[0,0]) self.pathway.addPlayer(self.player.returnPos()) self.wallPos = [] self.walls = self.addWalls() self.pathway.addWalls(self.wallPos) self.label = self.myfont.render('%.1f' %self.seconds, 1, (255,255,255)) self.scoreLabel = self.myfont2.render(str(self.score),1,(255,255,255)) self.objective = square(self.objectiveColor) tempPos = self.pathway.addRandom('objective') self.objective.place(tempPos) self.key = [] self.drawAll() self.t = pygame.time.Clock()
def main(): Map = map(sys.argv[1]) pygame.init() clock = pygame.time.Clock() done = False Map.draw() while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True if event.type == pygame.KEYDOWN: Map.draw() if event.key == pygame.K_d: _,path = Map.DFS() elif event.key == pygame.K_b: _,path = Map.BFS() elif event.key == pygame.K_u: _,path = Map.UCS() elif event.key == pygame.K_a: _,path = Map.AStar() elif event.key == pygame.K_q: done = True break else: continue Map.drawPath(path) Map.drawCost(_) pygame.display.flip() clock.tick(30)
def __init__(self, auto, debug): # initialize car object self.myCar = car() # initialize current state self.state = "f" # initialize map self.myMap = map() # initialize action counter self.actioncounter = 0 # initialize camera self.myCamera = camera() # initialize global variables vars.init() # debug or not self.debug = debug # get ready time.sleep(1) print("myCar and myCamera startup completed") if auto: # auto drive print("autoDrive mode") self.autoDrive() else: # manual drive print("manualDrive mode") self.manualDrive()
def __init__(self, coords_person, l_w, wall, sorties, obstacles, incendies): self.map = map.map(l_w, wall, sorties, obstacles, incendies) self.list_person = [] self.list_move_pc = [] # initialiser la liste de foule i = 0 for coord in coords_person: i += 1 self.list_person.append(Person(i, int(coord[0]), int(coord[1]))) # pour stocker les donnees de heat map self.thmap = np.zeros(((l_w[0] + 2), (l_w[1] + 2))) # stocker les resultats pour Pd self.pos_pd = np.zeros((l_w[0]+1,l_w[1]+1)) for i in range(0,l_w[0]+1): for j in range(0,l_w[1]+1): pt = (i,j) sor = fon.proche_sortie(pt,self.map.sorties) pd = fon.pd(pt,sor) self.pos_pd[i][j] = pd self.delta_time = 0.4 # les poids de chaque partie self.u1 = 10 # u1: coefficient d'attractivité de la sortie self.u2 = 0.01 # u2: coefficient d'attractivité du foule self.u3 = -0.1 # u3: coefficient de répulsion entre foule et obstacle self.u4 = -0.05 # u4: coefficient de friction self.u5 = -0.01 # u5: Coefficient de répulsion du feu
def start_game(hero, grid_select, spawn_coordinates, hero_name, oscars_hotfix): game_loop = True current_run = map(grid_size=grid_select) current_run.update_room(coordinate=spawn_coordinates, update="is_here") current_run.print_map() while game_loop is True: old_position = ask_player_to_move(current_run, hero_name) clear_screen() current_run.print_map() position = current_run.where_am_i(option="return") is_not_outside = check_if_outside( position, current_run ) # returns True for not outside and False for is outside if not is_not_outside: # if not True/False, outside of map == False return "end" x, y = position current_room = current_run.grid[y][x] if oscars_hotfix == 0: # om det är första rundan i spelet så kommer den att sätta första rummet som neutraliserat current_room.fight == False oscars_hotfix += 1 if current_room.fight == False: # if the room is already "finished" or if it is "edge", if edge should be picked up a few lines above doe fight_outcome = "win" # this is only so it will go down a few lines into the "elif fight_outcome == "win":" section else: # if the room is "unfinished" or "untouched" current_fight = current_run.grid[y][x].fight_generator( hero ) # genererar en fight instans för dem x,y coordinates som anges fight_outcome = current_fight.run_fight( ) # kör den fighteninstansen och ska returnera outcome för fighten # försöka få mapen att uppdatera sig utifrån hur fight outcome blir if fight_outcome == "escaped": current_run.update_room(coordinate=old_position, update="unfinished") elif fight_outcome == "win": score = current_room.total_loot hero.score_list.append(score) print("Your points from this round: {}".format(score)) update_score(hero_name, hero) current_room.total_loot = 0 current_room.fight = False elif fight_outcome == "died": break current_run.print_map() return
def __init__(self, grid_size, hero_instance): self.map_size = grid_size self.map = map(grid_size=self.map_size) self.hero = hero_instance self.ai = AI_class(hero_instance=self.hero, map_instance=self.map) self.fight = Fight(hero=self.hero, is_Ai=True) self.room = room() self.round_count = 0 self.game_active = True self.round_max = 5 self.stop_value = self.map_size**2
def test_map(): length_width, wall, sorties, obstacles, incendies, people = fon.lire_txt( 'pytest/test.txt') res = map.map(length_width, wall, sorties, obstacles, incendies) assert res.length == 50 assert res.width == 30 assert res.wall == [[(0, 49)], [(0, 29)], [(0, 49)], [(0, 3), (7, 29)]] assert res.sorties == [(0, 6), (0, 5), (0, 4)] assert res.incendies == [(10, 10)] assert res.zone_obstacale == [((5, 4), (8, 5))] assert (0, 29) in res.list_obstacle assert (6, 5) in res.list_obstacle
def load_files(url): files= glob.glob(url) json_out = [] keys = [] values = [] for file in files: json_file= open(file,'r') json_object = json.load(json_file) keys, values = map.map(json_object) return keys, values
def __init__(self, md=True): self.R = render() self.M = map() self.xycar = car() self.end = False self.steering_AOC = 200 self.set_frame(self.framepersec) self.curr_path = os.getcwd() self.pygame_exit = False if md: self.make_dir()
def main(sc): curses.nl(); gameplay_window = curses.newwin(10, 30, 0, 0); map_window = curses.newwin(5, 10, 0, 35); stats_window = curses.newwin(5, 10, 5, 35); gameplay_window.keypad(True); curses.curs_set(0); player = player_.player((13, 4), (0, 0)); map = map_.map(5, 6); running = True; def render_all(): stats_window.clear(); map.rooms[player.room_y][player.room_x].render(gameplay_window) player.render(gameplay_window, stats_window); map.render(map_window, player); sc.refresh(); gameplay_window.refresh(); map_window.refresh(); stats_window.refresh(); render_all(); while running: key = gameplay_window.getkey(); if key == ' ': gameplay_window.addstr(2, 8, "Do you really"); gameplay_window.addstr(3, 5, "want to quit (y/n) ?"); gameplay_window.refresh(); k = gameplay_window.getkey(); if k == 'y': running = False; render_all(); continue; player.update(key); player = map.rooms[player.room_y][player.room_x].update(player); render_all(); curses.curs_set(2); gameplay_window.keypad(False); curses.nonl();
def create_world(): global pacman, ghost, item_set, world_map, font_guide, font_life pacman = Player() ghost = [ Enemy(35, 565, 1), Enemy(565, 35, 2), Enemy(565, 565, 3), Enemy(350, 390, 4) ] # item_set = [item(100, 100, 0), item(200, 200, 0), item(300, 300, 0), item(400, 400, 0) # ,item(100, 200, 4), item(200, 300, 5), item(300, 400, 6), item(400, 500, 7)] world_map = map() font_guide = load_font('resource/Pixel.ttf', 30) font_life = load_font('resource/CrackMan.ttf', 30)
def main(sc): curses.nl() gameplay_window = curses.newwin(10, 30, 0, 0) map_window = curses.newwin(5, 10, 0, 35) stats_window = curses.newwin(5, 10, 5, 35) gameplay_window.keypad(True) curses.curs_set(0) curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_RED) player = player_.player((13, 4), (0, 0)) map = map_.map(5, 6) running = True def render_all(): stats_window.clear() gameplay_window.clear() player.render(gameplay_window, stats_window) map.rooms[player.room_y][player.room_x].render(gameplay_window, player) map.render(map_window, player) sc.refresh() gameplay_window.refresh() map_window.refresh() stats_window.refresh() render_all() while running: key = gameplay_window.getkey() if key == ' ': gameplay_window.addstr(2, 8, "Do you really") gameplay_window.addstr(3, 5, "want to quit (y/n) ?") gameplay_window.refresh() k = gameplay_window.getkey() if k == 'y': running = False render_all() continue player.update(key) player = map.rooms[player.room_y][player.room_x].update( player, gameplay_window) render_all() curses.curs_set(2) gameplay_window.keypad(False) curses.nonl()
def extra(self): self.disp_time.setText("0") self.disp_vehicles.setText("0") self.disp_stations.setText("0") self.disp_priority.setText("0") self.disp_outages.setText("0") self.btn_start.setStyleSheet("background-color: green") self.btn_start.clicked.connect(self.click_start) self.btn_step.setStyleSheet("background-color: #1aa3ff") self.btn_step.clicked.connect(self.click_step) self.btn_stop.setStyleSheet("background-color: red") self.btn_stop.clicked.connect(self.click_stop) self.map = map.map() self.reload_map()
def init(data): data.mode = 'start' data.modeCache = 'start' data.frameCount = 0 data.ScreenWidth = data.screen.get_width() data.ScreenHeight = data.screen.get_height() data.map = map.map('fastest', 64, 64,scale = 1.5) data.cellWidth, data.cellHeight = data.map.getCellsize() data.buildings = Building.building.buildings Building.building.setMap(data.map) Unit.Unit.setMap(data.map) Unit.Unit.setScreen(data.screen) player1 = Player.player('Protoss', 8,9,0) player2 = Player.player('Terran', 53,51,1) pMPic = 'Other/PauseMenu.png' data.pauseMenu = load.load_image(pMPic) data.currentPlayer = player1 data.otherPlayer = player2 #MenuFile = 'Other/Menu/Protoss Menu.png' data.MenuImage = data.currentPlayer.MenuImage #load.load_image(MenuFile) Menu_h = data.MenuImage.get_height() data.MenuHeight = Menu_h PointerFile = 'Other/Pointer.png' data.pointerImage = load.load_image(PointerFile) #pygame.mouse.set_visible(False) data.AutoScrollWidth = 20 data.ViewBox = Menu.ViewBox(data.map) data.buildMode = False data.placeMode = False data.currentBuildIndex = None data.currentBuildClass = None data.selected = None data.buttonStatus = [0]*9 data.currentPlayer.drawFogOfWar()
def __init__(self, coords_person, l_w, wall, sorties, obstacles, incendies): self.arg_A = 2000 self.arg_B = 0.08 self.k = 120000 self.delta_time = 0.005 self.map = map.map(l_w, wall, sorties, obstacles, incendies) self.list_person = [] # initialiser la liste de foule i = 0 for coord in coords_person: i += 1 per = Person(i, coord[0], coord[1]) per.destination = fon.proche_sortie(per.position, self.map.sorties) self.list_person.append(per) # pour stocker les donnees de heat map self.thmap = np.zeros(((l_w[0] + 2), (l_w[1] + 2)))
def __init__(self,map_name,camera): self.next="" self.current_maps=[] self.name_list=[] self.current_map=0 while self.next!=None: self.current_maps.append(map.map(map_name)) self.name_list.append(map_name) self.next=self.current_maps[-1].get_next_map() map_name=self.next spawn=self.current_maps[self.current_map].get_p_spawn() self.player=entity.Player(spawn[0],spawn[1],32,32) self.current_map=0 self.camera=camera self.camera.cam_max_x=self.current_maps[self.current_map].map_width() self.camera.cam_max_y=self.current_maps[self.current_map].map_height()
class robot: location = '' temp = map.map() def __init__(self, loc, currMap): self.location = loc self.temp = currMap def move(self, loc): print 'Moved from location: ' + self.location + ' to location : ' + loc self.location = loc def search(self, loc): if (self.temp.observeable(self.location, loc)): print 'Searched for Location: ' + loc + ' from location : ' + self.location + ' and found it!' return True else: print 'Searched for Location: ' + loc + ' from location : ' + self.location + ' and did not find it!' return False def enter(self, door): loc = self.temp.doors[door][0] print 'Exited Hallway : ' + self.location + ' and Entered Room : ' + loc self.location = loc def exit(self, door): loc = self.temp.doors[door][1] print 'Exited Room : ' + self.location + ' and Entered Hallway : ' + loc self.location = loc def currLoc(self): print self.location def naivePath(self, start, goal): return min(list(self.naivePathHelper(start, goal)), key=len) def naivePathHelper(self, start, goal): graph = self.arena.observMatrix stack = [(start, [start])] while stack: (vertex, path) = stack.pop() for next in graph[vertex] - set(path): if next == goal: yield path + [next] else: pass stack.append((next, path + [next]))
def trace_searching(self, mark): dbg_prnt(DBG_LVL_1, "Trace searching algorithm started.") self.__mark = mark # store object internally self.__ctr = 0 # clear mapping counter # create a mapping object mapping = M.map(mark.map_graph, self.__IR.nregs, self.__IR.nregvars) # enumerate all possible register and variable mappings rval = mapping.enum_mappings(self.__mapping_callback) dbg_prnt( DBG_LVL_1, "Trace searching algorithm finished with exit code %s" % bold(rval)) return rval
def open_map_rle(self, widget, event): print "open map" fcd = gtk.FileChooserDialog(title="Open map file", parent=None, action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_OPEN, gtk.RESPONSE_OK), backend=None) response = fcd.run() if response == gtk.RESPONSE_OK: f = fcd.get_filename() if self.ui.m == None: print "creation" self.ui.m = map(128, 128) self.ui.m.read_from_file_rle(f) self.ui.maparea.set_size_request(self.ui.m.w * 16, self.ui.m.h * 16) fcd.destroy() print f
def run_game(): pygame.init() maps = map() gray_map = maps.get_gray_map() colored_map = maps.get_colored_map() screen_size = maps.get_mapsize() SCREEN_WIDTH = screen_size[0] SCREEN_HEIGHT = screen_size[1] BG_COLOR = 150, 150, 80 screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), 0, 32) countries = country(gray_map, screen) armie = army(countries) continent = continents(countries) player = players() clock = pygame.time.Clock() armie.set_army(12, 88) screen.fill(BG_COLOR) screen.blit(colored_map, (0,0)) #Phase 1 while True: clock.tick(50) for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() if event.type == pygame.MOUSEBUTTONDOWN: if countries.is_country(countries.get_country_id(event.pos)) == True: pass #End Phase 1 if player.get_player_army() <= 0: break countries.update_countries(armie) pygame.display.flip()
def main(scr): curses.curs_set(0) pc = plyr(10, 10, 10, 10, 10, 10, scr) curses.use_default_colors() scr.clear() floor = map(scr) floor.defmap() ####################################################################################### ############# PLAYER CHARACTER FUNCTIONS ############################################## ####################################################################################### a = equip(1) b = equip(2) c = equip(3) d = equip(5) e = equip(6) f = equip(7) pc.addinv(a) pc.addinv(b) pc.addinv(c) pc.addinv(d) pc.addinv(e) pc.addinv(f) ##################################################################################### #################### RUNTIME ######################################################## ##################################################################################### while True: if pc.xp > (pc.lvl * pc.lvl + 10): pc.lvlup() floor.full.refresh( pc.cords[0] - 12, pc.cords[1] - 25, 1, 1, 25, 50, ) pc.run(floor.hostile, floor.impass) floor.draw(pc)
def traceMin_runtime(mapT, N_vec, M, T, params, time): """Short summary. Parameters ---------- mapT : type Description of parameter `mapT`. N_vec : vector i ** 2 = total number of districts M : type Description of parameter `M`. T : type Description of parameter `T`. params : type Description of parameter `params`. Returns ------- type Description of returned object. """ n_out = [] t_out = [] for i in N_vec: print(i) mapT = map.map(i, M, T, params) sim = mapT.sim(15) covM = mapT.covMat(sim) start_time = time.time() covMtm = mapT.traceMin(covM) t = time.time() - start_time t_out.append(t) n_out.append(covM.shape[0]) return( np.array([np.array(n_out), np.array(t_out)]) )
def main(): #Initialise Vehicle Class TEG = Vehicle(0, 0, 2) #Initialise blank image height = 500 width = 500 #Set the current map class to blank agvcmap = map.map(height, width, 255) #Generate a list of objects genObjects.main(agvcmap) #Retrieve objects from file obsList = loader.getObs() #M Mapping of obstacles and lines onto a pixel image and skeleton planning returning GPS (or distance) waypoints #Place obstacles on map agvcmap.updateObstacles(obsList) #Morph the obstacles agvcmap.updateMorph() nav = Navigation(agvcmap, obsList, TEG) nav.calculatePath()
def main(): #Initialise Vehicle Class TEG = Vehicle(0,0,2) #Initialise blank image height = 500 width = 500 #Set the current map class to blank agvcmap = map.map(height, width, 255) #Generate a list of objects genObjects.main(agvcmap) #Retrieve objects from file obsList = loader.getObs() #M Mapping of obstacles and lines onto a pixel image and skeleton planning returning GPS (or distance) waypoints #Place obstacles on map agvcmap.updateObstacles(obsList) #Morph the obstacles agvcmap.updateMorph(); nav = Navigation(agvcmap,obsList,TEG) nav.calculatePath()
#-- GENERATE PLAYER ------------------------------------------------------------------------------# import character as ch player_bstat = ch.basic_stat(acc=3, jump_power=10, max_speed=10, max_hp=100, max_mp=100) player_phstat = ch.physics_stat(width=20, height=20, air_drag=0.2) player = ch.player("1P", (500, 400), player_bstat, player_phstat) #-- GENERATE MAPS ------------------------------------------------------------------------------# import map maps = {} # MAP: TEST MAP maps['test_map'] = map.map(player, (40, 24)) map_now.map_setting(map_temp, {'start': (50, 300)}) test_map.background_setting(pygame.image.load("img/background.png")) test_map.start(player, test_map.spawn_list['start']) test_map.add_block( entity.eventblock( test_map, (5, 5), entity.PLAYER_COLLIDE, lambda: test_map.player.harms.append(attack.damage(5, False)))) test_map.add_block( entity.eventblock(test_map, (10, 5), entity.PLAYER_COLLIDE, lambda: test_map.player.set_acc((3, 3), 10))) test_map.add_block( entity.eventblock(test_map, (15, 5), entity.PLAYER_COLLIDE, lambda: test_map.player.set_controlled('stunned', 30))) test_map.add_block( entity.eventblock(test_map, (20, 5), entity.PLAYER_COLLIDE,
import map as mp import datetime ######## Function for finding primes between two numbers def numprimes(x,y): prime_nos=[] for num in range(x,y + 1): # prime numbers are greater than 1 if num > 1: for i in range(2,int(num**0.5)+1): if (num % i) == 0: break else: prime_nos.append(num) return prime_nos upper=2000000 num_steps=20 args=[(upper*i/num_steps,upper*(i+1)/num_steps) for i in range(0,num_steps)] now=datetime.datetime.now() ######## This is a parallelization of the above function primes=(reduce(lambda x,y:x+y,mp.map(numprimes,args))) print("Running time using mappy: "+str(datetime.datetime.now()-now)) now=datetime.datetime.now() primes=(reduce(lambda x,y:x+y,[numprimes(*arg) for arg in args])) print("Running time without mappy: "+str(datetime.datetime.now()-now))
#!/usr/bin/env python # coding=utf-8 from scenes import * from engine import engine from map import map amap = map('central_corridor') aengine = engine(amap) aengine.play()
import map as Mapper square = lambda x: x * x my_arr = [1,2,3] Mapper.map(my_arr, square) print(my_arr)
TARGET_FPS = 100 clock = pygame.time.Clock() life = 20 count = 0 #타임 조정을 위해 선언됨 while True: #마우스 좌표받기 #copyright 이동우 position = pygame.mouse.get_pos() #화면 구성 #copyright 이동우 screen.fill((255, 255, 255)) #임의의 맵 구현 #copyright 이동우 map1 = map.map(screen) map1.set([0, 100], [1280, 600]) map1.draw() #타이머 구현 #copyright 이동우 if count == 0: count += 1 tick = pygame.time.get_ticks() if 2900 <= pygame.time.get_ticks() - tick <= 3000: if virus.Virus.staticNum < wave_num: virus.Virus.staticNum += 1 count -= 1 #문구 출력 #copyright 이동우 virus.draw_text("remaining virus : ", screen, 150, 150, BLACK) virus.draw_text(str(virus.Virus.virusNum), screen, 250, 150, BLACK)
import map import application from random import randint import sound from sound_positioning import position_sound_1d import player from pyglet.window import key from speak import speak import pyglet m=map.map() me=player.player() en=player.player() en.x=-15 gun=sound.sound() step=sound.sound() death=sound.sound() amb=sound.sound() pain=sound.sound() enemyhit=sound.sound() enemydeath=sound.sound() jump=sound.sound() amb.load("sounds/amb.wav") enemy=sound.sound() jump.load("sounds/jump.wav") enemy.load("sounds/enemy.wav") death.load("sounds/playerdeath.ogg") enemydeath.load("sounds/enemydeath.wav") enemyhit.load("sounds/enemyhit.wav") gun.load("sounds/gun.wav") def positions(): position_sound_1d(enemy.handle,me.x,en.x,1,0.5)
import sys from world import world from agent import agent import random from PyQt4 import QtGui, QtCore from map import map app = QtGui.QApplication(sys.argv) inname = sys.argv[1] mp = map(inname) wrld = world(mp) for i in range(mp.mwidth*mp.mheight/8): agent(wrld,i) wrld.show() sys.exit(app.exec_())
import optparse import os from glob import glob import shutil from sys import exit usage = "usage: %prog [options] outpath" parser = optparse.OptionParser(usage=usage) archived_options = map(os.path.basename, glob(os.path.join(os.path.dirname(__file__), 'mechmap_archive', '*'))) parser.add_option("-a", dest = "archive", help = "Use archived mapping (one of: %s)" % ', '.join(archived_options), metavar="ARCHIVE", default = None) parser.add_option("-t", dest = "tracerinfo", help = "path to tracerinfo.dat (defaults to SOA from v9-01-01)", metavar="TRACERINFO", default = None) parser.add_option("-s", dest = "smvlog", help = "path to smv2.log (defaults to SOA from v9-01-01)", metavar="SMV", default = None) parser.add_option("-m", dest = "mechpath", help = "path to mechanism include files (e.g., mechpath*.EXT; defaults to cb05cl_ae6_aq)", metavar="MECHPATH", default = None) parser.add_option("-c", dest = "conversion", help = "path to converstion (i.e., mapping file)", metavar="CONV", default = None) parser.add_option("-e", dest = "extfiles", help = "use ext files instead of namelist", metavar="EXT", default = False, action = 'store_true') parser.add_option("-p", dest = "profiledat", help = "path to profile (e.g., CMAQ BCON input) (defaults profile.dat", metavar="PROFILEDAT", default = None) options, args = parser.parse_args() mapopt = dict([(o.dest, getattr(options, o.dest)) for o in parser.option_list[1:]]) convpath = options.conversion or os.path.join(os.path.dirname(__file__), 'mapping', 'saprc07t.csv') if not os.path.exists(convpath): temppath = os.path.join(os.path.dirname(__file__), 'mapping', convpath + '.csv') if os.path.exists(temppath): convpath = temppath del temppath tracerpath = options.tracerinfo or os.path.join(os.path.dirname(__file__), 'testdata', 'tracerinfo.dat') smvpath = options.smvlog or os.path.join(os.path.dirname(__file__), 'testdata', 'smv2.log') mechpath = options.mechpath or os.path.join(os.path.dirname(__file__), 'testdata') profilepath = options.profiledat or os.path.join(os.path.dirname(__file__), 'testdata', 'profile.dat') if len(args) < 1:
yvals = np.dot(yPoints, polynomial_array) return xvals, yvals def column(matrix, i): return [row[i] for row in matrix] if __name__ == "__main__": #Initialise Vehicle Class TEG = Vehicle(0,0,2) #Initialise blank image height = 500 width = 500 #Set the current map class to blank agvcmap = map.map(height, width, 255) #Generate a list of objects genObjects.main(agvcmap) #Retrieve objects from file obsList = loader.getObs() #M Mapping of obstacles and lines onto a pixel image and skeleton planning returning GPS (or distance) waypoints #Place obstacles on map agvcmap.updateObstacles(obsList) #Morph the obstacles agvcmap.updateMorph(); #Plan routes through obstacles #Skeleton Method---------------------------------------
import engine import map # Sheol # # Lee Enck # area = map.map('intro') Sheol = engine.engine(area) Sheol.play()
def tutorial_starting(screen) : chal = [0,0,0,0,0,0,0,0,0] chal_sv = [0,0,0,0,0,0,0,0,0] touer = [False, False, False, False] chal_scr = [500, 1000, 2000, 4000,6000,2000, 500, 3000, 5000] #도전과제 달성시 보상 chal_money = [100,200,350,550,700,200,100,500,0] score = 0 virus.Virus.Allnum = 0 virus.game_reset() WHITE = (255, 255, 255) BLACK = (0, 0, 0) back_ground = pygame.image.load("image/virus/map2.png") interface = pygame.image.load("image/virus/interface.png") map1 = map.map(screen) map1.ch = [[120,60],[120,300],[900,300],[900,720]] map1.set([0, 60], [900, 720]) chal_img = [] chal_img.append(pygame.image.load("image/challenge/chal_1.png")) chal_img.append(pygame.image.load("image/challenge/chal_2.png")) chal_img.append(pygame.image.load("image/challenge/chal_3.png")) chal_img.append(pygame.image.load("image/challenge/chal_4.png")) chal_img.append(pygame.image.load("image/challenge/chal_5.png")) chal_img.append(pygame.image.load("image/challenge/chal_6.png")) chal_img.append(pygame.image.load("image/challenge/chal_7.png")) chal_img.append(pygame.image.load("image/challenge/chal_8.png")) support_index = [] life = 20 tower1 = [] enemy1 = [] index = -1 vindex = -1 timg = [] timg.append(pygame.image.load("tower/normal_tower1.png")) timg.append(pygame.image.load("tower/short_tower1.png")) timg.append(pygame.image.load("tower/long_tower1.png")) timg.append(pygame.image.load("tower/support_tower1.png")) cancel_img = pygame.image.load("tower/cancel.png") build = 0 build_ok = True game_timer = time.time() old_time = game_timer gold = 1000 round123 = 0 count = 0 Font = pygame.font.Font(None, 52) font = pygame.font.Font(None, 26) vtimer = time.time() screen.blit(back_ground, (0, 0)) map1.draw() Gameoverbool = False ## 바이러스 badguy = [] selectNum = -1 count = 0 type_virus = 0 # copyright -shin hyuk jin pygame.mixer.init() pygame.mixer.music.load("sound/tutorbgm.wav") pygame.mixer.music.set_volume(0.1) # 1 ~ 0.1 pygame.mixer.music.play(-1) pygame.mixer.Sound("sound/tutorbgm.wav") managetime = time.time() viruslist = [[1,0,0,0],[2,0,0,0],[3,0,0,0],[4,0,0,0],[5,0,0,0]] wave = 0 while True : screen.blit(back_ground, (0, 0)) screen.blit(interface, (1030, 0)) map1.draw() pygame.display.flip() oldtime = time.time() curtime = time.time() while True : #Copyright : 노관태 timer = Font.render("Time : " + str(int(10-(curtime-oldtime))),True,(0,0,0)) #Copyright : 노관태 screen.blit(back_ground, (0, 0)) screen.blit(interface, (1030, 0)) if(curtime-oldtime < 10) : screen.blit(timer,(850,20)) for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: position = pygame.mouse.get_pos() if build == 0: for n in range(0, len(badguy)): # Copyright : 이동우 ~ badguy[n].calDistance(position[0], position[1]) for i in range(0, len(badguy)): if badguy[i].boolDtc(): selectNum = i break selectNum = -1 # ~ Copyright : 이동우 for i in range(0, len(tower1)): # made by 김재희~ if tower1[i].selected: if position[0] >= 1048 and position[0] <= 1048 + tower1[i].sell.get_width(): if position[1] >= 512 and position[1] <= 512 + tower1[i].sell.get_height(): gold += tower1[i].sell_tower() if tower1[i].is_support == True: for k in range(0, len(support_index)): if support_index[k] == i: support_index.pop(k) break for k in range(0, len(tower1)): if tower1[k].is_support == False: tower1[k].plus_damage = 0 for j in range(0, len(support_index)): if support_index[j] > i: support_index[j] -= 1 tower1.pop(i) index -= 1 break if position[1] >= 459 and position[1] <= 459 + tower1[i].upgrade.get_height(): if tower1[i].level <= 2: if gold >= tower1[i].upgrade_price[tower1[i].level]: gold -= tower1[i].upgrade_tower() else: tower1[i].selected = tower1[i].select_tower(position[0], position[1]) else: tower1[i].selected = tower1[i].select_tower(position[0], position[1]) if position[0] >= 1050 and position[0] <= 1050 + timg[0].get_width() and \ position[1] >= 110 and position[1] <= 110 + timg[0].get_height(): if gold >= 50: gold -= 50 index += 1 build += 1 tower1.append(tower()) tower1[index].timer = time.time() if position[0] >= 1170 and position[0] <= 1170 + timg[1].get_width() and \ position[1] >= 110 and position[1] <= 110 + timg[1].get_height(): if gold >= 150: gold -= 150 index += 1 build += 1 tower1.append(short_tower()) tower1[index].timer = time.time() if position[0] >= 1050 and position[0] <= 1050 + timg[2].get_width() and \ position[1] >= 230 and position[1] <= 230 + timg[2].get_height(): if gold >= 100: gold -= 100 index += 1 build += 1 tower1.append(long_tower()) tower1[index].timer = time.time() if position[0] >= 1170 and position[0] <= 1170 + timg[3].get_width() and \ position[1] >= 230 and position[1] <= 230 + timg[3].get_height(): if gold >= 200: gold -= 200 index += 1 build += 1 tower1.append(support_tower()) support_index.append(index) tower1[index].timer = time.time() elif build == 1: for i in range(0, len(tower1)): if (i != index): if (position[0] <= tower1[i].x + timg[0].get_width() / 2 + 15 and position[0] >= tower1[ i].x - timg[0].get_width() / 2 - 15\ and position[1] <= tower1[i].y + timg[0].get_height() / 2 + 15 and position[1] >= tower1[i].y - timg[0].get_height() / 2 - 15): build_ok = False break else: build_ok = True if on_roadt(position[0], position[1]) == False : if (build_ok == True) : build -= 1 if tower1[index].tower_name == "normal tower":# Copyright : 노관태~ touer[0] = True if tower1[index].tower_name == "short tower": touer[1] = True if tower1[index].tower_name == "long tower": touer[2] = True if tower1[index].tower_name == "support tower":# ~ Copyright : 노관태 touer[3] = True if position[0] >= 1150 and position[0] <= 1150 + cancel_img.get_width() and \ position[1] >= 615 and position[1] <= 615 + cancel_img.get_height(): build -= 1 if tower1[index].tower_name == "normal tower": # Copyright : 노관태~ gold += 50 if tower1[index].tower_name == "short tower": gold += 150 if tower1[index].tower_name == "long tower": gold += 100 if tower1[index].tower_name == "support tower": # ~ Copyright : 노관태 gold += 200 if tower1[i].is_support: support_index.pop() index -= 1 tower1.pop() # ~made by 김재희 if build == 1: # made by 김재희~ position = pygame.mouse.get_pos() tower1[index].build_tower(position[0], position[1]) for i in range(0, len(tower1)): attack_on = False if len(badguy) > 0: for j in range(0, len(badguy)): if build == 1: if index == i : break if (tower1[i].is_support != True): if (badguy[j].center[0] - tower1[i].x) * (badguy[j].center[0] - tower1[i].x) \ + (badguy[j].center[1] - tower1[i].y) * (badguy[j].center[1] - tower1[i].y) <= tower1[i].range * \ tower1[i].range: attack_on = True if tower1[i].tower_attack(game_timer): badguy[j].hp -= tower1[i].damage + tower1[i].plus_damage if badguy[j].hp <= 0: if badguy[j].name == "MERS virus": # Copyright : 노관태~ score += 10 gold += 7 if badguy[j].name == "ZIKA virus": score += 15 gold += 8 if badguy[j].name == "EBOLA virus": score += 20 gold += 10 if badguy[j].name == "CORONA virus": # ~ Copyright : 노관태 score += 300 gold += 300 badguy[j].dead() badguy.pop(j) if selectNum == j: selectNum = -1 elif selectNum > j: selectNum -= 1 vindex -= 1 break break else: if tower1[i].is_support == False: tower1[i].attack = 0 if tower1[i].is_support == False: if attack_on == False: tower1[i].attack = 0 if build == 0: for i in support_index: exist = False for j in range(0, len(tower1)): if tower1[j].is_support == False: if (tower1[j].x - tower1[i].x) * (tower1[j].x - tower1[i].x) \ + (tower1[j].y - tower1[i].y) * (tower1[j].y - tower1[i].y) <= tower1[i].range * \ tower1[i].range: tower1[j].plus_damage = tower1[i].plus_damage exist = True tower1[i].tower_attack(game_timer) if exist == False: tower1[i].attack = 0 for i in range(0, len(tower1)): tower1[i].blit_tower(screen) for i in range(0, len(enemy1)): screen.blit(enemy1[i].enemy_img, ( enemy1[i].x - enemy1[i].enemy_img.get_width() / 2, enemy1[i].y - enemy1[i].enemy_img.get_height() / 2)) # ~made by 김재희 gold_font = font.render(str(gold), True, (0, 0, 0)) life_font = font.render(str(life),True,(0,0,0)) screen.blit(life_font, (1080, 32)) screen.blit(gold_font, (1195, 32)) screen.blit(timg[0], (1050, 112)) screen.blit(timg[1], (1175, 115)) screen.blit(timg[2], (1052, 238)) screen.blit(timg[3], (1177, 233)) screen.blit(cancel_img, (1150, 615)) game_timer = time.time() map1.draw() chal = challenge.challenge_1_5_8_9(chal,virus.Virus.AllNum,gold,touer) for z in range (0,7,1) : if chal_sv[z] ==0 and chal[z] == 1 : chal_sv[z] = 2 managetime = time.time() for z in range(0, 7, 1): if chal_sv[z] == 2 or chal_sv[z] == 3 : if curtime - managetime < 3 : scr_giv = font.render("+" + str(chal_scr[z]),True,(0,0,0)) screen.blit(scr_giv,(150,680)) mon_giv = font.render("+" + str(chal_money[z]), True, (0, 0, 0)) screen.blit(mon_giv, (1190, 60)) if chal_sv[z] == 2 : score += int(chal_scr[z]) gold += int(chal_money[z]) chal_sv[z] =3 screen.blit(chal_img[z],(0,0)) elif curtime - managetime > 3 : if chal_sv[z] == 3 : chal_sv[z] =1 wave_print = Font.render("Wave : " + str(int(wave + 1)), True, (0, 0, 0)) Score_print = Font.render("Score : " + str(int(score)), True, (0, 0, 0)) screen.blit(Score_print, (10, 620)) screen.blit(wave_print, (10, 580)) chal = challenge.challenge_6(chal, life) if chal_sv[7] == 0 and chal[7] == 1: chal_sv[7] = 2 managetime = time.time() if chal_sv[7] == 2 or chal_sv[7] == 3: if curtime - managetime < 3: scr_giv = font.render("+" + str(chal_scr[7]), True, (0, 0, 0)) screen.blit(scr_giv, (150, 680)) mon_giv = font.render("+" + str(chal_money[7]), True, (0, 0, 0)) screen.blit(mon_giv, (1190, 60)) if chal_sv[7] == 2: score += int(chal_scr[7]) gold += int(chal_money[7]) chal_sv[7] = 3 screen.blit(chal_img[7], (0, 0)) elif curtime - managetime > 3: if chal_sv[7] == 3: chal_sv[7] = 1 if(curtime-oldtime > 10) : # 타이머 구현 #copyright 이동우 if count < viruslist[wave][0]: type_virus = 0 elif count >= viruslist[wave][0] and count < viruslist[wave][0] + viruslist[wave][1]: type_virus = 1 elif count >= viruslist[wave][0] + viruslist[wave][1] and count < viruslist[wave][0] + viruslist[wave][ 1] + viruslist[wave][2]: type_virus = 2 elif count >= viruslist[wave][0] + viruslist[wave][1] + viruslist[wave][2]: type_virus = 3 if count < viruslist[wave][0] + viruslist[wave][1] + viruslist[wave][2] + viruslist[wave][3] : if curtime - vtimer >= 1 : count += 1 vtimer = curtime badguy.append(virus.Virus(type_virus)) vindex += 1 badguy[vindex].setType() badguy[vindex].setPos([900, 720]) badguy[vindex].path = [[900,720],[900,300],[120,300],[120,60],[0,60]] #바이러스 좌표 조정 #copyright 이동우 for n in range(0, len(badguy)): if badguy[n].pos[0] < badguy[n].x_size: # 바이러스가 맵 끝에 도달하면 vindex -= 1 life -= badguy[n].dmg badguy.pop(n) if selectNum == n: selectNum = -1 elif selectNum > n: selectNum -= 1 break else: badguy[n].move() # 바이러스 화면 출력 #copyright 이동우 for n in range(0, len(badguy)): x = badguy[n].pos[0] y = badguy[n].Repeat(badguy[n].pos[1]) screen.blit(badguy[n].img, (x, y)) # 바이러스 클릭 시 바이러스 정보 출력 #copyright 이동우 if selectNum == -1: pass elif selectNum != -1: badguy[selectNum].drawInfo(screen, 1085, 370) if(life <=0) : # copyright -shin hyuk jin pygame.mixer.init() pygame.mixer.music.load("sound/damage.wav") pygame.mixer.music.set_volume(0.1) # 1 ~ 0.1 pygame.mixer.music.play() pygame.mixer.Sound("sound/damage.wav") Gameoverbool = True break if count >= viruslist[wave][0] + viruslist[wave][1] + viruslist[wave][2] + viruslist[wave][3] : if len(badguy) == 0 : count = 0 gold += 100 wave += 1 if wave == 5: #copyright-shin pygame.mixer.init() pygame.mixer.music.load("sound/roundswap.wav") pygame.mixer.music.set_volume(0.1) # 1 ~ 0.1 pygame.mixer.music.play() pygame.mixer.Sound("sound/roundswap.wav") score += life*100 score += gold GameOver.GameClear(screen, score, life, gold) return 1 break pygame.display.flip() curtime = time.time() if Gameoverbool : GameOver.GameOver(screen,score,life,gold) return 1 for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() exit(0)
def main(): m = map.map("test1.map")
pygame.init() window_size_x = 400 window_size_y = 300 cursor_x = (window_size_x/2) cursor_y = (window_size_y/2) pygame.mouse.set_visible(1) screen = pygame.display.set_mode((window_size_x, window_size_y)) pygame.display.set_caption("City Simulation") scroll_speed = 3 border = 50 map_pos_x = 0 map_pos_y = 0 std_map = map.map() std_map.load_map("map/","std_map.xml") std_map.set_window_size(window_size_x, window_size_y) pygame.time.set_timer(USEREVENT+1, 16) pygame.time.set_timer(USEREVENT+2, 16) while True: for event in pygame.event.get(): if event.type == QUIT: quit() if event.type == KEYDOWN: if event.key == K_ESCAPE: quit() if event.type == MOUSEBUTTONDOWN and event.button == 1: print "pressed"