def mainLoop(self): self.scene = gameViewObj() self.timer = 0 self.moveTimer = 3 self.actorList = [food(400, 600), player(500, 200), tail(900, 900)] self.amount = 3 self.gameOpen = True self.running = True while self.gameOpen: #Main Loop for the actual game while self.running: self.events() self.update() self.scene.render(self.actorList, self.amount) self.scene.drawText("Score: " + str(self.amount - 3) , (0,0)) self.scene.flippingTheScene() #We only exit the loop when we die. All the following is the code for the game over screen. self.scene.drawText("Game Over", (300, 320)) self.scene.drawText("Press Space to play again", (180, 350)) for event in pygame.event.get(): if event.type == pygame.QUIT: self.gameOpen = False if event.type == pygame.KEYDOWN: if event.key == pygame.K_SPACE: self.actorList[1].relocate((200, 200)) for x in range (self.amount - 1, 2, -1): del self.actorList[x] self.running = True self.amount = 3 self.scene.flippingTheScene()
def key(event): #print(event.keysym) #print(type(event.keysym)) if event.keysym == "F5": print("refresh") root.label.config(text="Refrescando...") root.update_idletasks() txt.delete('1.0', END) texto = tail(url,block_size) txt.insert(INSERT, texto) txt.see(END) root.label.config(text = "Actualizado a las: " + str(datetime.now())[11:])
def update(self): if(self.timer == self.moveTimer): y = self.amount - 1 for x in range(y, 1, -1): self.actorList[x].follow(self.actorList[x - 1]) self.actorList[1].move() self.timer = 0 self.timer += 1 if self.actorList[1].collide(self.actorList[0]): self.actorList[0].relocate() self.actorList.append(tail(900, 900)) self.amount += 1 if self.scene.outBoundsLeft(self.actorList[1]) or self.scene.outBoundsRight(self.actorList[1]) or self.scene.outBoundsTop(self.actorList[1]) or self.scene.outBoundsBottom(self.actorList[1]): self.running = False for x in range(self.amount - 1, 1, -1): if self.actorList[1].collide(self.actorList[x]): self.running = False
from diff import getDiff from math import log from tail import * te = 20.0 nTest = 7 #tests=[1,2] tests = [] for d in range(nTest): tests.append(5 * 2**d) #refFile="../kiter_5/heat_sdc_standard_M-3_nStep-5120-00001.vtu" Mv = [2, 3] refFile = "../../ros2/heat_ros2_40960-00001.vtu" for M in Mv: acname = "accuracy_M_%d.dat" % (M) f = open(acname, 'w') f.write("#h l2 max nstep runtime[ms]\n") for nstep in tests: dFile1 = "heat_sdc_standard_M-%d_nStep-%d-00001.vtu" % (M, nstep) res = getDiff(refFile, dFile1) h = te / nstep log = "log_%d_%d" % (nstep, M) logf = open(log) lastLine = tail(logf, 1) logf.close() data = str(h) + " " + str(res[0]) + " " + str( res[1]) + " " + str(nstep) + " " + str( lastLine[0].split(':')[1].split()[0]) f.write(data + "\n") f.close()
# realtime.py for realtime mode running hansipy from hansipy import * from tail import * from sender import * # Print all match string in realtime mode logfile = open( "./run/access.log") # "./run/access.log + ../log/apache2/access.log" loglines = tail(logfile) parselog = parsing(loglines) result = analyz(parselog) for i in result: j = '|'.join(map(str, i)) print j sendtodb(i)
from diff import getDiff from math import log from tail import * te=20.0 nTest=9 nStepsRef=5*(2**nTest) P_vec=[2,3,6,8] refFile="../kiter_5/heat_sdc_M-3_P-8_nStep-%d-00001.vtu" % nStepsRef #refFile="../ros2/heat_ros2_40960-00001.vtu" M=2 for P in P_vec: acname="accuracy_M_%d_P_%d.dat" %(M,P) f=open(acname,'w') f.write("#h l2 max nstep runtime[ms]\n") for n in range(0, nTest): nstep=(5*(2**n)) dFile1="heat_sdc_M-%d_P-%d_nStep-%d-00001.vtu" % (M,P,nstep) res=getDiff(refFile, dFile1) h=te/nstep log="log_%d_%d_%d"%(nstep,M,P) logf=open(log) lastLine=tail(logf, 1) logf.close() data=str(h)+" " +str(res[0])+" " +str(res[1]) +" "+str(nstep)+" " +str(lastLine[0].split(':')[1].split()[0]) f.write(data+"\n") f.close()
root=Tk() scrV = Scrollbar(root) scrH = Scrollbar(root, orient=HORIZONTAL) txt = Text(root, height=5, width=55, wrap=NONE) scrV.config(command=txt.yview) txt.config(yscrollcommand=scrV.set) scrH.config(command=txt.xview) txt.config(xscrollcommand=scrH.set) root.label = Label(root, bd=1, relief=SUNKEN, anchor=W) root.label.pack(side = BOTTOM, fill=X) texto = tail(url,block_size) txt.insert(INSERT, texto) txt.insert(END,"\n") txt.see(END) scrH.pack(side=BOTTOM, fill=X, expand=False) scrV.pack(side=RIGHT, fill=Y, expand=False) txt.pack(side=LEFT, fill=BOTH, expand=True) txt.bind("<Key>", key) root.bind("<Key>", key) root.title(url)