Skip to content

Commit 8a2dd21

Browse files
authored
Add files via upload
1 parent f4a9d3f commit 8a2dd21

22 files changed

+1317
-0
lines changed

Angry_Birds/Fonts/Comic_Kings.ttf

101 KB
Binary file not shown.
16.4 KB
Binary file not shown.

Angry_Birds/Images/bird.png

4.46 KB
Loading

Angry_Birds/Images/block1.png

5.34 KB
Loading
9.9 KB
Loading

Angry_Birds/Images/game_play1.png

217 KB
Loading

Angry_Birds/Images/game_play2.png

203 KB
Loading

Angry_Birds/Images/pig1.png

3.43 KB
Loading

Angry_Birds/Images/pig3.png

4.46 KB
Loading

Angry_Birds/Images/pig_damaged.png

5.33 KB
Loading
2.56 KB
Loading

Angry_Birds/Images/wall_vertical.png

2.82 KB
Loading

Angry_Birds/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Angry Birds
2+
3+
Here is a Small Attempt to Recreate One of the popular Games, Angry Birds in Python using Pygame
4+
5+
Link to 14 Hour Time Lapse of coding the game from Scratch: [Angry Birds - 14 Hour Time Lapse]()
6+
7+
Link to Blog: [Angry Birds in Python Using PyGame]()
8+
9+
Game Play Screenshot:
10+
11+
<p align="center"> <img src="Images/game_play1.png"/> </p>
12+
13+
14+
<p align="center"> <img src="Images/game_play2.png"/> </p>
2.13 KB
Binary file not shown.
16.1 KB
Binary file not shown.
2.84 KB
Binary file not shown.
Binary file not shown.

Angry_Birds/interface.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
'''
2+
3+
Game: Angry Birds
4+
File: interface.py
5+
6+
Contents: Class Buttons and Class Labels for User Interface
7+
8+
Requirements: Pygame, sys
9+
10+
By: Jatin Kumar Mandav
11+
12+
Blog: https://www.jatinmandav.wordpress.com
13+
Twitter: @jatinmandav
14+
YouTube: https://www.youtube.com/mandav
15+
16+
'''
17+
import pygame
18+
import sys
19+
20+
pygame.init()
21+
display = None
22+
23+
def init(screen):
24+
global display
25+
display = screen
26+
27+
class Button:
28+
def __init__(self, x, y, w, h, action=None, colorNotActive=(189, 195, 199), colorActive=None):
29+
self.x = x
30+
self.y = y
31+
self.w = w
32+
self.h = h
33+
34+
self.colorActive = colorActive
35+
self.colorNotActive = colorNotActive
36+
37+
self.action = action
38+
39+
self.font = None
40+
self.text = None
41+
self.text_pos = None
42+
43+
def add_text(self, text, size=20, font="Times New Roman", text_color=(0, 0, 0)):
44+
self.font = pygame.font.Font(font, size)
45+
self.text = self.font.render(text, True, text_color)
46+
self.text_pos = self.text.get_rect()
47+
48+
self.text_pos.center = (self.x + self.w/2, self.y + self.h/2)
49+
50+
def draw(self):
51+
if self.isActive():
52+
if not self.colorActive == None:
53+
pygame.draw.rect(display, self.colorActive, (self.x, self.y, self.w, self.h))
54+
else:
55+
pygame.draw.rect(display, self.colorNotActive, (self.x, self.y, self.w, self.h))
56+
57+
if self.text:
58+
display.blit(self.text, self.text_pos)
59+
60+
def isActive(self):
61+
pos = pygame.mouse.get_pos()
62+
63+
if (self.x < pos[0] < self.x + self.w) and (self.y < pos[1] < self.y + self.h):
64+
return True
65+
else:
66+
return False
67+
68+
class Label(Button):
69+
def draw(self):
70+
if self.text:
71+
display.blit(self.text, self.text_pos)

Angry_Birds/main.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
'''
2+
3+
Game: Angry Birds
4+
File: main.py
5+
6+
Contents: The Main file to Start the Game!
7+
8+
Requirements: Pygame, sys, random, math
9+
Supporting Modules: interface.py, physics_engine.py, maps.py, objects.py
10+
11+
Usage:
12+
Angry_Birds/$ python3 main.py or
13+
Angry_Birds/$ python main.py
14+
15+
By: Jatin Kumar Mandav
16+
17+
Blog: https://www.jatinmandav.wordpress.com
18+
Twitter: @jatinmandav
19+
YouTube: https://www.youtube.com/mandav
20+
21+
'''
22+
import pygame
23+
import sys
24+
import random
25+
from math import *
26+
27+
import physics_engine
28+
import objects
29+
import maps
30+
import interface
31+
32+
pygame.init()
33+
width = 1800
34+
height = 700
35+
display = pygame.display.set_mode((width, height))
36+
clock = pygame.time.Clock()
37+
38+
physics_engine.init(display)
39+
objects.init(display)
40+
maps.init(display)
41+
interface.init(display)
42+
43+
background = (51, 51, 51)
44+
45+
def close():
46+
pygame.quit()
47+
sys.exit()
48+
49+
def start_game(map):
50+
map.draw_map()
51+
52+
def GAME():
53+
map = maps.Maps()
54+
55+
welcome = interface.Label(700, 100, 400, 200, None, background)
56+
welcome.add_text("ANGRY BIRDS", 80, "Fonts/arfmoochikncheez.ttf", (236, 240, 241))
57+
58+
start = interface.Button(500, 400, 300, 100, start_game, (244, 208, 63), (247, 220, 111))
59+
start.add_text("START GAME", 60, "Fonts/arfmoochikncheez.ttf", background)
60+
61+
exit = interface.Button(1000, 400, 300, 100, close, (241, 148, 138), (245, 183, 177))
62+
exit.add_text("QUIT", 60, "Fonts/arfmoochikncheez.ttf", background)
63+
64+
mandav = interface.Button(width - 300, height - 80, 300, 100, None, background)
65+
mandav.add_text("MANDAV", 60, "Fonts/arfmoochikncheez.ttf", (41, 41, 41))
66+
67+
while True:
68+
for event in pygame.event.get():
69+
if event.type == pygame.QUIT:
70+
close()
71+
if event.type == pygame.KEYDOWN:
72+
if event.key == pygame.K_q:
73+
close()
74+
75+
if event.type == pygame.MOUSEBUTTONDOWN:
76+
if exit.isActive():
77+
exit.action()
78+
if start.isActive():
79+
start_game(map)
80+
81+
display.fill(background)
82+
83+
start.draw()
84+
exit.draw()
85+
welcome.draw()
86+
mandav.draw()
87+
88+
pygame.display.update()
89+
clock.tick(60)
90+
91+
GAME()

0 commit comments

Comments
 (0)