1001 Freelance Projects
Latest Projects from
Freelance Marketplaces
View Project
View this project in detail
(Note: you will be redirected to external marketplace)
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:
View this project in detail
(Note: you will be redirected to external marketplace)
Last Projects / Browse Projects
  Project Started
Logo Design and Graphic Shirt/Hoodie Designs for Basketball Theme
Category: Graphic Design, Illustration, Logo Design, Photoshop, T Shirts
Budget: $50 - $100 USD
21 Nov 2025 20:50 GMT
Migration of SaaS CRM Platform to Laravel 11 and Next.js
Category: HTML, Laravel, MySQL, Next.js, PHP, Web Design
Budget: €5000 - €10000 EUR
21 Nov 2025 20:32 GMT
CRM Telecalling for Realtors
Category: Account Management, Business Development, CRM, Customer Service, Lead Generation, Marketing, Real Estate, Sales, Telemarketing
Budget: ₹100 - ₹400 INR
21 Nov 2025 17:04 GMT
Fix Push Notifications Issue
Category: Database Management, JavaScript, Linux, Node.js, PHP, React.js, Web API, Web Development
Budget: £20 - £250 GBP
21 Nov 2025 17:03 GMT
Synchronisation GitHub et App Mobile
Category: Android, Git, GitHub, IOS Development, IPhone, Mobile App Development, PhoneGap, React Native
Budget: $30 - $250 USD
21 Nov 2025 17:03 GMT
SketchUp Interior Walkthrough Video
Category: 3D Animation, 3D Modelling, 3D Rendering, 3ds Max, Architectural Visualization, SketchUp, V Ray, Video Editing
Budget: €30 - €250 EUR
21 Nov 2025 17:01 GMT
English-Iraqi Arabic Website Translation
Category: Content Management System (CMS), Content Writing, Copywriting, Customer Experience, Product Descriptions, Translation, Website Localization
Budget: ₹1500 - ₹12500 INR
21 Nov 2025 17:01 GMT
Experto en Salesforce Marketing Cloud
Category: Automation, CRM, Customer Retention, Data Analysis, Data Integration, Email Marketing, Salesforce Marketing Cloud, SQL
Budget: $250 - $750 USD
21 Nov 2025 17:01 GMT
Employee Handbook Creation
Category: Business Writing, Content Development, Content Writing, Documentation, Editing, Human Resources, Technical Writing, Writing
Budget: $30 - $250 USD
21 Nov 2025 17:00 GMT
Make a wordpress website with elementor based on my figma design
Category: Coding, Elementor, Email Marketing, Figma, Web Design, WordPress
Budget: $30 - $50 USD
21 Nov 2025 17:00 GMT
I have got my job portal already developed theough web development company. Now i want to launch the same in market with soefic focused areas and niche. Inwant social media professional who can work on promoting brand through social media audience follow
Category: Brand Management, Content Creation, Digital Marketing, Email Marketing, Facebook Marketing, Graphic Design, Influencer Marketing, Social Media Marketing
Budget: ₹12500 - ₹37500 INR
21 Nov 2025 16:59 GMT
Strategi Dana Medis Mendesak
Category: Article Writing, Catch Phrases, Copywriting, Crowdfunding, Digital Marketing, Fundraising, Grant Writing, Product Descriptions
Budget: $25 - $50 USD
21 Nov 2025 16:59 GMT
Facebook Lead-Gen Campaign Manager
Category: Content Strategy, Conversion Rate Optimization, Digital Marketing, Facebook Ads, Facebook Marketing, Facebook Pixel, Lead Generation, Social Media Marketing
Budget: $8 - $15 USD
21 Nov 2025 16:59 GMT
Administrative Assistant for Australian Building & Design Firm (8–12 Month Contract, 25–35 hrs/week)
Category: Admin Support, AutoCAD, Building Design, Construction Management, Customer Service, Excel, Project Management, Time Management, Training
Budget: ₹400 - ₹750 INR
21 Nov 2025 16:59 GMT
Minimalistic Corporate Mural
Category: Art Installation, Graphic Design, Illustration, Mural Painting
Budget: $3000 - $5000 USD
21 Nov 2025 16:57 GMT
Browse All Projects
Projects by Skills ...
android
ajax
asp
aspnet
cms
cpp
csharp
css
delphi
design
drupal
excel
facebook
flash
html
java
javascript
joomla
iphone
mysql
photoshop
php
python
ruby
seo
sql
sysadm
translate
typing
twitter
vbnet
xml
wordpress
writing
New!
Проекты на русском
(Projects in Russian)

Copyright © 2005-2024
1001 Freelance Projects