Skip to content

Commit

Permalink
Garnet Monsters - Public
Browse files Browse the repository at this point in the history
Adventure game that educates players about endangered species.

Collaborators: Elliott Hendricks, Sophia Lu, Eduardo Aguilar. Professor Michael Wehar's CPSC 71 Software Engineering Course
  • Loading branch information
elliot-d-kim committed Aug 30, 2023
0 parents commit 017cfe5
Show file tree
Hide file tree
Showing 164 changed files with 3,448 additions and 0 deletions.
141 changes: 141 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# 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/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

saveFile.txt
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/garnet-monsters.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# pokemon-garnet
Adventure game based on Pokemon for a school project
Empty file added __init__.py
Empty file.
141 changes: 141 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import sys
import pygame
from pygame.locals import *
from pygame import Rect
from src.util import colors as col
from src.util import graphics as gr
from src.stages.splash.splash import Splash
from src.stages.world.world import World
from src.stages.bag.bag import Bag
from src.stages.catch.catch import Catch
from src.stages.credits.credits import Credits
from src.stages.journal.journal import Journal
from src.stages.profile.profile import Profile
from src.logic.state import State
from src.util.graphics import FPS
import logging

"""
Top level class of the project.
"""
class App:
# Stages
stageNames = {
"splash": Splash,
"world": World,
"catch": Catch,
"credits": Credits,
"journal": Journal,
"bag": Bag,
"profile": Profile
}

# Constructor
def __init__(self):
# init PyGame
pygame.init()
self.clock = pygame.time.Clock()
self.surface = pygame.display.set_mode((gr.BOUND_TOT[2], gr.BOUND_TOT[3]))
self.upSurface = self.surface.subsurface(gr.BOUND_UP)
self.lowSurface = self.surface.subsurface(gr.BOUND_LOW)
pygame.display.set_caption("Garnet Monsters")

# init fonts
App.loadFonts()


# create all the stages
self.stages = {}
state = State()
for n in App.stageNames:
self.stages[n] = App.stageNames[n](self, state)

#set the active stage
self.active = self.stageNames["splash"](self, state)
self.active.load()
@staticmethod
def loadFonts():
pygame.font.init()
gr.FONT_4 = pygame.font.Font("src/assets/fonts/joystix.ttf", 4)
gr.FONT_6 = pygame.font.Font("src/assets/fonts/joystix.ttf", 6)
gr.FONT_8 = pygame.font.Font("src/assets/fonts/joystix.ttf", 8)
gr.FONT_10 = pygame.font.Font("src/assets/fonts/joystix.ttf", 10)
gr.FONT_12 = pygame.font.Font("src/assets/fonts/joystix.ttf", 12)
gr.FONT_14 = pygame.font.Font("src/assets/fonts/joystix.ttf", 14)
gr.FONT_16 = pygame.font.Font("src/assets/fonts/joystix.ttf", 16)
gr.FONT_20 = pygame.font.Font("src/assets/fonts/joystix.ttf", 20)
gr.FONT_24 = pygame.font.Font("src/assets/fonts/joystix.ttf", 24)
gr.FONT_28 = pygame.font.Font("src/assets/fonts/joystix.ttf", 28)
gr.FONT_32 = pygame.font.Font("src/assets/fonts/joystix.ttf", 32)

# Game loop
def loop(self):
# stage logic
self.getInput()
self.active.update()

# prepare canvas
self.surface.fill(col.LIGHT_GRAY)

# stage drawing
self.active.draw()

# overlay on canvas
self.drawCanvasRibbons()

# update the display
pygame.display.update()
@staticmethod
def quit():
pygame.quit()
sys.exit()

# Loop utility
def drawCanvasRibbons(self):
pygame.draw.rect(self.surface, col.BLACK, Rect(0, 0, gr.BOUND_TOT.w, gr.RIBBON))
pygame.draw.rect(self.surface, col.BLACK, Rect(0, gr.RIBBON + gr.SCR_HT, gr.BOUND_TOT.w, gr.RIBBON))
pygame.draw.rect(self.surface, col.BLACK, Rect(0, gr.BOUND_TOT.h - gr.RIBBON, gr.BOUND_TOT.w, gr.RIBBON))
pygame.draw.rect(self.surface, col.BLACK, Rect(0, 0, gr.RIBBON, gr.BOUND_TOT.h))
pygame.draw.rect(self.surface, col.BLACK, Rect(gr.BOUND_TOT.w - gr.RIBBON, 0, gr.RIBBON, gr.BOUND_TOT.h))
def drawLowerBackground(self):
pygame.draw.rect(self.surface, col.LIGHT_GRAY, gr.BOUND_LOW)
def getInput(self):
#update mouse position
if gr.BOUND_LOW.collidepoint(pygame.mouse.get_pos()):
self.active.setMousePos(App.transformPosToLower(pygame.mouse.get_pos()))
else:
self.active.setMousePos((-1, -1))

#general events
for event in pygame.event.get():
if event.type == QUIT:
App.quit()
elif event.type == pygame.MOUSEBUTTONDOWN:
if gr.BOUND_LOW.collidepoint(pygame.mouse.get_pos()):
self.active.mouseDown(App.transformPosToLower(pygame.mouse.get_pos()))
elif event.type == pygame.MOUSEBUTTONUP:
if gr.BOUND_LOW.collidepoint(pygame.mouse.get_pos()):
self.active.mouseUp(App.transformPosToLower(pygame.mouse.get_pos()))

@staticmethod
def transformPosToLower(position):
return position[0]-gr.BOUND_LOW.x, position[1]-gr.BOUND_LOW.y

# Outward facing
def switchStage(self, stageName):
if stageName in self.stageNames:
self.active.unload()
self.active = self.stages[stageName]
self.active.load()
else:
logging.exception("Unknown stage name provided")


"""
App initialization and game loop.
"""
if __name__ == "__main__":
app = App()
while True:
app.loop()
app.clock.tick(FPS)
Binary file added src/assets/art/catch-art-beach.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/art/catch-art-cave.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/art/catch-art-low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/art/catch-art-mesa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/art/catch-art-ocean.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/art/catch-art-plains.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/art/credits-art-up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/art/journal-image-frame.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/art/title-art-low.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/art/title-art-up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 017cfe5

Please sign in to comment.