Alien Invastion progress
This commit is contained in:
parent
3a5807be57
commit
ffa990eae1
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
4
.idea/misc.xml
generated
Normal file
4
.idea/misc.xml
generated
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/python-crash-course.iml" filepath="$PROJECT_DIR$/.idea/python-crash-course.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
.idea/python-crash-course.iml
generated
Normal file
12
.idea/python-crash-course.iml
generated
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
47
.idea/workspace.xml
generated
Normal file
47
.idea/workspace.xml
generated
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="c1aa85dc-cf52-443a-9cd8-6f2142959970" name="Changes" comment="" />
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectColorInfo"><![CDATA[{
|
||||||
|
"associatedIndex": 2
|
||||||
|
}]]></component>
|
||||||
|
<component name="ProjectId" id="2u5upLeaTkGgQf9tSH9KfFm5WqF" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
|
"keyToString": {
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
|
"git-widget-placeholder": "main",
|
||||||
|
"last_opened_file_path": "/Users/cheeks/repos/python-crash-course"
|
||||||
|
}
|
||||||
|
}]]></component>
|
||||||
|
<component name="SharedIndexes">
|
||||||
|
<attachedChunks>
|
||||||
|
<set>
|
||||||
|
<option value="bundled-python-sdk-495700d161d3-aa17d162503b-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-243.22562.220" />
|
||||||
|
</set>
|
||||||
|
</attachedChunks>
|
||||||
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="c1aa85dc-cf52-443a-9cd8-6f2142959970" name="Changes" comment="" />
|
||||||
|
<created>1741550937759</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1741550937759</updated>
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -1,20 +1,36 @@
|
|||||||
import sys
|
import sys
|
||||||
import pygame
|
import pygame
|
||||||
|
from settings import Settings
|
||||||
|
from ship import Ship
|
||||||
|
|
||||||
class AlienInvasion:
|
class AlienInvasion:
|
||||||
"""Overall class for the game"""
|
"""Overall class for the game"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize game and create resources"""
|
"""Initialize game and create resources"""
|
||||||
pygame.init()
|
pygame.init()
|
||||||
self.screen = pygame.display.set_mode((1920, 1080))
|
self.clock = pygame.time.Clock()
|
||||||
|
self.settings = Settings()
|
||||||
|
self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height))
|
||||||
pygame.display.set_caption("Alien Invasion")
|
pygame.display.set_caption("Alien Invasion")
|
||||||
|
self.ship = Ship(self)
|
||||||
|
|
||||||
def run_game(self):
|
def run_game(self):
|
||||||
"""Start main game loop"""
|
"""Start main game loop"""
|
||||||
while True:
|
while True:
|
||||||
#Listen for events
|
#Listen for events
|
||||||
|
self._check_events()
|
||||||
|
self._update_screen()
|
||||||
|
self.clock.tick(60)
|
||||||
|
|
||||||
|
def _check_events(self):
|
||||||
|
"""Respond to keypresses and mouse events"""
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
def _update_screen(self):
|
||||||
|
self.screen.fill(self.settings.bg_color)
|
||||||
|
self.ship.blitme()
|
||||||
# refresh display
|
# refresh display
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
|
|||||||
BIN
Projects/Alien_Invasion/assets/shuttle.png
Normal file
BIN
Projects/Alien_Invasion/assets/shuttle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 767 B |
9
Projects/Alien_Invasion/settings.py
Normal file
9
Projects/Alien_Invasion/settings.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class Settings:
|
||||||
|
"""A Class to store all settings for Alien Invasion"""
|
||||||
|
def __init__(self):
|
||||||
|
"""Initialize the game's settings"""
|
||||||
|
# Screen settings
|
||||||
|
self.screen_width = 800
|
||||||
|
self.screen_height = 600
|
||||||
|
self.bg_color = (230, 230, 230)
|
||||||
|
|
||||||
20
Projects/Alien_Invasion/ship.py
Normal file
20
Projects/Alien_Invasion/ship.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
class Ship():
|
||||||
|
"""A class to manage the ship"""
|
||||||
|
|
||||||
|
def __init__(self, ai_game):
|
||||||
|
"""Initialize the ship and set its starting position"""
|
||||||
|
self.screen = ai_game.screen
|
||||||
|
self.screen_rect = ai_game.screen.get_rect()
|
||||||
|
|
||||||
|
# Load the ship image and get its rect
|
||||||
|
self.image = pygame.image.load('assets/shuttle.png')
|
||||||
|
self.rect = self.image.get_rect()
|
||||||
|
|
||||||
|
# start each new ship at the bottom center of the screen
|
||||||
|
self.rect.midbottom = self.screen_rect.midbottom
|
||||||
|
|
||||||
|
def blitme(self):
|
||||||
|
"""Draw the ship at its current location"""
|
||||||
|
self.screen.blit(self.image, self.rect)
|
||||||
176
bookmark.sublime-workspace
Normal file
176
bookmark.sublime-workspace
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
{
|
||||||
|
"auto_complete":
|
||||||
|
{
|
||||||
|
"selected_items":
|
||||||
|
[
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"buffers":
|
||||||
|
[
|
||||||
|
],
|
||||||
|
"build_system": "",
|
||||||
|
"build_system_choices":
|
||||||
|
[
|
||||||
|
],
|
||||||
|
"build_varint": "",
|
||||||
|
"command_palette":
|
||||||
|
{
|
||||||
|
"height": 0.0,
|
||||||
|
"last_filter": "",
|
||||||
|
"selected_items":
|
||||||
|
[
|
||||||
|
],
|
||||||
|
"width": 0.0
|
||||||
|
},
|
||||||
|
"console":
|
||||||
|
{
|
||||||
|
"height": 0.0,
|
||||||
|
"history":
|
||||||
|
[
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"distraction_free":
|
||||||
|
{
|
||||||
|
"menu_visible": true,
|
||||||
|
"show_minimap": false,
|
||||||
|
"show_open_files": false,
|
||||||
|
"show_tabs": false,
|
||||||
|
"side_bar_visible": false,
|
||||||
|
"status_bar_visible": false
|
||||||
|
},
|
||||||
|
"file_history":
|
||||||
|
[
|
||||||
|
"/Users/cheeks/.ssh/cheeksmacmini.pub",
|
||||||
|
"/Users/cheeks/.ssh/vpsmacmini.pub",
|
||||||
|
"/Users/cheeks/.ssh/cheeksmacmini",
|
||||||
|
"/Users/cheeks/repos/recipe-site/_components/chicken-meatballs.md",
|
||||||
|
"/Users/cheeks/repos/recipe-site/about.md",
|
||||||
|
"/Users/cheeks/repos/python-projects/Chapter_01/README.md",
|
||||||
|
"/Users/cheeks/repos/python-projects/Chapter_01/fileExtensions.py",
|
||||||
|
"/Users/cheeks/repos/python-projects/Chapter_03/guestList.py",
|
||||||
|
"/Users/cheeks/repos/python-projects/Chapter_03/guestList.pt",
|
||||||
|
"/Users/cheeks/test.py"
|
||||||
|
],
|
||||||
|
"find":
|
||||||
|
{
|
||||||
|
"height": 0.0
|
||||||
|
},
|
||||||
|
"find_in_files":
|
||||||
|
{
|
||||||
|
"height": 0.0,
|
||||||
|
"where_history":
|
||||||
|
[
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"find_state":
|
||||||
|
{
|
||||||
|
"case_sensitive": false,
|
||||||
|
"find_history":
|
||||||
|
[
|
||||||
|
],
|
||||||
|
"highlight": true,
|
||||||
|
"in_selection": false,
|
||||||
|
"preserve_case": false,
|
||||||
|
"regex": false,
|
||||||
|
"replace_history":
|
||||||
|
[
|
||||||
|
],
|
||||||
|
"reverse": false,
|
||||||
|
"scrollbar_highlights": true,
|
||||||
|
"show_context": true,
|
||||||
|
"use_buffer2": true,
|
||||||
|
"use_gitignore": true,
|
||||||
|
"whole_word": false,
|
||||||
|
"wrap": true
|
||||||
|
},
|
||||||
|
"groups":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"sheets":
|
||||||
|
[
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"incremental_find":
|
||||||
|
{
|
||||||
|
"height": 0.0
|
||||||
|
},
|
||||||
|
"input":
|
||||||
|
{
|
||||||
|
"height": 0.0
|
||||||
|
},
|
||||||
|
"layout":
|
||||||
|
{
|
||||||
|
"cells":
|
||||||
|
[
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"cols":
|
||||||
|
[
|
||||||
|
0.0,
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
"rows":
|
||||||
|
[
|
||||||
|
0.0,
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"menu_visible": true,
|
||||||
|
"output.find_results":
|
||||||
|
{
|
||||||
|
"height": 0.0
|
||||||
|
},
|
||||||
|
"pinned_build_system": "Packages/Python/Python.sublime-build",
|
||||||
|
"project": "bookmark.sublime-project",
|
||||||
|
"replace":
|
||||||
|
{
|
||||||
|
"height": 0.0
|
||||||
|
},
|
||||||
|
"save_all_on_build": true,
|
||||||
|
"select_file":
|
||||||
|
{
|
||||||
|
"height": 0.0,
|
||||||
|
"last_filter": "",
|
||||||
|
"selected_items":
|
||||||
|
[
|
||||||
|
],
|
||||||
|
"width": 0.0
|
||||||
|
},
|
||||||
|
"select_project":
|
||||||
|
{
|
||||||
|
"height": 0.0,
|
||||||
|
"last_filter": "",
|
||||||
|
"selected_items":
|
||||||
|
[
|
||||||
|
],
|
||||||
|
"width": 0.0
|
||||||
|
},
|
||||||
|
"select_symbol":
|
||||||
|
{
|
||||||
|
"height": 0.0,
|
||||||
|
"last_filter": "",
|
||||||
|
"selected_items":
|
||||||
|
[
|
||||||
|
],
|
||||||
|
"width": 0.0
|
||||||
|
},
|
||||||
|
"selected_group": 0,
|
||||||
|
"settings":
|
||||||
|
{
|
||||||
|
},
|
||||||
|
"show_minimap": true,
|
||||||
|
"show_open_files": true,
|
||||||
|
"show_tabs": true,
|
||||||
|
"side_bar_visible": true,
|
||||||
|
"side_bar_width": 150.0,
|
||||||
|
"status_bar_visible": true,
|
||||||
|
"template_settings":
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user