diff --git a/Programs/SpeedKey Game Pygame(Pratap2018)/README.md b/Programs/SpeedKey Game Pygame(Pratap2018)/README.md new file mode 100644 index 0000000..94d8bd6 --- /dev/null +++ b/Programs/SpeedKey Game Pygame(Pratap2018)/README.md @@ -0,0 +1,25 @@ +# Speed Key Game (Using Pygame) + +Simple Game Built In Pygame + +Letters will fall from sky and game player need to press that key. If Displayed Key and the key stroke is same then that is a score. + +If Wrong Keypress or it falls to the bottom then game over + +### Prerequisites + +pygame + +python + +pip install pygame + +### Screenshot/GIF showing the sample use of the program + +Add a jpeg/png/gif file here.(If possible) +![Gif image](myvideos.gif) + +## *Author Name* + + +[Pratap Mridha](https://github.com/Pratap2018) diff --git a/Programs/SpeedKey Game Pygame(Pratap2018)/SpeedKey.py b/Programs/SpeedKey Game Pygame(Pratap2018)/SpeedKey.py new file mode 100644 index 0000000..3197e98 --- /dev/null +++ b/Programs/SpeedKey Game Pygame(Pratap2018)/SpeedKey.py @@ -0,0 +1,106 @@ +# Simple pygame program + +# Import and initialize the pygame library +import pygame +import random +pygame.init() +fpsclock=pygame.time.Clock() +pygame.display.set_caption("Speed Key") +# Set up the drawing window +screen = pygame.display.set_mode([800, 600]) +icon=pygame.image.load("game-controller.png") +pygame.display.set_icon(icon) +object_x=pygame.image.load("home-plate.png") +def object(x,y,letter): + screen.blit(object_x,(x,y)) + font = pygame.font.SysFont(None, 30) + img = font.render(letter, True, (0,255,0)) + screen.blit(img, (x+22,y+18)) + +# Run until the user asks to quit +running = True +x=random.randint(0,800-64) +y=random.randint(0,50) +letter="S" +score=0 +key='None' +screen.fill((10,10,0)) + +intro=True +while intro: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + intro=False + running=False + font = pygame.font.Font(None, 36) + text = font.render("Press any Key To Start", True, (255,255,255)) + text_rect = text.get_rect() + text_x = screen.get_width() / 2 - text_rect.width / 2 + text_y = screen.get_height() / 2 - text_rect.height / 2 + screen.blit(text, [text_x, text_y]) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + + if event.type==pygame.KEYDOWN: + intro=False + pygame.display.update() + + +while running: + + + + screen.fill((10,10,0)) + font = pygame.font.Font(None, 36) + text = font.render("Score : "+str(score), True, (255,255,255)) + text_rect = text.get_rect() + text_x = 650 + text_y = 0 + screen.blit(text, [text_x, text_y]) + text = font.render("Key Pressed:"+key, True, (255,255,255)) + text_rect = text.get_rect() + text_x = 0 + text_y = 0 + screen.blit(text, [text_x, text_y]) + object(x,y,letter) + + # Did the user click the window close button? + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + if not y>550: + + if event.type==pygame.KEYDOWN: + key=pygame.key.name(event.key).upper() + if letter == key: + score=score+1 + x=random.randint(0,800-64) + y=random.randint(0,50) + letter=random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ') + else: + y=560 + + + # Fill the background with white + + y=y+2 + if y>550: + font = pygame.font.Font(None, 36) + text = font.render("Game Over Score :"+str(score), True, (255,255,255)) + text_rect = text.get_rect() + text_x = screen.get_width() / 2 - text_rect.width / 2 + text_y = screen.get_height() / 2 - text_rect.height / 2 + screen.blit(text, [text_x, text_y]) + + + + + + + pygame.display.update() + fpsclock.tick(170) + + +# Done! Time to quit. +pygame.quit() \ No newline at end of file diff --git a/Programs/SpeedKey Game Pygame(Pratap2018)/game-controller.png b/Programs/SpeedKey Game Pygame(Pratap2018)/game-controller.png new file mode 100644 index 0000000..f9bc02b Binary files /dev/null and b/Programs/SpeedKey Game Pygame(Pratap2018)/game-controller.png differ diff --git a/Programs/SpeedKey Game Pygame(Pratap2018)/home-plate.png b/Programs/SpeedKey Game Pygame(Pratap2018)/home-plate.png new file mode 100644 index 0000000..e0b5c04 Binary files /dev/null and b/Programs/SpeedKey Game Pygame(Pratap2018)/home-plate.png differ diff --git a/Programs/SpeedKey Game Pygame(Pratap2018)/myvideos.gif b/Programs/SpeedKey Game Pygame(Pratap2018)/myvideos.gif new file mode 100644 index 0000000..1fac77e Binary files /dev/null and b/Programs/SpeedKey Game Pygame(Pratap2018)/myvideos.gif differ