Skip to content

Commit 2cdc63f

Browse files
authored
Merge branch 'main' into footer-card-section
2 parents cc28932 + 0a9b6a4 commit 2cdc63f

6 files changed

Lines changed: 452 additions & 447 deletions

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ python games/Rock-Paper-Scissor/Rock-Paper-Scissor.py
6868

6969
## 🙌 Contributors
7070

71+
- Lavanya-Talele
72+
73+
7174
- advikdivekar
7275

7376

@@ -301,6 +304,20 @@ Find all the hidden differences between two interactive canvases!
301304
- ⏱️ Built-in timer and hint system
302305
- 🌐 *Web App Exclusive Project*
303306

307+
</td>
308+
</tr>
309+
<tr>
310+
<td width="50%">
311+
312+
#### 🐦 Flappy Game
313+
Fly through pipes and survive as long as possible!
314+
- 🦅 Interactive jump mechanics
315+
- 💥 Collision detection
316+
- 🏆 High score tracking
317+
```bash
318+
python games/Flappy-Game/Flappy-Game.py
319+
```
320+
304321
</td>
305322
</tr>
306323
</table>

games/Flappy-Game/Flappy-Game.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
from random import randrange
2+
from turtle import *
3+
import math
4+
5+
class Vector:
6+
def __init__(self, x, y):
7+
self.x = x
8+
self.y = y
9+
10+
def move(self, other):
11+
"""move this vector by adding another vector to it"""
12+
self.x += other.x
13+
self.y += other.y
14+
15+
def __sub__(self, other):
16+
"""subtract two vectors to find the difference"""
17+
return Vector(self.x - other.x, self.y - other.y)
18+
19+
def __abs__(self):
20+
return math.hypot(self.x, self.y)
21+
22+
bird = Vector(0, 0)
23+
balls = []
24+
score = 0
25+
game_over = False
26+
27+
def tap(x, y):
28+
"""move bird up in response to screen tap or reset if dead"""
29+
global game_over
30+
31+
if game_over:
32+
reset_game()
33+
else:
34+
up = Vector(0, 30)
35+
bird.move(up)
36+
37+
def reset_game():
38+
"""resets the game state and starts the loop again"""
39+
global game_over, score
40+
game_over = False
41+
score = 0
42+
bird.x, bird.y = 0, 0
43+
balls.clear()
44+
move()
45+
46+
def inside(point):
47+
"""return True if point on screen"""
48+
return -200 < point.x < 200 and -200 < point.y < 200
49+
50+
def draw(alive):
51+
clear()
52+
53+
goto(bird.x, bird.y)
54+
if alive:
55+
dot(10, '#06b6d4')
56+
else:
57+
dot(10, '#ef4444')
58+
59+
for ball in balls:
60+
goto(ball.x, ball.y)
61+
dot(20, '#8b5cf6')
62+
63+
goto(-190, 180)
64+
color('white')
65+
write(f"Score: {score}", font=("Arial", 14, "bold"))
66+
67+
if not alive:
68+
goto(0, 20)
69+
write("💥 GAME OVER 💥", align="center", font=("Arial", 24, "bold"))
70+
goto(0, -20)
71+
write("🔄 Click anywhere to Play Again", align="center", font=("Arial", 14, "normal"))
72+
73+
update()
74+
75+
def move():
76+
"""update object positions"""
77+
global score, game_over
78+
79+
if game_over:
80+
return
81+
82+
bird.y -= 5
83+
84+
for ball in balls:
85+
ball.x -= 3
86+
87+
if randrange(10) == 0:
88+
y = randrange(-199, 199)
89+
ball = Vector(199, y)
90+
balls.append(ball)
91+
92+
while len(balls) > 0 and not inside(balls[0]):
93+
balls.pop(0)
94+
score += 1
95+
96+
if not inside(bird):
97+
game_over = True
98+
draw(False)
99+
return
100+
101+
for ball in balls:
102+
if abs(ball - bird) < 15:
103+
game_over = True
104+
draw(False)
105+
return
106+
107+
draw(True)
108+
ontimer(move, 50)
109+
110+
setup(420, 420, 370, 0)
111+
bgcolor('#0f172a')
112+
hideturtle()
113+
up()
114+
tracer(False)
115+
onscreenclick(tap)
116+
move()
117+
done()

math/Prime-Number-Analyzer/Prime-Number-Analyzer.py

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
print("2. Generate prime numbers up to N")
99
print("3. Find primes in a range")
1010
print("4. Prime factorization")
11-
print("5. Exit")
12-
13-
choice = input("\nEnter your choice (1-5): ")
14-
11+
print("5. Find the Nth prime number")
12+
print("6. Exit")
13+
14+
choice = input("\nEnter your choice (1-6): ")
15+
1516
if choice == '1':
1617
print("\n" + "-" * 50)
1718
print("CHECK IF A NUMBER IS PRIME")
@@ -157,12 +158,45 @@
157158
print("Please enter a valid number!")
158159

159160
elif choice == '5':
161+
print("\n" + "-" * 50)
162+
print("FIND THE NTH PRIME NUMBER")
163+
print("-" * 50)
164+
165+
try:
166+
n = int(input("Enter the value of n: "))
167+
168+
if n <= 0:
169+
print("\nPlease enter a positive number!")
170+
else:
171+
count = 0
172+
num = 1
173+
174+
while count < n:
175+
num += 1
176+
is_prime = True
177+
divisor = 2
178+
179+
while divisor * divisor <= num:
180+
if num % divisor == 0:
181+
is_prime = False
182+
break
183+
divisor += 1
184+
185+
if is_prime:
186+
count += 1
187+
188+
print(f"\nThe {n}th prime number is: {num}")
189+
190+
except ValueError:
191+
print("Please enter a valid number!")
192+
193+
elif choice == '6':
160194
print("\n" + "=" * 50)
161195
print("Thank you for using Prime Number Analyzer!")
162196
print("=" * 50)
163197
break
164198

165199
else:
166-
print("\nInvalid choice! Please enter a number between 1 and 5.")
200+
print("\nInvalid choice! Please enter a number between 1 and 6.")
167201

168202
print("\n" + "=" * 50)

web-app/index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,15 @@ <h3>Whack-a-Mole</h3>
536536
<button class="btn-play">Try It</button>
537537
</div>
538538

539+
<div class="project-card" data-category="games" data-project="flappy-game">
540+
<div class="card-icon">🐦</div>
541+
<h3>Flappy Game</h3>
542+
<p>Dodge the incoming balls and survive!</p>
543+
<button class="btn-play">Try It</button>
544+
</div>
545+
546+
<div class="project-card" data-category="math" data-project="fibonacci"
547+
data-tags="math,sequence,series,loops,recursion">
539548
<div class="project-card" data-category="games" data-project="game2048"
540549
data-tags="game,puzzle,2048,logic,tiles">
541550
<div class="card-icon">🟦</div>
@@ -625,7 +634,6 @@ <h3>Derivative Calculator</h3>
625634
<button class="btn-play">Try It</button>
626635
</div>
627636

628-
<!-- UTILITIES -->
629637
<div class="project-card" data-category="utilities" data-project="morse-code"
630638
data-tags="utility,morse,translation,communication">
631639
<div class="card-icon">📻</div>

0 commit comments

Comments
 (0)