Compare commits
15 Commits
Author | SHA1 | Date |
---|---|---|
Jake Howard | bb2bc41b68 | |
Jake Howard | 8020853ef7 | |
Jake Howard | cb5ece304a | |
Jake Howard | 5640158e82 | |
Jake Howard | d91f82a889 | |
Jake Howard | 7cf6638cb9 | |
Jake Howard | 5b14f36770 | |
Jake Howard | a9d7d9c6f7 | |
Jake Howard | 230c2db7ec | |
Jake Howard | 8f56f52980 | |
Jake Howard | 0bbd172764 | |
Jake Howard | 3542fe1f74 | |
Jake Howard | 1d216164c8 | |
Jake Howard | 1b34829e62 | |
Jake Howard | 73a913c43c |
|
@ -1 +1,57 @@
|
|||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
|
14
GUI.py
14
GUI.py
|
@ -16,11 +16,11 @@ class Main_Window:
|
|||
|
||||
self.title = Label(self.master)
|
||||
self.title.config(text="ATTACK ON BLOCKS!",font=("Courier New", 37))
|
||||
self.title.pack(side="top", padx=PADDING_BUTTON, pady=PADDING_TITLE/2)
|
||||
self.title.pack(side="top", padx=PADDING_TITLE, pady=PADDING_TITLE/2)
|
||||
|
||||
self.version_info = Label(self.master)
|
||||
self.version_info.config(text="Version {ID} tagged {DATE}".format(**VERSION), font=("Courier New", 15))
|
||||
self.version_info.pack(side="top", padx=PADDING_BUTTON, pady=PADDING_BUTTON/2)
|
||||
self.version_info.config(text="Version {ID} tagged {DATE}".format(**VERSION), font=("Courier New", 13))
|
||||
self.version_info.pack(side="top", padx=0, pady=PADDING_BUTTON/2)
|
||||
|
||||
self.start_button = Button(self.master, style="Menu.TButton")
|
||||
self.start_button.config(text="Play Game")
|
||||
|
@ -42,6 +42,11 @@ class Main_Window:
|
|||
self.exit_button.pack(ipadx=PADDING_BUTTON/3, ipady=PADDING_BUTTON, padx=PADDING_BUTTON, pady=PADDING_BUTTON)
|
||||
self.exit_button.bind('<Button-1>', self.close)
|
||||
|
||||
self.about_info = Label(self.master)
|
||||
self.about_info.config(text="Game Created by TheOrangeOne!", font=("Courier New", 9))
|
||||
self.about_info.bind("<Button-1>", self.show_site)
|
||||
self.about_info.pack(side="top", padx=0, pady=PADDING_BUTTON/2)
|
||||
|
||||
Style().configure("Menu.TButton", font=("Lucida", 21))
|
||||
Style().configure("About.TButton", font=("Lucida", 17))
|
||||
Style().configure("Quit.TButton", font=("Lucida", 13))
|
||||
|
@ -66,6 +71,9 @@ class Main_Window:
|
|||
logging.critical("Closing Main Window.")
|
||||
self.master.destroy()
|
||||
|
||||
def show_site(self, event):
|
||||
logging.info("Loading Website")
|
||||
system("start http://theorangeone.net")
|
||||
|
||||
class Options_Window:
|
||||
def __init__(self):
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Jake Howard
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
52
README.md
52
README.md
|
@ -1,26 +1,26 @@
|
|||
# Attack on Blocks #
|
||||
|
||||
This take on space invaders was written for my IT BTEC course, Unit 21 Games Development at college. This version, written in python, includes more advanced features such as resource packs.
|
||||
|
||||
### More Information ###
|
||||
|
||||
For more information, check out the [Wiki](//bitbucket.org/TheOrangeOne/attack-on-blocks/wiki) page.
|
||||
|
||||
### Requirements ###
|
||||
|
||||
* Python 3
|
||||
* Pygame
|
||||
* TKinter
|
||||
|
||||
The game is only playable on windows, due to the GUI library only being available on windows. However a cross platform, lightweight version may be made in the future.
|
||||
|
||||
### Playing the game ###
|
||||
|
||||
* Clone the repository, or visit the downloads page
|
||||
* Install the required libraries (See Above)
|
||||
* Run 'Play The Game.py'
|
||||
|
||||
### Core Contributors ###
|
||||
|
||||
* Jake Howard
|
||||
* Furhan Bhatti (Well not really)
|
||||
# Attack on Blocks #
|
||||
|
||||
This take on space invaders was written for my IT BTEC course, Unit 22 Games Development at college. This version, written in python, includes more advanced features such as resource packs.
|
||||
|
||||
### More Information ###
|
||||
|
||||
For more information, check out the [Wiki](//bitbucket.org/TheOrangeOne/attack-on-blocks/wiki) page.
|
||||
|
||||
### Requirements ###
|
||||
|
||||
* Python 3
|
||||
* Pygame
|
||||
* TKinter
|
||||
|
||||
The game is only playable on windows, due to the GUI library only being available on windows. However a cross platform, lightweight version may be made in the future.
|
||||
|
||||
### Playing the game ###
|
||||
|
||||
* Clone the repository, or visit the downloads page
|
||||
* Install the required libraries (See Above)
|
||||
* Run 'Play The Game.py'
|
||||
|
||||
### Core Contributors ###
|
||||
|
||||
* Jake Howard
|
||||
* Furhan Bhatti (Well not really)
|
||||
|
|
|
@ -72,12 +72,12 @@ def generate_random_level():
|
|||
|
||||
Sounds = {}
|
||||
def init_sounds():
|
||||
music_files = ["main.wav", "OP.wav", "shot.wav"]
|
||||
music_files = ["main.ogg", "OP.ogg", "shot.ogg"]
|
||||
for file in music_files:
|
||||
path = os.path.dirname(os.path.realpath(__file__)) + "\\resources\\sounds\\" + file
|
||||
if file == "main.wav":
|
||||
if file == "main.ogg":
|
||||
mixer = pygame.mixer.music
|
||||
mixer.load(path)
|
||||
else: mixer = pygame.mixer.Sound(path)
|
||||
mixer.set_volume(1.0)
|
||||
Sounds[file.replace(".wav", "")] = mixer
|
||||
Sounds[file.replace(".ogg", "")] = mixer
|
35
game.py
35
game.py
|
@ -29,7 +29,7 @@ def initialise(menu, options):
|
|||
pygame.mixer.pre_init(44100, -16, 2, 2048)
|
||||
pygame.init()
|
||||
window = pygame.display.set_mode(WINDOW_SIZE)
|
||||
|
||||
pygame.display.set_caption("Attack on Blocks")
|
||||
exit_code = play(window, options) # Run main game loop
|
||||
for key, value in Sounds.items():
|
||||
value.fadeout(500)
|
||||
|
@ -61,7 +61,7 @@ def play(window, options):
|
|||
"Powerup":[FPS*15, FPS*15]
|
||||
}
|
||||
init_sounds()
|
||||
Sounds["main"].play(loops=-1) #Start background music
|
||||
if options["Sounds"]: Sounds["main"].play(loops=-1) #Start background music
|
||||
|
||||
logging.info("Game Started.")
|
||||
PLAYING_GAME = True
|
||||
|
@ -84,18 +84,7 @@ def play(window, options):
|
|||
temp.rect.y += 20
|
||||
bullet_group.add(temp)
|
||||
fired = True
|
||||
|
||||
if event.type == pygame.KEYDOWN and event.key == pygame.K_KP_PLUS:
|
||||
if not player.options["Sounds"] or not player.OP:
|
||||
Sounds["main"].stop()
|
||||
#Sounds["OP"].play(loops=-1)
|
||||
player.OP = True
|
||||
player.change_colour((255,96,0))
|
||||
elif player.OP:
|
||||
Sounds["OP"].stop()
|
||||
Sounds["main"].play(loops=-1)
|
||||
player.OP = False
|
||||
player.reset_image()
|
||||
|
||||
|
||||
keys = pygame.key.get_pressed()
|
||||
if keys[pygame.K_RIGHT] or keys[pygame.K_d]:
|
||||
|
@ -107,12 +96,28 @@ def play(window, options):
|
|||
else: player.move(-player.speed)
|
||||
|
||||
if keys[pygame.K_KP4] and keys[pygame.K_KP5] and keys[pygame.K_KP6] and player.OP:
|
||||
temp = Bullet(player, player.options["Textures"])
|
||||
temp = Bullet(player, player.options["Textures"], False)
|
||||
bullet_group.add(temp)
|
||||
|
||||
if keys[pygame.K_r] and [pygame.K_9] and [pygame.K_k] and player.OP:
|
||||
eggs.r9k(window)
|
||||
|
||||
if keys[pygame.K_KP4] and keys[pygame.K_KP2] and keys[pygame.K_KP0] and keys[pygame.K_o] and keys[pygame.K_p] and not player.OP:
|
||||
if player.options["Sounds"]:
|
||||
Sounds["main"].stop()
|
||||
Sounds["OP"].play(loops=-1)
|
||||
player.OP = True
|
||||
player.change_colour((255,96,0))
|
||||
logging.warn("OP mode engaged.")
|
||||
|
||||
if keys[pygame.K_KP_MINUS] and player.OP:
|
||||
if player.options["Sounds"]:
|
||||
Sounds["OP"].stop()
|
||||
Sounds["main"].play(loops=-1)
|
||||
player.OP = False
|
||||
player.reset_image()
|
||||
logging.warn("OP mode disabled.")
|
||||
|
||||
for sprite in bullet_group:
|
||||
sprite.update()
|
||||
if sprite.rect.y < 0 or (sprite.rect.y > player.rect.y and sprite.type == "TARGET"):
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -49,8 +49,10 @@ def generate_targets(player, window_size, Levels):
|
|||
firebacks = len(sprite_list)
|
||||
else: firebacks = level.firebacks
|
||||
for i in range(firebacks):
|
||||
loop = 0
|
||||
changed = False
|
||||
while not changed:
|
||||
if loop == firebacks: changed = True
|
||||
index = randint(0, len(sprite_list)-1) if (len(sprite_list) - 1 != 0) else 0
|
||||
if sprite_list[index].type != "SHOOTER":
|
||||
sprite_list[index].type = "SHOOTER"
|
||||
|
@ -60,6 +62,7 @@ def generate_targets(player, window_size, Levels):
|
|||
sprite_list[index].rect = sprite_list[index].image.get_rect()
|
||||
sprite_list[index].set_position(x,y, center=False) #Already Centered!
|
||||
changed = True
|
||||
loop += 1
|
||||
|
||||
if len(sprite_list) < level.powerups:
|
||||
powerups = len(sprite_list)
|
||||
|
|
Reference in New Issue