Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5c64a71
Added new feature in the existing GST calculator
tanujbordikar Aug 4, 2023
0b9e78c
Added new feature in the existing GST calculator
tanujbordikar Aug 4, 2023
2cffc8f
Improved the calculator by using tkinter
tanujbordikar Aug 4, 2023
0ad6ecc
added the screenshot with tkinter gui and also created a new document…
tanujbordikar Aug 5, 2023
369dcbe
added techCrunch.py
Mihan786Chistie Aug 5, 2023
af89634
updated techCrunch.py
Mihan786Chistie Aug 5, 2023
f1ae4ed
updated techCrunch.py
Mihan786Chistie Aug 5, 2023
58c7c6d
added README.md
Mihan786Chistie Aug 5, 2023
3f15a8f
updated techCrunch.py
Mihan786Chistie Aug 5, 2023
2dc2121
added requirements.txt
Mihan786Chistie Aug 5, 2023
e5d8c91
Pixel Art Generator Script Added
andoriyaprashant Aug 5, 2023
eeda4e1
Lint Fix
andoriyaprashant Aug 5, 2023
ac34009
culturally-inspired names imaginary
Swapnil-2503 Aug 5, 2023
66af624
morphological transformations
invigorzz313 Aug 5, 2023
31a905e
Infinite Runner with Obstacles Script Added
andoriyaprashant Aug 5, 2023
46c36bf
Gomoku_game.py
Shikhar9425 Aug 6, 2023
ac814f2
README.md
Shikhar9425 Aug 6, 2023
0171cee
Adding code, README file
MrResilient Aug 8, 2023
2328db2
Adding code, README file
MrResilient Aug 8, 2023
8a9853c
Merge branch 'cont1' of https://github.com/Shivansh-Jain-github/Amazi…
MrResilient Aug 8, 2023
eec9f8b
Merge pull request #2687 from Shivansh-Jain-github/master
1e9abhi1e10 Aug 8, 2023
14d473a
Merge pull request #2686 from Shivansh-Jain-github/cont1
1e9abhi1e10 Aug 8, 2023
a741426
Completed payment receipt project
Yashika-Agrawal Aug 8, 2023
2d2d94b
Merge pull request #2691 from Yashika-Agrawal/Payment
1e9abhi1e10 Aug 8, 2023
3250119
Adding code, README.md file
MrResilient Aug 8, 2023
84f20e8
Adding code, README.md file
MrResilient Aug 8, 2023
83f766a
Add commit
MrResilient Aug 8, 2023
51cf405
Delete
MrResilient Aug 8, 2023
fabfd2c
delete
MrResilient Aug 8, 2023
034c8d4
Merge pull request #2696 from Shivansh-Jain-github/CONT1
1e9abhi1e10 Aug 8, 2023
42b6943
Merge pull request #2695 from Shivansh-Jain-github/cont1
1e9abhi1e10 Aug 8, 2023
2efacbb
Merge pull request #2668 from Shikhar9425/master-8
1e9abhi1e10 Aug 8, 2023
57fe6d4
Merge pull request #2639 from Swapnil-2503/culturally-inspired-names
1e9abhi1e10 Aug 8, 2023
bfb1e89
Merge pull request #2635 from Mihan786Chistie/techCrunch
1e9abhi1e10 Aug 8, 2023
b25ce3d
Merge pull request #2650 from andoriyaprashant/branch28
1e9abhi1e10 Aug 8, 2023
a9dee15
Merge pull request #2637 from andoriyaprashant/branch27
1e9abhi1e10 Aug 8, 2023
8890205
Merge pull request #2640 from invigorzz313/morphtransforms
1e9abhi1e10 Aug 8, 2023
148eaea
Merge pull request #2631 from tanujbordikar/screenshot
1e9abhi1e10 Aug 8, 2023
4d01156
True False Automation
MrResilient Aug 8, 2023
c58725c
WhatsApp_timer_messenger code
MrResilient Aug 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Infinite Runner with Customizable Obstacles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Infinite Runner with Customizable Obstacles

This is a simple Infinite Runner game implemented in Python using the Pygame library. The player runs endlessly through a procedurally generated landscape while avoiding various obstacles. What sets this game apart is the ability for the player to encounter multiple types of obstacles: rectangular, triangular, and rotating circular obstacles.

## Features

- Endless runner gameplay with customizable obstacles.
- Three types of obstacles: rectangular, triangular, and rotating circular.
- Player can move left, right, and jump using arrow keys and spacebar.
- Scoring system to keep track of player progress.
- Background music, sound effects for jumping and collisions.

## Prerequisites

- Python
- Pygame library (`pip install pygame`)

## How to Run

1. Install the required Pygame library using `pip`:

```bash
pip install pygame
```

2. Download or clone the repository.

3. Run the game script:

```bash
python infinite_runner.py
```

5. Use the left and right arrow keys to move the player character.
6. Press the spacebar to make the player character jump.

## Gameplay

- The objective of the game is to survive for as long as possible without colliding with any obstacles.
- Rectangular obstacles move straight down, triangular obstacles move diagonally, and circular obstacles rotate while moving down.
- The player can collect points by running and avoiding collisions with obstacles.

## Customization

- You can customize the appearance and movement of obstacles by modifying the obstacle generation and update logic in the script.
- Feel free to add more obstacle types or enhance the gameplay to suit your preferences.


141 changes: 141 additions & 0 deletions Infinite Runner with Customizable Obstacles/infinite_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import pygame
import random
import math

# Initialize Pygame
pygame.init()

# Screen dimensions
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600

# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)

# Create the screen
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Infinite Runner with Customizable Obstacles")

# Load sound effects and background music
pygame.mixer.music.load("background_music.mp3")
jump_sound = pygame.mixer.Sound("jump_sound.wav")
collision_sound = pygame.mixer.Sound("collision_sound.wav")

# Scoring
score = 0
font = pygame.font.Font(None, 36)

# Player attributes
player_width = 50
player_height = 50
player_x = SCREEN_WIDTH // 2 - player_width // 2
player_y = SCREEN_HEIGHT - player_height - 20
player_speed = 5

# Obstacle attributes
obstacle_width = 100
obstacle_height = 20
obstacle_speed = 5
obstacles = []

# Game loop
running = True
clock = pygame.time.Clock()
pygame.mixer.music.play(-1)

while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False

# Input handling - left and right arrow keys
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and player_x > 0:
player_x -= player_speed
if keys[pygame.K_RIGHT] and player_x < SCREEN_WIDTH - player_width:
player_x += player_speed

# Jumping with Spacebar
if keys[pygame.K_SPACE] and player_y == SCREEN_HEIGHT - player_height - 20:
player_y -= 10
jump_sound.play()

# Apply gravity
if player_y < SCREEN_HEIGHT - player_height - 20:
player_y += 5

# Add a new obstacle randomly
if random.randint(0, 100) < 2:
obstacle_type = random.choice(["rect", "tri", "circle"])
obstacle_x = random.randint(0, SCREEN_WIDTH - obstacle_width)

if obstacle_type == "circle":
obstacle_x = random.randint(0, SCREEN_WIDTH - obstacle_width - 50)

obstacles.append((obstacle_x, -obstacle_height, obstacle_type))

# Update obstacle positions
for i, (obstacle_x, obstacle_y, obstacle_type) in enumerate(obstacles):
if obstacle_type == "rect":
# Rectangular obstacle: move straight down
obstacles[i] = (obstacle_x, obstacle_y + obstacle_speed)
elif obstacle_type == "tri":
# Triangular obstacle: move diagonally
obstacles[i] = (obstacle_x + obstacle_speed, obstacle_y + obstacle_speed)
elif obstacle_type == "circle":
# Rotating circular obstacle: update the angle
angle = 0.1 # Adjust the rotation speed
rotated_obstacle_x = obstacle_x + (obstacle_width // 2)
rotated_obstacle_y = obstacle_y + (obstacle_height // 2)
obstacles[i] = (rotated_obstacle_x - obstacle_width // 2 * math.cos(angle),
rotated_obstacle_y - obstacle_height // 2 * math.sin(angle),
"circle")

# Remove obstacles that are off the screen
if obstacle_y > SCREEN_HEIGHT:
del obstacles[i]

# Check for collision with obstacles
if obstacle_y + obstacle_height > player_y and obstacle_y < player_y + player_height:
if obstacle_x + obstacle_width > player_x and obstacle_x < player_x + player_width:
# Game over
collision_sound.play()
running = False

# Save high score to a file (you can choose a different file path)
with open("high_score.txt", "w") as file:
file.write(str(score))

# Increase the score
score += 1

# Clear the screen
screen.fill(WHITE)

# Draw the player
pygame.draw.rect(screen, (0, 0, 255), (player_x, player_y, player_width, player_height))

# Draw the obstacles
for obstacle_x, obstacle_y, obstacle_type in obstacles:
if obstacle_type == "rect":
pygame.draw.rect(screen, (255, 0, 0), (obstacle_x, obstacle_y, obstacle_width, obstacle_height))
elif obstacle_type == "tri":
pygame.draw.polygon(screen, (0, 255, 0), [(obstacle_x, obstacle_y), (obstacle_x + obstacle_width, obstacle_y),
(obstacle_x + obstacle_width // 2, obstacle_y + obstacle_height)])
elif obstacle_type == "circle":
pygame.draw.circle(screen, (0, 0, 255), (int(obstacle_x + obstacle_width // 2),
int(obstacle_y + obstacle_height // 2)), obstacle_width // 2)

# Draw the score
score_text = font.render("Score: " + str(score), True, BLACK)
screen.blit(score_text, (10, 10))

# Update the screen
pygame.display.update()

# Set the frame rate
clock.tick(60)

# Quit the game
pygame.quit()
3 changes: 3 additions & 0 deletions Infinite Runner with Customizable Obstacles/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pygame
random
math