How to use the pygame.display.set_caption function in pygame

To help you get started, we’ve selected a few pygame examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kidscancode / gamedev / tutorials / platform-tests / plat-test3.py View on Github external
WIDTH = 800
HEIGHT = 640
FPS = 60

# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)

pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Run!!!")
clock = pygame.time.Clock()

class Platform(pygame.sprite.Sprite):
    def __init__(self, x, y, w, h, vx, vy):
        super(Platform, self).__init__()
        self.image = pygame.Surface((w, h))
        self.image.fill(GREEN)
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y
        self.vx = vx
        self.vy = vy

    def update(self):
        self.rect.x += self.vx
        # shift the player if we hit
github buckyroberts / Source-Code-from-Tutorials / Pygame / 73_PythonGameDevelopment.py View on Github external
import pygame
import time
import random

pygame.init()

display_width = 800
display_height = 600

gameDisplay = pygame.display.set_mode((display_width,display_height))


pygame.display.set_caption('Tanks')

#icon = pygame.image.load("apple.png")       
#pygame.display.set_icon(icon)

white = (255,255,255)
black = (0,0,0)


red = (200,0,0)
light_red = (255,0,0)

yellow = (200,200,0)
light_yellow = (255,255,0)

green = (34,177,76)
light_green = (0,255,0)
github ehmatthes / pcc / chapter_14 / alien_invasion.py View on Github external
def run_game():
    # Initialize pygame, settings, and screen object.
    pygame.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Alien Invasion")
    
    # Make the Play button.
    play_button = Button(ai_settings, screen, "Play")
    
    # Create an instance to store game statistics, and a scoreboard.
    stats = GameStats(ai_settings)
    sb = Scoreboard(ai_settings, screen, stats)
    
    # Set the background color.
    bg_color = (230, 230, 230)
    
    # Make a ship, a group of bullets, and a group of aliens.
    ship = Ship(ai_settings, screen)
    bullets = Group()
    aliens = Group()
github pygame / pygame / examples / arraydemo.py View on Github external
def surfdemo_show(array_img, name):
    "displays a surface, waits for user to continue"
    screen = pygame.display.set_mode(array_img.shape[:2], 0, 32)
    surfarray.blit_array(screen, array_img)
    pygame.display.flip()
    pygame.display.set_caption(name)
    while 1:
        e = pygame.event.wait()
        if e.type == MOUSEBUTTONDOWN:
            break
        elif e.type == KEYDOWN and e.key == K_s:
            # pygame.image.save(screen, name+'.bmp')
            # s = pygame.Surface(screen.get_size(), 0, 32)
            # s = s.convert_alpha()
            # s.fill((0,0,0,255))
            # s.blit(screen, (0,0))
            # s.fill((222,0,0,50), (0,0,40,40))
            # pygame.image.save_extended(s, name+'.png')
            # pygame.image.save(s, name+'.png')
            # pygame.image.save(screen, name+'_screen.png')
            # pygame.image.save(s, name+'.tga')
            pygame.image.save(screen, name + ".png")
github spiraltechnica / Spout-for-Python / Examples / spout_sender_example.py View on Github external
def main():

    # window details
    width = 800 
    height = 600 
    display = (width,height)
    
    # window setup
    pygame.init() 
    pygame.display.set_caption('Spout Python Sender')
    pygame.display.set_mode(display, DOUBLEBUF|OPENGL)
    pygame.display.gl_set_attribute(pygame.GL_ALPHA_SIZE, 8)

    # OpenGL init
    # setup OpenGL perspective
    glMatrixMode(GL_PROJECTION)
    gluPerspective(45, (display[0]/display[1]), 0.1, 50.0)
    # setup default colours, blending modes, rotation and translation parameters
    glMatrixMode(GL_MODELVIEW)
    # reset the drawing perspective
    glLoadIdentity()
    # can disable depth buffer because we aren't dealing with multiple geometry in our scene
    glDisable(GL_DEPTH_TEST)
    glEnable(GL_ALPHA_TEST)
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
github Revolutionary-Games / thrive-prototypes / patch_map / patch_map.py View on Github external
import pygame
import math
import random
from pygame.locals import *
from pygame import gfxdraw

#setup

background_colour = (0,0,0)
(width, height) = (1000, 600)

screen = pygame.display.set_mode((width, height))#,pygame.FULLSCREEN)
screen.fill(background_colour)
pygame.display.set_caption('Patch Map')
pygame.font.init()

myfont = pygame.font.SysFont("monospace", 20, bold = True)
bg = pygame.image.load("bg.png")

clock = pygame.time.Clock()

def draw_aa_circle(colour, pos, radius):
	pygame.gfxdraw.filled_circle(screen, pos[0], pos[1], radius, colour)
	pygame.gfxdraw.aacircle(screen, pos[0], pos[1], radius, colour)

def distance(a,b):
	return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)

def interpolate(maxi, mini, value):
	return ((value-mini)/(maxi - mini))
github luciotorre / spacecraft / spacecraft / monitor.py View on Github external
def main(size):

    pygame.init()
    pygame.font.init()
    pygame.display.set_caption('monitor')
    screen = pygame.display.set_mode(size)

    reactor.connectTCP("localhost", 11105, MonitorFactory(screen))
github buckyroberts / Source-Code-from-Tutorials / Pygame / 28_PythonGameDevelopment.py View on Github external
import pygame
import time
import random

pygame.init()

white = (255,255,255)
black = (0,0,0)
red = (255,0,0)
green = (0,155,0)

display_width = 800
display_height  = 600

gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('Slither')



clock = pygame.time.Clock()

block_size = 20
FPS = 30

font = pygame.font.SysFont(None, 25)

def snake(block_size, snakelist):
    for XnY in snakelist:
        pygame.draw.rect(gameDisplay, green, [XnY[0],XnY[1],block_size,block_size])

def text_objects(text,color):
    textSurface = font.render(text, True, color)
github buckyroberts / Source-Code-from-Tutorials / Pygame / 82_PythonGameDevelopment.py View on Github external
import pygame
import time
import random

pygame.init()

display_width = 800
display_height = 600

gameDisplay = pygame.display.set_mode((display_width,display_height))


pygame.display.set_caption('Tanks')

#icon = pygame.image.load("apple.png")       
#pygame.display.set_icon(icon)

white = (255,255,255)
black = (0,0,0)


red = (200,0,0)
light_red = (255,0,0)

yellow = (200,200,0)
light_yellow = (255,255,0)

green = (34,177,76)
light_green = (0,255,0)
github openhumanoids / oh-distro / ros_workspace / irobot-hand / Software / 2013_08_07_full / handle / handle_launch / launch / power_grasp_keyboard_teleop.py View on Github external
print "Example 1: a fully open cylindrical grasp for the left/only hand "
  print "is commnanded by pressing 'q'. For the right hand, press 'y'."
  print ""
  print "Example 2: fully closed spherical grasp for the left/only hand "
  print "is commanded by pressing 'g'. For the right hand, press ';'."
  print ""
  print "Press [escape] to quit."

def draw_string(screen, font, x, y, string):
  text = font.render(string, 1, (255,255,255))
  screen.blit(text, (x, y))

if __name__ == '__main__':
  pygame.init()
  screen = pygame.display.set_mode((640, 480))
  pygame.display.set_caption('Minimalist Dual-Hand Keyboard Teleop For IRobot Hand')
  font = pygame.font.Font(None, 18)
  draw_string(screen, font, 10, 10, "This window must have focus")
  draw_string(screen, font, 10, 30, "Press [escape] to quit.")
  pygame.display.flip()
  print_usage()
  rospy.init_node("power_grasp_keyboard_teleop")
  g_left_grasp_pub  = rospy.Publisher("irobot_hands/l_hand/control", HandleControl)
  g_right_grasp_pub = rospy.Publisher("irobot_hands/r_hand/control", HandleControl)
  rate = rospy.Rate(100.0) # todo: something smarter
  done = False
  while not done and not rospy.is_shutdown():
    for event in pygame.event.get():
      if (event.type == KEYDOWN):
        if event.key == K_ESCAPE:
          done = True
        elif event.key < 128: