Project title:
program to devlope offline game
Posted by:
External project from PeoplePerHour
Started:
05-Dec-2024 12:49 GMT
Description:
import pygame import random import time # Initialize pygame pygame.init() # Game Constants SCREEN_WIDTH = 600 SCREEN_HEIGHT = 400 FPS = 60 # Colors WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = (0, 255, 0) BLACK = (0, 0, 0) # Initialize the screen screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption("Dodge the Falling Objects") # Clock object to control game speed clock = pygame.time.Clock() # Game variables player_width = 50 player_height = 50 player_x = SCREEN_WIDTH // 2 player_y = SCREEN_HEIGHT - player_height - 10 player_speed = 5 obstacle_width = 30 obstacle_height = 30 obstacle_speed = 5 obstacles = [] score = 0 # Fonts font = pygame.font.SysFont('Arial', 30) # Function to draw the player def draw_player(x, y): pygame.draw.rect(screen, GREEN, (x, y, player_width, player_height)) # Function to draw obstacles def draw_obstacles(obstacles): for obstacle in obstacles: pygame.draw.rect(screen, RED, obstacle) # Function to handle collisions def check_collision(player_rect, obstacles): for obstacle in obstacles: if player_rect.colliderect(obstacle): return True return False # Main game loop def game_loop(): global player_x, score running = True player_rect = pygame.Rect(player_x, player_y, player_width, player_height) while running: screen.fill(WHITE) # Event handling for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # Get the keys pressed keys = pygame.key.get_pressed() # Move the player if keys[pygame.K_LEFT] and player_x > 0: player_x -= player_speed if keys[pygame.K_RIGHT] and player_x SCREEN_HEIGHT: obstacles.remove(obstacle) score += 1 # Check for collisions if check_collision(player_rect, obstacles): running = False # End the game if there is a collision # Draw everything draw_player(player_x, player_y) draw_obstacles(obstacles) # Display the score score_text = font.render(f"Score: {score}", True, BLACK) screen.blit(score_text, (10, 10)) # Update the display pygame.display.update() # Frame rate clock.tick(FPS) # Game Over Screen game_over_text = font.render("Game Over", True, BLACK) screen.blit(game_over_text, (SCREEN_WIDTH // 2 - 100, SCREEN_HEIGHT // 2 - 30)) pygame.display.update() time.sleep(2) # Pause before quitting pygame.quit() # Run the game game_loop()
Project ID:
3411300
Project category:
Project budget:
Project
Started
Revamp Law Firm WordPress Website
Category : API Integration, Graphic Design, HTML, PHP, User Interface / IA, Web Design, Web Development, Website Optimization, WordPress Budget : $250 - $750 USD
12 Mar 2026 23:04 GMT
VTuber Character Gear System (3D Modeling + Unity Toggle System)
Category : 3D Animation, 3D Design, 3D Modelling, Blender, C#, Programming, Game Design, Game Development, Mobile App Development, Unity, Unity 3D Budget : $30 - $250 USD
12 Mar 2026 23:03 GMT
21 Instagram Reels and 7 Carousels
Category : 2D Animation, Adobe Illustrator, Photoshop, Animation, Caricature & Cartoons, Graphic Design, Illustration, Video Editing, Video Production Budget : $10 - $30 USD
12 Mar 2026 23:02 GMT
Corporate Webpage Design for Buyers Advocate
Category : Graphic Design, HTML, PHP, Web Design, Web Development Budget : $250 - $750 AUD
12 Mar 2026 22:59 GMT
Custom Shopify Theme Build
Category : CSS, HTML, JavaScript, SEO, Shopify Development, Shopify Templates, Web Design, Web Development Budget : $10 - $30 USD
12 Mar 2026 22:59 GMT
Residential Roof Integration for Home Extension
Category : 3D Rendering, AutoCAD, Building Architecture, Building Design, Building Engineering, Construction, Roofing Budget : $30 - $250 USD
12 Mar 2026 22:57 GMT
Amazon PPC Specialist for Campaign Optimization
Category : Amazon Ads, Data Analysis, Digital Marketing, Internet Marketing, Keyword Research, Link Building, PPC Marketing, SEO Budget : $30 - $250 USD
12 Mar 2026 22:57 GMT
Herbal Spa Treatments and services
Category : Customer Service, WordPress Multilingual Budget : ₹750 - ₹1250 INR
12 Mar 2026 22:47 GMT
Wedding Photo Edit
Category : Digital Art, Graphic Design, Image Consultation, Image Processing, Photo Editing, Photo Restoration, Photo Retouching, Photoshop, Photoshop Design, Visual Design Budget : $30 - $250 USD
12 Mar 2026 22:46 GMT
Drive Leads, Boost Website Traffic
Category : Analytics, Email Marketing, Internet Marketing, Link Building, Marketing, SEO Budget : $30 - $250 AUD
12 Mar 2026 22:46 GMT
Meta Leads-to-AFOS Automation
Category : API Development, CRM, Data Integration, Facebook API, Facebook Pixel, Instagram API, Make.com, PHP Budget : $30 - $250 AUD
12 Mar 2026 22:46 GMT
Calculate Accurate Square Footage From CAD Floor Plan (Color-Coded Areas)
Category : 2D Drafting, 2D Drawing, 3D Design, 3D Modelling, 3D Rendering, AutoCAD, Autodesk Revit, Data Analysis, Revit, SketchUp Budget : $10 - $30 USD
12 Mar 2026 22:44 GMT
AI Law PhD Proposal Writing
Category : Academic Writing, Artificial Intelligence, Corporate Law, Employment Law, Legal, Legal Analysis, Legal Research, Research, Research Writing, Technology Law Budget : $15 - $25 USD
12 Mar 2026 22:41 GMT
Afan Oromo Document Translation Needed - 12/03/2026 18:28 EDT
Category : English (US) Translator, English Translation, Language Tutoring, Logo Design, Proofreading, Video Services Budget : $250 - $750 USD
12 Mar 2026 22:40 GMT
Multi-Service Marketplace App Development
Category : Android, Flutter, IPhone, Laravel, Mobile App Development, Node.js, PHP, Spanish Translator Budget : $250 - $750 USD
12 Mar 2026 22:40 GMT
Browse All Projects