Skip to content

Commit e785246

Browse files
authored
Merge branch 'main' into feature/ui-improve
2 parents 594e922 + 9bfe4e6 commit e785246

9 files changed

Lines changed: 478 additions & 458 deletions

File tree

README.md

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

6969
## 🙌 Contributors
7070

71+
- nimkarprachi17
72+
73+
74+
- Lavanya-Talele
75+
76+
7177
- advikdivekar
7278

7379

@@ -301,6 +307,20 @@ Find all the hidden differences between two interactive canvases!
301307
- ⏱️ Built-in timer and hint system
302308
- 🌐 *Web App Exclusive Project*
303309

310+
</td>
311+
</tr>
312+
<tr>
313+
<td width="50%">
314+
315+
#### 🐦 Flappy Game
316+
Fly through pipes and survive as long as possible!
317+
- 🦅 Interactive jump mechanics
318+
- 💥 Collision detection
319+
- 🏆 High score tracking
320+
```bash
321+
python games/Flappy-Game/Flappy-Game.py
322+
```
323+
304324
</td>
305325
</tr>
306326
</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()

games/Number-Guessing-Game/Number-Guessing-Game.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
print("I'm thinking of a number between 1 and 100...\n")
88

99
while True:
10-
num = int(input("🤔 Guess the Number (1 - 100): "))
10+
try:
11+
num = int(input("🤔 Guess the Number (1 - 100): "))
12+
except ValueError:
13+
print("⚠️ Oops! That doesn't look like a valid number. Please try again.\n")
14+
continue
1115

1216
if (num >= 1) and (num <= 100):
1317
if num > num1:

math/Happy-Number/Happy-Number.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
print("🔢 Happy Number Checker 🔢")
22
print("🎯 A happy number is a number which eventually reaches 1 when replaced repeatedly by the sum of the square of its digits.\n")
33

4-
N = int(input("➡️ Enter a number: "))
4+
while True:
5+
try:
6+
N = int(input("➡️ Enter a number: "))
7+
break
8+
except ValueError:
9+
print("⚠️ Oops! That doesn't look like a valid number. Please try again.\n")
510

611
seen = set()
712
num = N
@@ -12,4 +17,4 @@
1217
if (num == 1):
1318
print(f"🔍 {N} is a happy number! ✅")
1419
else:
15-
print(f"🔍 {N} is not a happy number. ❌")
20+
print(f"🔍 {N} is not a happy number. ❌")

math/Pascal-Triangle/Pascal-Triangle.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@
3232
print(f"Row {i+1}: {row_str.center(max_width)}")
3333

3434
elif choice == '2':
35-
row_num = int(input(f"\n📍 Enter row number (1 to {n}): "))
36-
37-
if 1 <= row_num <= len(triangle):
35+
try:
36+
row_num = int(input(f"\n📍 Enter row number (1 to {n}): "))
37+
except ValueError:
38+
print("⚠️ Oops! That doesn't look like a valid number. Please try again.")
39+
row_num = None
40+
41+
if row_num is not None and 1 <= row_num <= len(triangle):
3842
print(f"\n📍 Row {row_num} of Pascal's Triangle:")
3943
print(f" {triangle[row_num-1]}")
4044
print(f"\n📊 Elements: {' → '.join(map(str, triangle[row_num-1]))}")
41-
else:
45+
elif row_num is not None:
4246
print(f"\n❌ Row {row_num} doesn't exist in the generated triangle!")
43-
44-
else:
45-
print("❌ Invalid choice!")
47+
48+
else:
49+
print("❌ Invalid choice!")
4650

4751
print(f"\n💡 Total rows generated: {n}")
4852

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ <h1>
479479
</nav>
480480

481481
<main id="main-content" tabindex="-1">
482-
483482
<!-- Search & Category Tabs -->
484483
<section class="tabs-section" aria-label="Search and Project categories">
485484
<div class="container">
@@ -677,6 +676,15 @@ <h3>Whack-a-Mole</h3>
677676
<button class="btn-play">Try It</button>
678677
</div>
679678

679+
<div class="project-card" data-category="games" data-project="flappy-game">
680+
<div class="card-icon">🐦</div>
681+
<h3>Flappy Game</h3>
682+
<p>Dodge the incoming balls and survive!</p>
683+
<button class="btn-play">Try It</button>
684+
</div>
685+
686+
<div class="project-card" data-category="math" data-project="fibonacci"
687+
data-tags="math,sequence,series,loops,recursion">
680688
<div class="project-card" data-category="games" data-project="game2048"
681689
data-tags="game,puzzle,2048,logic,tiles">
682690
<div class="card-icon game-icon-puzzle">
@@ -788,7 +796,6 @@ <h3>Derivative Calculator</h3>
788796
<button class="btn-play">Try It</button>
789797
</div>
790798

791-
<!-- UTILITIES -->
792799
<div class="project-card" data-category="utilities" data-project="morse-code"
793800
data-tags="utility,morse,translation,communication">
794801
<div class="card-icon utility-icon-radio">

0 commit comments

Comments
 (0)