Merge pull request 'dev-jakklu' (#2) from dev-jakklu into master
Reviewed-on: #2
This commit is contained in:
commit
782b27d264
133
.idea/.gitignore
vendored
133
.idea/.gitignore
vendored
@ -1,8 +1,125 @@
|
|||||||
# Default ignored files
|
# Editors
|
||||||
/shelf/
|
.vscode/
|
||||||
/workspace.xml
|
.idea/
|
||||||
# Datasource local storage ignored files
|
|
||||||
/../../../:\ai-project\.idea/dataSources/
|
# Vagrant
|
||||||
/dataSources.local.xml
|
.vagrant/
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
# Mac/OSX
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
|
||||||
|
# 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/
|
||||||
|
*.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
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# 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
|
24
survival/textureatlas.py
Normal file
24
survival/textureatlas.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
|
||||||
|
class TextureAtlas(object):
|
||||||
|
def __init__(self, filename):
|
||||||
|
self.atlas = pygame.image.load(filename).convert()
|
||||||
|
|
||||||
|
def image_at(self, rectangle, color_key=None):
|
||||||
|
rect = pygame.Rect(rectangle)
|
||||||
|
image = pygame.Surface(rect.size).convert()
|
||||||
|
image.blit(self.atlas, (0, 0), rect)
|
||||||
|
if color_key is not None:
|
||||||
|
if color_key is -1:
|
||||||
|
color_key = image.get_at((0, 0))
|
||||||
|
image.set_colorkey(color_key, pygame.RLEACCEL)
|
||||||
|
return image
|
||||||
|
|
||||||
|
def images_at(self, rects, color_key=None):
|
||||||
|
return [self.image_at(rect, color_key) for rect in rects]
|
||||||
|
|
||||||
|
def load_row(self, rect, image_count, color_key=None):
|
||||||
|
images = [(rect[0] + rect[2] * x, rect[1], rect[2], rect[3])
|
||||||
|
for x in range(image_count)]
|
||||||
|
return self.images_at(images, color_key)
|
Loading…
Reference in New Issue
Block a user