예제 #1
0
	def paint(self,screen):
		img = pygame.image.load(os.path.join("data","gfx","help.png"))
		screen.blit(img,(0,0))
		
		g = self.game
		fg = (255,255,255)
		bg = (0,0,0)
		
		fnt = g.font_title
		text.write(screen,fnt,(20,10),fg,"You Won!",border=2)
		
		x,y = 20,140
		
		txt = """You have saved the people from the evil potentate.  Good job.
		
Now you can spend the rest of your life basking in the glow of your great accomplishment.  You are a true hero.

Huzzah.
"""

		for dx,dy in [(-1,0),(1,0),(0,1),(0,-1),(2,2)]:
			text.writewrap(screen,self.game.font_small,pygame.Rect(x+dx,y+dy,600,1),bg,txt)	
		text.writewrap(screen,self.game.font_small,pygame.Rect(x,y,600,1),fg,txt)	
		
		
		
		
		
		
		pygame.display.flip()
예제 #2
0
	def paint(self,screen):
		img = pygame.image.load(os.path.join("data","gfx","help.png"))
		screen.blit(img,(0,0))
		
		g = self.game
		fg = (255,255,255)
		bg = (0,0,0)
		
		fnt = g.font_title
		text.write(screen,fnt,(20,10),fg,"Help",border=2)
		
		x,y = 20,140
		
		txt = """The evil potentate is ruining everyone's lives!  Use the 
power of dynamite to destroy his strongholds.

Detonate dynamite by the blue load bearing pillars to bring down the castles.  Watch out for the guards.  Hide next to walls, but not too close to guards.  Escape via windows.

Controls:
Left Mouse Button - walk to a point
Numeric Keypad - walk in a direction
Right Mouse Button 1st Time - place dynamite
Right Mouse Button 2nd Time - detonate dynamite
Left CTRL - same as Right Mouse Button
Arrow Keys - peek around the level
Escape - quit;  Enter / p - pause;  F2 - toggle music
"""

		for dx,dy in [(-1,0),(1,0),(0,1),(0,-1),(2,2)]:
			text.writewrap(screen,self.game.font_small,pygame.Rect(x+dx,y+dy,600,1),bg,txt)	
		text.writewrap(screen,self.game.font_small,pygame.Rect(x,y,600,1),fg,txt)	
		
		pygame.display.flip()
예제 #3
0
def capture_vid():
    count = 0
    i=0
    font = pygame.font.SysFont("default", 24)
    while True:
        events = pygame.event.get()
        for event in events:
            if event.type == QUIT or event.type == KEYDOWN:
                sys.exit(0)
        im = webcam.getImage(0)
        #im,count = do_Display(im,count)
        pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
        time_text = time.asctime(time.localtime(time.time()))
        bg = (0,192,255)
        text.write(pg_img,font,(20,20),bg,time_text)
        text.write(pg_img,font,(20,45),bg,'Temperatur Pos 1 ')
        text.write(pg_img,font,(20,70),bg,'Temperatur Pos 2 ')
        screen.blit(pg_img, (0,0))
        pygame.display.flip()
        
        #text.write(pg_img,font,(20,20),bg,"Hello World!")
        if i>100:
            #allowing the camera to focus
            #auto focus is really annoying
            pygame.image.save(window,("data\%05d.jpg" % (i -100)))
            #im.save("image_"+str(i-100)+"", "JPEG")
        i=i+1
        print i
        
        pygame.time.delay(int(1000 * 1.0/fps))
예제 #4
0
	def paint(self,screen):
		self.game.score = 0
		screen.blit(self.img,(0,0))
		
		g = self.game
		hi = (128,128,128)
		fg = (255,255,255)
		
		fnt = g.font_title
		text.write(screen,fnt,(125,10),fg,"dynamite",border=2)
		
		fnt = g.font_menu
		x,y = 180,160
		

		c = fg
		#text.write(screen,fnt,(x,y),c,"High: %05d"%g.high,border=1)
		text.write(screen,fnt,(x,y),c,"Name: %s_"%g.name,border=1)
		y += 70
		
		#x += 40

				
		n = 0
		self.rects = []
		for txt,st in self.options:
			c = fg
			if n == self.cur: c = hi
			txt = txt.replace("$l",levels.levels[g.level][1])
			text.write(screen,fnt,(x,y),c,txt,border=1)
			self.rects.append((pygame.Rect(0,y,640,45),n))
			y += 45
			n += 1
		
		fnt = g.font_small
		x = 80
		y += 28
		text.write(screen,fnt,(x,y),fg,"use left and right arrow keys to change level",border=1)
			
		pygame.display.flip()
예제 #5
0
	def paint(self,screen):
		g = self.game
		img = pygame.image.load(os.path.join("data","gfx","help.png"))
		screen.blit(img,(0,0))

		fnt = g.font_title
		fg = (255,255,255)
		text.write(screen,fnt,(80,10),fg,"High Scores",border=2)
		
		fnt = g.font_small
		
		cx = 20,60,220, 340,380,540
		
		cts = []
		cts.append(['','Overall Records','','','Your Records',''])
		cts.append(['','       ','','','        ',''])
		name = g.name
		for n in range(1,11):
			e = g.highs['_overall-%d'%n][0]
			
			h = g.highs['%s-%d'%(name,n)]
			if len(h) > 0: score = h[0].score
			else: score = 0
			
			cts.append(["%d."%n,e.name,"%05d"%e.score,"%d."%n,name,"%05d"%score])
		
		y = 170
		for ct in cts:		
			i = 0
			for t in ct:
				x,i = cx[i],i+1
				text.write(screen,fnt,(x,y),fg,t)
			y += 21
			
		y += 21
		text.write(screen,fnt,(120,y),fg,"high scores are on a per-level basis")
		
		pygame.display.flip()
예제 #6
0
                    showInventory=False
                else:
                    showInventory=True
            if event.key in [K_DOWN,K_UP,K_RIGHT,K_LEFT]:
                npcs=enemyUpdate(Rmap,npcs,guy)
            if attack==True:
                attackEnemy(direction,npcs,guy)
                
            new_position=movePlayer(direction,guy)
            if validMove(Rmap,new_position[0],new_position[1]):
                pos=new_position
                guy.x=pos[0]
                guy.y=pos[1]
                CollisionList(Rmap,npcs,guy)
                CollisionList(Rmap,items,guy)
    CleanMap(Rmap)
    Rmap=PlaceList(Rmap,npcs,9)
    Rmap=PlaceList(Rmap,items,6)

    windowSurface.fill(BLACK)
    drawDungeon(Rmap,guy)
    if showInventory==True:
        DisplayInventory(guy)
    DisplayVitals(guy)
    font = pygame.font.SysFont("default", 24)
    bg = (255,255,255)
    text.write(windowSurface,font,(0,0),bg,"Hello World!")
    gameState=checkGameState(guy,npcs,items)
    
    pygame.display.update()
    mainClock.tick(40)
예제 #7
0
import sys; sys.path.insert(0, "..")

from pgu import text

pygame.font.init()

screen = pygame.display.set_mode((640,480),SWSURFACE)
fg = (0,0,0)
bg = (0,192,255)
screen.fill(bg)
bg = (255,255,255)

font = pygame.font.SysFont("default", 24)

##::
text.write(screen,font,(0,0),bg,"Hello World!")
text.writec(screen,font,bg,"Centered Text")
text.writepre(screen,font,pygame.Rect(160,48,320,100),fg,"""This is some
preformatted
    t e  x   t""")
text.writewrap(screen,font,pygame.Rect(160,268,320,100),fg,"""This is some text that will wrap automatically. This is some text that will wrap automatically.
 
This is some text that will wrap automatically. This is some text that will wrap automatically.""")
##
    
pygame.display.flip()

_quit = 0
while not _quit:
    for e in pygame.event.get():
        if e.type is QUIT: _quit = 1
예제 #8
0
sys.path.insert(0, "..")

from pgu import text

pygame.font.init()

screen = pygame.display.set_mode((640, 480), SWSURFACE)
fg = (0, 0, 0)
bg = (0, 192, 255)
screen.fill(bg)
bg = (255, 255, 255)

font = pygame.font.SysFont("default", 24)

##::
text.write(screen, font, (0, 0), bg, "Hello World!")
text.writec(screen, font, bg, "Centered Text")
text.writepre(screen, font, pygame.Rect(160, 48, 320, 100), fg, """This is some
preformatted
    t e  x   t""")
text.writewrap(
    screen, font, pygame.Rect(160, 268, 320, 100), fg,
    """This is some text that will wrap automatically. This is some text that will wrap automatically.
 
This is some text that will wrap automatically. This is some text that will wrap automatically."""
)
##

pygame.display.flip()

_quit = 0