Skip to content

Commit 1e20e8b

Browse files
authored
Merge pull request #45 from MatinAfzal/develop
Merge Develop Branch into Main for v1.2.0 Release.
2 parents 2cc9cf3 + 33fe90f commit 1e20e8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1870
-576
lines changed

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# my ignores
2-
.idea/
31
# Byte-compiled / optimized / DLL files
42
__pycache__/
53
*.py[cod]
@@ -161,4 +159,4 @@ cython_debug/
161159
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162160
# and can be added to the global gitignore or merged into this file. For a more nuclear
163161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
164-
#.idea/
162+
.idea/

README.md

+66-69
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,89 @@
11
# We Can Make This Game Better!
22

3-
Welcome to the **Alien Invasion** project! This is an exciting open-source initiative where **we** can collaborate to improve, enhance, and evolve the game together.
4-
As a community of passionate developers, designers, and gamers, we have the opportunity to make this game **better** with each contribution.
5-
6-
This project started with a basic version, which has now been evolved to **V1.1.0**, featuring a new scrolling space background, enhanced assets, new sound effects, and more. However, this is just the beginning, and we need **your** help to take this game to the next level!
7-
8-
---
9-
10-
## Table of Contents
11-
12-
- [Current Version](#current-version)
13-
- [How to Contribute](#how-to-contribute)
14-
- [Communication & Collaboration](#communication--collaboration)
15-
- [Project Setup](#project-setup)
16-
- [Assets Used](#assets-used)
3+
Welcome to the Alien Invasion project. This is an open-source effort where serious developers, designers, and gamers come together to create something extraordinary. We’re focused on pushing the limits of what this game can be, and we need your expertise to make that happen.
4+
5+
The foundation is set, but now it’s time to build something even better. If you’re ready to contribute, collaborate, and help take this project to the next level, we’re excited to have you on board.
6+
7+
<div align="center" style="line-height: 1;">
8+
<a href="https://github.com/MatinAfzal/Alien-invasion/releases" target="_blank" style="margin: 2px;">
9+
<img alt="Homepage" src="https://img.shields.io/badge/Github-Latest%20release-7289da?logo=futurelearn&logoColor=white&color=7289da" style="display: inline-block; vertical-align: middle;"/>
10+
</a>
11+
<a href="https://discord.com/invite/jBhmM2j2GN" target="_blank" style="margin: 2px;">
12+
<img alt="Chat" src="https://img.shields.io/badge/Discord-MatinAfzal-7289da?logo=Discord&logoColor=white&color=7289da" style="display: inline-block; vertical-align: middle;"/>
13+
</a>
14+
<a href="https://github.com/MatinAfzal/Alien-invasion/discussions/43" target="_blank" style="margin: 2px;">
15+
<img alt="Chat" src="https://img.shields.io/badge/Discussions-TODO%20List-7289da?logo=todoist&logoColor=white&color=green" style="display: inline-block; vertical-align: middle;"/>
16+
</a>
17+
</div>
1718

1819
---
1920

20-
## Current Version
21-
22-
The current release is **V1.1.0**, which includes several exciting updates:
21+
<table align="center">
22+
<tr>
23+
<th>Version</th>
24+
<th>Date</th>
25+
<th>Release</th>
26+
</tr>
27+
<tr>
28+
<td>Vx.x.x</td>
29+
<td>Feb 3, 2025</td>
30+
<td>
31+
<a href="" target="_blank">
32+
<img src="https://img.shields.io/badge/Release-Vx.x.x-7289da?logo=alienware&logoColor=green&color=violet" alt="Release Badge">
33+
</a>
34+
</td>
35+
</tr>
36+
<tr>
37+
<td>V1.1.0</td>
38+
<td>Jan 8, 2025</td>
39+
<td>
40+
<a href="https://github.com/MatinAfzal/Alien-invasion/releases/tag/V1.1.0" target="_blank">
41+
<img src="https://img.shields.io/badge/Release-V1.1.0-7289da?logo=alienware&logoColor=green&color=violet" alt="Release Badge">
42+
</a>
43+
</td>
44+
</tr>
45+
<tr>
46+
<td>V1.0.0</td>
47+
<td>Nov 16, 2024</td>
48+
<td>
49+
<a href="https://github.com/MatinAfzal/Alien-invasion/releases/tag/V1.0.0" target="_blank">
50+
<img src="https://img.shields.io/badge/Release-V1.0.0-7289da?logo=alienware&logoColor=green&color=violet" alt="Release Badge">
51+
</a>
52+
</td>
53+
</tr>
54+
</table>
2355

24-
- **Dynamic Scrolling Space Background**: A dynamic background effect that adds life to the space environment.
25-
- **New Assets**: Improved graphics for ships, bullets, and aliens for better visual appeal and gameplay.
26-
- **Sound Effects**: Immersive sound effects for actions such as firing bullets and alien ship explosions.
27-
- **Cargo Entity**: A new entity, "Cargo," which is currently deactivated (to be re-enabled in a future update).
28-
29-
![Screenshot of V1.1.0](https://github.com/MatinAfzal/Alien-invasion/blob/main/changelog/V1.1.0/V1.1.0.png)
30-
31-
[Check out the full release on GitHub here!](https://github.com/MatinAfzal/Alien-invasion/releases/tag/V1.1.0)
32-
33-
---
3456

3557
## How to Contribute
3658

37-
As I have worked on **V1.0.0** and made improvements in **V1.1.0**, I now want **you** to help make the game even **better**! Here’s how you can contribute:
38-
39-
1. **Fork this repository** to your own GitHub account.
40-
2. Create a new branch from the **beta branch**.
41-
3. **Develop** your improvements, features, or fixes in this new branch.
42-
4. **Submit a Pull Request** to the **beta branch**.
43-
- Make sure to provide a clear, detailed description of what your PR does and why it's important.
44-
- Ensure your code is well-documented and follows the existing code style.
45-
5. **Engage with other contributors** and provide feedback or support where needed.
59+
- To contribute to the Alien Invasion project, please make your pull requests to the [develop](https://github.com/MatinAfzal/Alien-invasion/tree/develop) branch with a clear and detailed description in English of the changes you've made.
4660

47-
Please note: **All contributions should be made to the `beta` branch**, and **only pull requests to the `beta` branch will be reviewed** for merging. This will ensure a streamlined workflow as we refine and test new features.
61+
- It's important to ensure your PRs are standardized, PEP8 compliant, and that you avoid large commits. Instead, break your changes into smaller, logical commits to make the review process smoother.
4862

49-
---
50-
51-
## Communication & Collaboration
52-
53-
We believe that collaboration and communication are key to making this game better. To discuss your ideas, share your progress, and ask questions, please join our **Discord server**. This is where you can interact with other contributors, get help, and keep up with updates to the project.
63+
- If you're adding new assets like sound effects, music, or textures, ensure that the sources are listed in the Copyright.txt file in the appropriate directory, and include the source links in your PR description if possible.
5464

55-
[Join our Discord Server!](https://discord.gg/jBhmM2j2GN)
65+
- For ideas on what to work on, check the [TODO list discussion](https://github.com/MatinAfzal/Alien-invasion/discussions/43), or feel free to join our [Discord server](https://discord.com/invite/jBhmM2j2GN) to collaborate and share your progress.
5666

57-
---
67+
We appreciate your contributions and look forward to building something great.
5868

5969
## Project Setup
6070

61-
To get started with the project, follow these steps:
71+
- Clone this [repository](https://github.com/MatinAfzal/Alien-invasion) or download the [latest version](https://github.com/MatinAfzal/Alien-invasion/releases).
6272

63-
### Prerequisites:
64-
- Python 3.x
65-
- Pygame library (you can install it using `pip install pygame`)
73+
- Next, navigate to the project directory:
6674

67-
### Clone the Repository:
68-
```bash
69-
git clone https://github.com/MatinAfzal/Alien-invasion.git
70-
cd Alien-invasion
7175
```
72-
### Run the Game:
73-
```bash
74-
python alien_invasion.py
76+
cd Alien-invasion
7577
```
7678

77-
#### Branches:
78-
- main: The stable version of the game (only for release).
79-
- beta: The branch where development happens. Make all contributions here!
80-
81-
### Assets Used
82-
This game uses some amazing assets that we are thankful for. Here are the details:
83-
84-
- Art assets used in this game were created by Skorpio and are licensed under CC-BY-SA 3.0.
85-
You can view and download them here: Space Ship Construction Kit.
86-
87-
- Fire sound effect by K.L.Jonasson, Winnipeg, Canada. Triki Minut Interactive www.trikiminut.com
88-
You can view and download them here: Sci-Fi Laser Fire SFX.
79+
- Make sure you have Python 3 or later installed. Then, install the dependencies:
80+
```
81+
pip install -r requirements.txt
82+
```
8983

90-
- Explosion sound effect by hosch.
91-
You can view and download them here: 8-Bit Sound Effects 2.
9284

85+
- Finally, run the game:
86+
87+
```
88+
python3 alien_invasion.py
89+
```

alien.py

-56
This file was deleted.

alien_invasion.py

+88-29
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,119 @@
11
import pygame
2-
import game_functions as gf
3-
from game_stats import GameStats
42
from pygame.sprite import Group
5-
from settings import Settings
6-
from ship import Ship
7-
from button import Button
8-
from scoreboard import Scoreboard
3+
import src.game_functions as gf
4+
from src.game_stats import GameStats
5+
from src.settings import Settings
6+
from src.ship import Ship
7+
from src.button import Button
8+
from src.scoreboard import Scoreboard
9+
from src.health import Health
10+
from src.input import Input
911

1012

1113
def run_game():
12-
# Credit for the assets
13-
print("""
14-
Art assets used in this game were created by Skorpio and are licensed under CC-BY-SA 3.0.
15-
You can view and download them here: [https://opengameart.org/content/space-ship-construction-kit].\n
16-
Fire sound effect by K.L.Jonasson, Winnipeg, Canada. Triki Minut Interactive www.trikiminut.com
17-
You can view and download them here: [https://opengameart.org/content/sci-fi-laser-fire-sfx].\n
18-
Explosion sound effect by by hosch
19-
You can view and download them here: https://opengameart.org/content/8-bit-sound-effects-2
20-
""")
2114
# Initialize pygame, settings, screen object and assets.
2215
pygame.init()
2316
ai_settings = Settings()
17+
input = Input()
2418
screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
2519
pygame.display.set_caption("Alien Invasion")
26-
screen_bg = pygame.image.load("images/space.jpg")
20+
screen_bg = pygame.image.load("data/assets/images/space3.png")
2721
screen_bg = pygame.transform.scale(screen_bg, (ai_settings.screen_width*2, ai_settings.screen_width*2))
2822
screen_bg_2 = pygame.transform.rotate(screen_bg, 180)
2923
clock = pygame.time.Clock()
30-
31-
# Make the play button.
32-
play_button = Button(ai_settings, screen, "Play")
24+
alien_spawn_timer = pygame.time.get_ticks()
3325

3426
# Create an instance to store game statistics and create scoreboard.
3527
stats = GameStats(ai_settings)
3628
sb = Scoreboard(ai_settings, screen, stats)
3729

38-
# Make a ship, a group of bullets, and a group of aliens.
39-
ship = Ship(ai_settings, screen)
30+
health = Health(ai_settings, screen)
31+
health.init_health()
32+
33+
# Make a ship, and a group for each game sprite.
34+
ship = Ship(ai_settings, input, screen)
4035
bullets = Group()
4136
aliens = Group()
4237
cargoes = Group()
38+
alien_bullets = Group()
39+
hearts = Group()
40+
shields = Group()
41+
42+
# Make the play button.
43+
play_button = Button(
44+
screen,
45+
input,
46+
position=(screen.get_rect().centerx - 100, screen.get_rect().centery + 25),
47+
size=(200, 50),
48+
text="Play",
49+
foreground_color=(255, 255, 255),
50+
background_color=(0, 225, 0),
51+
border_width=0,
52+
display_condition=lambda: not stats.game_active and not stats.credits_active,
53+
on_clicked=lambda: gf.run_play_button(ai_settings, stats, ship, aliens, cargoes, bullets, health))
54+
55+
credits_button = Button(
56+
screen,
57+
input,
58+
position=(screen.get_rect().centerx - 100, screen.get_rect().centery + 100),
59+
size=(200, 50),
60+
text="Credits",
61+
foreground_color=(255, 255, 255),
62+
background_color=(0, 225, 0),
63+
border_width=0,
64+
display_condition=lambda: not stats.credits_active and not stats.game_active,
65+
on_clicked=lambda: gf.run_credit_button(stats))
66+
67+
back_button = Button(
68+
screen,
69+
input,
70+
position=(10, 50),
71+
size=(200, 50),
72+
text="Back",
73+
foreground_color=(255, 255, 255),
74+
background_color=(0, 225, 0),
75+
border_width=0,
76+
display_condition=lambda: stats.credits_active,
77+
on_clicked=lambda: gf.run_back_button(stats))
78+
79+
alien_spawn_counter = 0
4380

44-
# Create the fleet of aliens.
45-
gf.create_fleet(ai_settings, screen, ship, aliens, cargoes)
81+
gf.load_animations(screen, ai_settings)
82+
gf.load_credits()
4683

4784
# Start the main loop for the game.
4885
while True:
49-
gf.check_events(ai_settings, screen, stats, play_button, ship, aliens, bullets, cargoes)
86+
input.update()
87+
gf.check_events(ai_settings, input, screen, stats, ship, bullets)
5088
if stats.game_active:
51-
ship.update()
52-
gf.update_bullets(ai_settings, screen, stats, sb, ship, aliens, bullets, cargoes)
53-
gf.update_aliens(ai_settings, stats, screen, ship, aliens, bullets, cargoes, sb)
89+
# Prevent mouse from going out of screen.
90+
pygame.event.set_grab(True)
91+
92+
# Update game sprites
93+
gf.update_game_sprites(ai_settings, screen, stats, sb, ship, aliens, bullets, cargoes, alien_bullets,
94+
health, hearts, shields)
95+
else:
96+
pygame.event.set_grab(False)
97+
98+
gf.update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, play_button, credits_button,
99+
back_button, screen_bg, screen_bg_2, cargoes, alien_bullets, health, hearts, shields)
54100

55-
gf.update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets, play_button, screen_bg,
56-
screen_bg_2, cargoes)
57101
clock.tick(ai_settings.fps)
58102

103+
# Aliens fire timer
104+
current_time = pygame.time.get_ticks()
105+
106+
if current_time - alien_spawn_timer > 100:
107+
gf.alien_fire(ai_settings, stats, screen, aliens, alien_bullets, ship)
108+
109+
gf.generate_heart(ai_settings, stats, screen, hearts)
110+
gf.generate_shields(screen, ai_settings, stats, shields)
111+
112+
if alien_spawn_counter % 10 == 0:
113+
gf.spawn_random_alien(ai_settings, screen, aliens)
114+
115+
alien_spawn_counter += 1
116+
alien_spawn_timer = current_time
117+
59118

60119
run_game()

0 commit comments

Comments
 (0)