Pixel Gamble 2.0: законченная игра на ресурсах Ninja Adventure
- 10 волн, 5 видов врагов со своим поведением и босс в три фазы - меч, копьё и посох, 11 улучшений между волнами, опыт и уровни - меню, пауза, настройки, итоги партии и рекорд, русский и английский - мир 480×270 с масштабированием, интерфейс в 960×540, скорости от dt - асинхронный цикл: та же игра в браузере через pygbag - тесты без окна, автоигрок, CI, релизы exe/Linux, GitHub Pages - README на двух языках; исходная версия — релиз v1.0.0
27
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python: ["3.10", "3.12"]
|
||||
env:
|
||||
SDL_VIDEODRIVER: dummy
|
||||
SDL_AUDIODRIVER: dummy
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
- run: pip install -r requirements-dev.txt
|
||||
- run: ruff check .
|
||||
- run: pytest -q
|
||||
- name: Автоигрок проходит две минуты игры без ошибок
|
||||
working-directory: game
|
||||
run: python main.py --bot --fast --frames 7200
|
||||
36
.github/workflows/pages.yml
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
name: Web version
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths: ["game/**", "web/**", ".github/workflows/pages.yml"]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- run: pip install pygbag==0.9.3
|
||||
- name: Сборка для браузера (pygbag)
|
||||
run: python -m pygbag --build --title "Pixel Gamble" --width 960 --height 540 --template web/template.tmpl game
|
||||
- uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: game/build/web
|
||||
- id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
38
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-latest
|
||||
file: PixelGamble-windows.exe
|
||||
- os: ubuntu-latest
|
||||
file: PixelGamble-linux.tar.gz
|
||||
runs-on: ${{ matrix.os }}
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- run: pip install -r requirements.txt pyinstaller pillow
|
||||
- name: Иконка из портрета героя
|
||||
run: python -c "from PIL import Image; Image.open('game/assets/images/chars/player_face.png').resize((256, 256), Image.NEAREST).save('icon.ico')"
|
||||
- name: Сборка в один файл
|
||||
run: pyinstaller --onefile --windowed --name PixelGamble --icon icon.ico --add-data "game/assets:assets" game/main.py
|
||||
- name: Упаковка (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
run: Move-Item dist/PixelGamble.exe ${{ matrix.file }}
|
||||
- name: Упаковка (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: tar -czf ${{ matrix.file }} -C dist PixelGamble
|
||||
- name: Файл в релиз
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: gh release upload "${{ github.ref_name }}" ${{ matrix.file }} --clobber
|
||||
7
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
build/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.pytest_cache/
|
||||
.ruff_cache/
|
||||
dist/
|
||||
*.spec
|
||||
149
README.en.md
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
# Pixel Gamble
|
||||
|
||||
[Русский](README.md) · **English**
|
||||
|
||||
[](https://github.com/EDeev/pixel_gamble/actions/workflows/ci.yml)
|
||||
[](https://github.com/EDeev/pixel_gamble/releases)
|
||||
|
||||
A pixel-art survival action game in Python and pygame: ten waves of enemies, upgrades between
|
||||
waves and a final fight with the Red Samurai. A run takes about 10 minutes, and the best score is saved.
|
||||
|
||||
**[▶ Play in the browser](https://edeev.github.io/pixel_gamble/)** · [Download for Windows and Linux](https://github.com/EDeev/pixel_gamble/releases/latest)
|
||||
|
||||
**Status:** started as a Yandex Lyceum school project (2022), turned into a complete game in 2026;
|
||||
the version shown at the defence is release [v1.0.0](https://github.com/EDeev/pixel_gamble/releases/tag/v1.0.0)
|
||||
|
||||

|
||||
|
||||
**Stack:** Python 3.10+ · pygame · pygbag (browser build) · PyInstaller · pytest
|
||||
|
||||
## How to play
|
||||
|
||||
| Action | Keys |
|
||||
|---|---|
|
||||
| Move | WASD or arrow keys |
|
||||
| Attack | left mouse button, Space or J |
|
||||
| Switch weapon | Q, mouse wheel, 1–3 |
|
||||
| Pause | Esc or P |
|
||||
| Fullscreen | F11 |
|
||||
|
||||
Mouse attacks aim at the cursor; keyboard attacks go where the hero is facing.
|
||||
|
||||
## What's inside
|
||||
|
||||
- **10 waves.** Enemies come from the edges of the arena, each wave is bigger and tougher, the 10th
|
||||
is the boss.
|
||||
- **5 enemy types with their own behaviour:**
|
||||
- the slime crawls slowly towards you;
|
||||
- the bat zigzags and flies over rocks;
|
||||
- the ninja winds up and lunges;
|
||||
- the skeleton keeps its distance and throws shuriken;
|
||||
- the cyclops demon flashes a warning and charges.
|
||||
- **Boss — the Red Samurai**, with three phases: he slashes up close, adds a dash with a shuriken fan
|
||||
below 60% health, and below 30% speeds up, summons minions and fires a ring of shuriken.
|
||||
- **Three weapons:** the sword sweeps wide, the lance reaches further and pierces, the staff shoots bolts.
|
||||
- **11 upgrades:** pick one of three between waves — hearts, damage, speed, new weapons, triple shot,
|
||||
healing on kills and more.
|
||||
- **XP and levels.** Hearts drop from enemies and broken rocks and heal you.
|
||||
- **Menu, pause, settings** (volume, language, fullscreen), run summary and best score.
|
||||
- **Two languages:** Russian and English.
|
||||
|
||||
| Choosing an upgrade | The boss |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|
||||
## Quick start
|
||||
|
||||
The easiest way is to [play in the browser](https://edeev.github.io/pixel_gamble/) or download a
|
||||
ready-made file from the [releases page](https://github.com/EDeev/pixel_gamble/releases/latest):
|
||||
`PixelGamble-windows.exe` or `PixelGamble-linux.tar.gz`, no Python needed.
|
||||
|
||||
From source:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/EDeev/pixel_gamble.git
|
||||
cd pixel_gamble
|
||||
pip install -r requirements.txt
|
||||
python game/main.py
|
||||
```
|
||||
|
||||
The best score and settings are stored in `%APPDATA%\pixel_gamble` (Windows),
|
||||
`~/.local/share/pixel_gamble` (Linux) or `localStorage` in the browser.
|
||||
|
||||
## How it works
|
||||
|
||||
```
|
||||
game/
|
||||
├── main.py # entry point (desktop and browser)
|
||||
├── pixelgamble/
|
||||
│ ├── app.py # window, main loop, menu, settings, run summary
|
||||
│ ├── game.py # a run: waves, combat, camera, in-game HUD
|
||||
│ ├── player.py # the hero and weapons
|
||||
│ ├── enemies.py # five enemy types
|
||||
│ ├── boss.py # the Red Samurai, three phases
|
||||
│ ├── waves.py # wave plans and the spawn queue
|
||||
│ ├── upgrades.py # upgrades between waves
|
||||
│ ├── world.py # the tile arena
|
||||
│ ├── bot.py # auto-player for tests and GIF recording
|
||||
│ └── … # assets, effects, UI, texts, saves
|
||||
└── assets/ # art, sounds, music and fonts
|
||||
tools/import_assets.py # copies the needed files from the Ninja Adventure pack
|
||||
web/template.tmpl # page template for pygbag
|
||||
```
|
||||
|
||||
The world is drawn at 480×270 and scaled 2×, while the UI is drawn on top at 960×540, so the pixels
|
||||
stay crisp and the text stays readable. Speeds don't depend on FPS. The game loop is async, so the
|
||||
same code runs in the browser via [pygbag](https://github.com/pygame-web/pygbag).
|
||||
|
||||
## Checks
|
||||
|
||||
```bash
|
||||
pip install -r requirements-dev.txt
|
||||
ruff check .
|
||||
pytest
|
||||
python game/main.py --bot --fast --frames 7200 # auto-player, two minutes of play without a window
|
||||
```
|
||||
|
||||
The tests run without a window or sound. They check that:
|
||||
- the auto-player clears the first waves;
|
||||
- the boss goes through all three phases, and both victory and death lead to the summary screen;
|
||||
- upgrades apply, and every wave spawns exactly its plan;
|
||||
- the save survives a corrupted file;
|
||||
- characters can't pass through walls.
|
||||
|
||||
CI runs all of this on Python 3.10 and 3.12.
|
||||
|
||||
## Building
|
||||
|
||||
- **Release:** a `v*` tag builds `PixelGamble-windows.exe` and `PixelGamble-linux.tar.gz` with
|
||||
PyInstaller and attaches them to the release.
|
||||
- **Browser version:** every push to `main` builds it with pygbag and publishes it to GitHub Pages.
|
||||
To do the same locally:
|
||||
|
||||
```bash
|
||||
pip install pygbag==0.9.3
|
||||
python -m pygbag --build --width 960 --height 540 --template web/template.tmpl game
|
||||
```
|
||||
|
||||
## Assets
|
||||
|
||||
- Art, sounds, music and the title font — [Ninja Adventure](https://pixel-boy.itch.io/ninja-adventure-asset-pack)
|
||||
(pixel-boy, CC0 license), license text in `game/assets/LICENSE-ninja-adventure.txt`.
|
||||
- UI font — [Tiny5](https://github.com/Gissio/font_tiny5) (SIL Open Font License, `game/assets/fonts/OFL.txt`).
|
||||
- The page template is based on the standard pygbag template.
|
||||
|
||||
## License
|
||||
|
||||
School project (Yandex Lyceum, 2021–2022 academic year), reworked in 2026. The code is open for
|
||||
study; there is no separate license.
|
||||
|
||||
## Author
|
||||
|
||||
**Egor Deev** — [GitHub](https://github.com/EDeev) · [Telegram](https://t.me/DeevEgor) · [egor@deev.space](mailto:egor@deev.space)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<sub>⭐ If you find this project useful, give it a star on GitHub!</sub>
|
||||
<p><sub>Made with ❤️ — <a href="https://deev.space">deev.space</a></sub></p>
|
||||
</div>
|
||||
194
README.md
|
|
@ -1,124 +1,148 @@
|
|||
# Pixel Gamble
|
||||
|
||||
[](https://python.org)
|
||||
[](https://pygame.org)
|
||||
[](LICENSE)
|
||||
**Русский** · [English](README.en.md)
|
||||
|
||||
## Описание проекта
|
||||
[](https://github.com/EDeev/pixel_gamble/actions/workflows/ci.yml)
|
||||
[](https://github.com/EDeev/pixel_gamble/releases)
|
||||
|
||||
Pixel Gamble — это полнофункциональная 2D action-RPG игра, разработанная на Python с использованием библиотеки Pygame. Проект демонстрирует реализацию классических игровых механик в современной объектно-ориентированной архитектуре.
|
||||
Пиксельный экшен на выживание на Python и pygame: десять волн врагов, улучшения между волнами и
|
||||
финальный бой с Красным самураем. Партия занимает около 10 минут, рекорд сохраняется.
|
||||
|
||||
## Ключевые особенности
|
||||
**[▶ Играть в браузере](https://edeev.github.io/pixel_gamble/)** · [Скачать для Windows и Linux](https://github.com/EDeev/pixel_gamble/releases/latest)
|
||||
|
||||
### Игровые механики
|
||||
- **Система боя**: Реализован динамический боевой процесс с различными типами атак
|
||||
- **ИИ противников**: Интеллектуальные противники с различными поведенческими паттернами
|
||||
- **Система прогрессии**: Механика получения опыта и развития персонажа
|
||||
- **Физика столкновений**: Точная система коллизий с оптимизированными хитбоксами
|
||||
**Статус:** начат как учебный проект Яндекс Лицея (2022), в 2026 доработан до законченной игры;
|
||||
версия с защиты — в релизе [v1.0.0](https://github.com/EDeev/pixel_gamble/releases/tag/v1.0.0)
|
||||
|
||||
### Техническая архитектура
|
||||
- **Модульная структура**: Четкое разделение логики игры по компонентам
|
||||
- **Система камеры**: Следящая камера с плавным движением
|
||||
- **Карты уровней**: CSV-основанная система генерации игрового мира
|
||||
- **Аудиосистема**: Интегрированное воспроизведение звуковых эффектов
|
||||

|
||||
|
||||
## Технологический стек
|
||||
**Стек:** Python 3.10+ · pygame · pygbag (браузерная сборка) · PyInstaller · pytest
|
||||
|
||||
- **Язык программирования**: Python 3.8+
|
||||
- **Игровой движок**: Pygame 2.0+
|
||||
- **Управление ресурсами**: CSV для уровней, PNG для графики
|
||||
- **Архитектурный паттерн**: Entity-Component-System (ECS)
|
||||
## Как играть
|
||||
|
||||
## Структура проекта
|
||||
| Действие | Клавиши |
|
||||
|---|---|
|
||||
| Движение | WASD или стрелки |
|
||||
| Удар | левая кнопка мыши, пробел или J |
|
||||
| Сменить оружие | Q, колесо мыши, 1–3 |
|
||||
| Пауза | Esc или P |
|
||||
| Полный экран | F11 |
|
||||
|
||||
```
|
||||
pixel_gamble/
|
||||
├── code/
|
||||
│ ├── main.py # Точка входа в приложение
|
||||
│ ├── game.py # Основной игровой цикл
|
||||
│ ├── level.py # Логика уровней и камеры
|
||||
│ ├── player.py # Класс игрока
|
||||
│ ├── enemy.py # Система противников
|
||||
│ ├── entity.py # Базовый класс сущностей
|
||||
│ └── data.py # Конфигурация и утилиты
|
||||
├── data/
|
||||
│ ├── map/ # CSV файлы карт
|
||||
│ ├── textures/ # Графические ресурсы
|
||||
│ └── audio/ # Звуковые файлы
|
||||
└── requirements.txt # Зависимости проекта
|
||||
```
|
||||
При ударе мышью оружие бьёт в сторону курсора, с клавиатуры — туда, куда смотрит герой.
|
||||
|
||||
## Установка и запуск
|
||||
## Что в игре
|
||||
|
||||
### Требования к системе
|
||||
- Python 3.8 или выше
|
||||
- Pygame 2.0+
|
||||
- **10 волн.** Враги появляются у краёв арены, каждая следующая волна больше и сильнее, 10-я — босс.
|
||||
- **5 видов врагов с разным поведением:**
|
||||
- слайм медленно ползёт к игроку;
|
||||
- летучая мышь петляет и пролетает над камнями;
|
||||
- ниндзя замахивается и делает выпад;
|
||||
- скелет держит дистанцию и метает сюрикены;
|
||||
- демон-циклоп предупреждает вспышкой и бросается тараном.
|
||||
- **Босс — Красный самурай** с тремя фазами: рубит мечом вблизи, с 60% здоровья добавляет рывок с
|
||||
веером сюрикенов, с 30% ускоряется, призывает помощников и стреляет кольцом.
|
||||
- **Три оружия:** меч бьёт широким взмахом, копьё — дальше и насквозь, посох стреляет зарядами.
|
||||
- **11 улучшений:** между волнами нужно выбрать одно из трёх — сердца, урон, скорость, новое оружие,
|
||||
тройной заряд, лечение за победы и другие.
|
||||
- **Опыт и уровни.** Сердечки выпадают из врагов и разбитых камней и лечат.
|
||||
- **Меню, пауза, настройки** (громкость, язык, полный экран), итоги партии и рекорд.
|
||||
- **Два языка:** русский и английский.
|
||||
|
||||
### Процесс установки
|
||||
| Выбор улучшения | Босс |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|
||||
## Быстрый старт
|
||||
|
||||
Проще всего — [играть в браузере](https://edeev.github.io/pixel_gamble/) или скачать готовый файл
|
||||
со [страницы релизов](https://github.com/EDeev/pixel_gamble/releases/latest): `PixelGamble-windows.exe` или
|
||||
`PixelGamble-linux.tar.gz`, Python для них не нужен.
|
||||
|
||||
Из исходников:
|
||||
|
||||
1. **Клонирование репозитория**:
|
||||
```bash
|
||||
git clone https://github.com/DeevEV/pixel_gamble.git
|
||||
git clone https://github.com/EDeev/pixel_gamble.git
|
||||
cd pixel_gamble
|
||||
```
|
||||
|
||||
2. **Установка зависимостей**:
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
python game/main.py
|
||||
```
|
||||
|
||||
3. **Запуск игры**:
|
||||
Рекорд и настройки хранятся в `%APPDATA%\pixel_gamble` (Windows), `~/.local/share/pixel_gamble`
|
||||
(Linux), в браузере — в `localStorage`.
|
||||
|
||||
## Устройство
|
||||
|
||||
```
|
||||
game/
|
||||
├── main.py # точка входа (рабочий стол и браузер)
|
||||
├── pixelgamble/
|
||||
│ ├── app.py # окно, главный цикл, меню, настройки, итоги
|
||||
│ ├── game.py # партия: волны, бой, камера, интерфейс боя
|
||||
│ ├── player.py # герой и оружие
|
||||
│ ├── enemies.py # пять видов врагов
|
||||
│ ├── boss.py # Красный самурай, три фазы
|
||||
│ ├── waves.py # состав волн и очередь появления
|
||||
│ ├── upgrades.py # улучшения между волнами
|
||||
│ ├── world.py # арена из плиток
|
||||
│ ├── bot.py # автоигрок для проверок и записи GIF
|
||||
│ └── … # ресурсы, эффекты, интерфейс, тексты, сохранения
|
||||
└── assets/ # графика, звук, музыка и шрифты
|
||||
tools/import_assets.py # перенос нужных файлов из набора Ninja Adventure
|
||||
web/template.tmpl # шаблон страницы для pygbag
|
||||
```
|
||||
|
||||
Мир рисуется в разрешении 480×270 и масштабируется в два раза, а интерфейс — поверх, в 960×540,
|
||||
поэтому пиксели остаются чёткими и текст читается. Скорости не зависят от FPS. Игровой цикл
|
||||
асинхронный, поэтому тот же код работает в браузере через [pygbag](https://github.com/pygame-web/pygbag).
|
||||
|
||||
## Проверки
|
||||
|
||||
```bash
|
||||
cd code
|
||||
python main.py
|
||||
pip install -r requirements-dev.txt
|
||||
ruff check .
|
||||
pytest
|
||||
python game/main.py --bot --fast --frames 7200 # автоигрок, две минуты игры без окна
|
||||
```
|
||||
|
||||
## Управление
|
||||
Тесты запускаются без окна и звука. Проверяются:
|
||||
- автоигрок проходит первые волны;
|
||||
- босс проходит все три фазы, победа и смерть ведут на экран итогов;
|
||||
- улучшения применяются, а каждая волна выпускает ровно свой состав;
|
||||
- сохранение переживает испорченный файл;
|
||||
- персонаж не проходит сквозь стены.
|
||||
|
||||
- **W, A, S, D** — Перемещение персонажа
|
||||
- **ЛКМ** — Атака
|
||||
- **ESC** — Выход из игры
|
||||
CI прогоняет всё это на Python 3.10 и 3.12.
|
||||
|
||||
## Архитектурные решения
|
||||
## Сборка
|
||||
|
||||
### Система сущностей
|
||||
Игра построена на базовом классе `Entity`, обеспечивающем унифицированный интерфейс для всех игровых объектов с поддержкой:
|
||||
- Движения и физики
|
||||
- Анимационной системы
|
||||
- Обработки столкновений
|
||||
- **Релиз:** тег `v*` собирает `PixelGamble-windows.exe` и `PixelGamble-linux.tar.gz` через
|
||||
PyInstaller и прикладывает их к релизу.
|
||||
- **Браузерная версия:** каждый пуш в `main` собирает её через pygbag и выкладывает на GitHub Pages.
|
||||
Локально это делается так:
|
||||
|
||||
### Управление ресурсами
|
||||
- CSV-файлы для описания структуры уровней
|
||||
- Модульная система загрузки графических ресурсов
|
||||
- Централизованное управление игровыми данными
|
||||
```bash
|
||||
pip install pygbag==0.9.3
|
||||
python -m pygbag --build --width 960 --height 540 --template web/template.tmpl game
|
||||
```
|
||||
|
||||
### Производительность
|
||||
- Оптимизированная система рендеринга с сортировкой по глубине
|
||||
- Эффективная обработка столкновений
|
||||
- Управление памятью через группы спрайтов Pygame
|
||||
## Ресурсы
|
||||
|
||||
## Возможности расширения
|
||||
|
||||
Проект спроектирован с учетом масштабируемости:
|
||||
- Легкое добавление новых типов противников
|
||||
- Расширяемая система оружия
|
||||
- Модульная архитектура уровней
|
||||
- Гибкая система анимаций
|
||||
- Графика, звуки, музыка и шрифт заголовка — [Ninja Adventure](https://pixel-boy.itch.io/ninja-adventure-asset-pack)
|
||||
(pixel-boy, лицензия CC0), текст лицензии — `game/assets/LICENSE-ninja-adventure.txt`.
|
||||
- Шрифт интерфейса — [Tiny5](https://github.com/Gissio/font_tiny5) (SIL Open Font License, `game/assets/fonts/OFL.txt`).
|
||||
- Шаблон страницы — на основе стандартного шаблона pygbag.
|
||||
|
||||
## Лицензия
|
||||
|
||||
Этот проект распространяется под лицензией MIT.
|
||||
Учебный проект (Яндекс Лицей, 2021–2022 учебный год), доработанный в 2026 — код доступен для
|
||||
изучения, отдельной лицензии нет.
|
||||
|
||||
## Контакты разработчика
|
||||
## Автор
|
||||
|
||||
**Деев Егор Викторович** - Backend Developer
|
||||
- GitHub: [@EDeev](https://github.com/EDeev)
|
||||
- Email: egor@deev.space
|
||||
- Telegram: [@Egor_Deev](https://t.me/Egor_Deev)
|
||||
**Деев Егор Викторович** — [GitHub](https://github.com/EDeev) · [Telegram](https://t.me/DeevEgor) · [egor@deev.space](mailto:egor@deev.space)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<sub>Проект создан в рамках изучения игровой разработки и демонстрации навыков программирования на Python.</sub>
|
||||
<p><sub>Создано с ❤️ от вашего дорогого - deev.space ©</sub></p>
|
||||
<sub>⭐ Если проект оказался полезным, поставьте звёздочку на GitHub!</sub>
|
||||
<p><sub>Сделано с ❤️ — <a href="https://deev.space">deev.space</a></sub></p>
|
||||
</div>
|
||||
|
|
|
|||
36
code/data.py
|
|
@ -1,36 +0,0 @@
|
|||
from csv import reader
|
||||
from os import walk
|
||||
import pygame
|
||||
|
||||
# ОСНОВНЫЕ НАСТРОЙКИ
|
||||
WIDTH = 1920
|
||||
HEIGTH = 1080
|
||||
FPS = 60
|
||||
TILESIZE = 64
|
||||
HITBOX = {'player': -26, 'stone': -10, 'invisible': 0}
|
||||
|
||||
weapon_data = {'sword': {'cooldown': 100, 'damage': 15}} # набор оружия
|
||||
mobs_data = {'ninja': {'health': 100, 'exp': 250, 'damage': 6, # тип и характеристики моба
|
||||
'attack_type': 'leaf_attack', 'attack_sound': '../data/audio/hit.wav',
|
||||
'speed': 3, 'resistance': 3, 'attack_radius': 50, 'notice_radius': 300}}
|
||||
|
||||
|
||||
def import_csv_layout(path): # ЗАГРУЗКА ФАЙЛОВ CSV КАРТЫ
|
||||
terrain_map = []
|
||||
with open(path) as level_map:
|
||||
layout = reader(level_map, delimiter=',')
|
||||
for row in layout:
|
||||
terrain_map.append(list(row))
|
||||
return terrain_map
|
||||
|
||||
|
||||
def import_folder(path): # ОБРАБОТКА КАРТИНОК
|
||||
surface_list = []
|
||||
|
||||
for i, j, img_files in walk(path):
|
||||
for image in img_files:
|
||||
full_path = path + '/' + image
|
||||
image_surf = pygame.image.load(full_path).convert_alpha()
|
||||
surface_list.append(image_surf)
|
||||
|
||||
return surface_list
|
||||
124
code/enemy.py
|
|
@ -1,124 +0,0 @@
|
|||
from data import *
|
||||
from entity import Entity
|
||||
|
||||
|
||||
class Enemy(Entity):
|
||||
def __init__(self, monster_name, pos, groups, obstacle_sprites, damage_player, add_exp):
|
||||
super().__init__(groups)
|
||||
self.sprite_type = 'enemy'
|
||||
|
||||
# стартовый спрайт
|
||||
self.import_graphics(monster_name)
|
||||
self.status = 'idle'
|
||||
self.image = self.animations[self.status][self.frame_index]
|
||||
|
||||
# положение
|
||||
self.rect = self.image.get_rect(topleft=pos)
|
||||
self.hitbox = self.rect.inflate(0, -10)
|
||||
self.obstacle_sprites = obstacle_sprites
|
||||
|
||||
# характеристики
|
||||
self.monster_name = monster_name
|
||||
monster_info = mobs_data[self.monster_name]
|
||||
self.health = monster_info['health']
|
||||
self.exp = monster_info['exp']
|
||||
self.speed = monster_info['speed']
|
||||
self.attack_damage = monster_info['damage']
|
||||
self.resistance = monster_info['resistance']
|
||||
self.attack_radius = monster_info['attack_radius']
|
||||
self.notice_radius = monster_info['notice_radius']
|
||||
|
||||
# параметры
|
||||
self.can_attack = True
|
||||
self.attack_time = None
|
||||
self.attack_cooldown = 400
|
||||
self.damage_player = damage_player
|
||||
self.add_exp = add_exp
|
||||
|
||||
# звуки
|
||||
self.death_sound = pygame.mixer.Sound('../data/audio/death.wav')
|
||||
self.hit_sound = pygame.mixer.Sound('../data/audio/hit.wav')
|
||||
self.attack_sound = pygame.mixer.Sound(monster_info['attack_sound'])
|
||||
self.death_sound.set_volume(0.6)
|
||||
self.hit_sound.set_volume(0.6)
|
||||
self.attack_sound.set_volume(0.6)
|
||||
|
||||
def import_graphics(self, name):
|
||||
self.animations = {'idle': [], 'move': [], 'attack': []}
|
||||
main_path = f'../data/textures/mobs/{name}/'
|
||||
for animation in self.animations.keys():
|
||||
self.animations[animation] = import_folder(main_path + animation)
|
||||
|
||||
def get_player_distance_direction(self, player):
|
||||
enemy_vec = pygame.math.Vector2(self.rect.center)
|
||||
player_vec = pygame.math.Vector2(player.rect.center)
|
||||
distance = (player_vec - enemy_vec).magnitude()
|
||||
|
||||
if distance > 0:
|
||||
direction = (player_vec - enemy_vec).normalize()
|
||||
else:
|
||||
direction = pygame.math.Vector2()
|
||||
|
||||
return (distance, direction)
|
||||
|
||||
def get_status(self, player):
|
||||
distance = self.get_player_distance_direction(player)[0]
|
||||
|
||||
if distance <= self.attack_radius and self.can_attack:
|
||||
if self.status != 'attack':
|
||||
self.frame_index = 0
|
||||
self.status = 'attack'
|
||||
elif distance <= self.notice_radius:
|
||||
self.status = 'move'
|
||||
else:
|
||||
self.status = 'idle'
|
||||
|
||||
def actions(self, player):
|
||||
if self.status == 'attack':
|
||||
self.attack_time = pygame.time.get_ticks()
|
||||
self.damage_player(self.attack_damage)
|
||||
self.attack_sound.play()
|
||||
elif self.status == 'move':
|
||||
self.direction = self.get_player_distance_direction(player)[1]
|
||||
else:
|
||||
self.direction = pygame.math.Vector2()
|
||||
|
||||
def animate(self):
|
||||
animation = self.animations[self.status]
|
||||
|
||||
self.frame_index += self.animation_speed
|
||||
if self.frame_index >= len(animation):
|
||||
if self.status == 'attack':
|
||||
self.can_attack = False
|
||||
self.frame_index = 0
|
||||
|
||||
self.image = animation[int(self.frame_index)]
|
||||
self.rect = self.image.get_rect(center=self.hitbox.center)
|
||||
|
||||
def cooldowns(self):
|
||||
current_time = pygame.time.get_ticks()
|
||||
if not self.can_attack:
|
||||
if current_time - self.attack_time >= self.attack_cooldown:
|
||||
self.can_attack = True
|
||||
|
||||
def get_damage(self, player):
|
||||
self.hit_sound.play()
|
||||
self.direction = self.get_player_distance_direction(player)[1]
|
||||
self.health -= player.get_full_weapon_damage()
|
||||
self.hit_time = pygame.time.get_ticks()
|
||||
|
||||
def check_death(self):
|
||||
if self.health <= 0:
|
||||
self.kill()
|
||||
self.add_exp(self.exp)
|
||||
self.death_sound.play()
|
||||
|
||||
def update(self):
|
||||
self.move(self.speed)
|
||||
self.animate()
|
||||
self.cooldowns()
|
||||
self.check_death()
|
||||
|
||||
def enemy_update(self, player):
|
||||
self.get_status(player)
|
||||
self.actions(player)
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
import pygame
|
||||
from math import sin
|
||||
|
||||
|
||||
class Entity(pygame.sprite.Sprite):
|
||||
def __init__(self, groups):
|
||||
super().__init__(groups)
|
||||
self.frame_index = 0
|
||||
self.animation_speed = 0.15
|
||||
self.direction = pygame.math.Vector2()
|
||||
|
||||
def move(self, speed):
|
||||
if self.direction.magnitude() != 0:
|
||||
self.direction = self.direction.normalize()
|
||||
|
||||
self.hitbox.x += self.direction.x * speed
|
||||
self.collision('horizontal')
|
||||
self.hitbox.y += self.direction.y * speed
|
||||
self.collision('vertical')
|
||||
self.rect.center = self.hitbox.center
|
||||
|
||||
def collision(self, direction):
|
||||
if direction == 'horizontal':
|
||||
for sprite in self.obstacle_sprites:
|
||||
if sprite.hitbox.colliderect(self.hitbox):
|
||||
if self.direction.x > 0: # moving right
|
||||
self.hitbox.right = sprite.hitbox.left
|
||||
if self.direction.x < 0: # moving left
|
||||
self.hitbox.left = sprite.hitbox.right
|
||||
|
||||
if direction == 'vertical':
|
||||
for sprite in self.obstacle_sprites:
|
||||
if sprite.hitbox.colliderect(self.hitbox):
|
||||
if self.direction.y > 0: # moving down
|
||||
self.hitbox.bottom = sprite.hitbox.top
|
||||
if self.direction.y < 0: # moving up
|
||||
self.hitbox.top = sprite.hitbox.bottom
|
||||
|
||||
def wave_value(self):
|
||||
value = sin(pygame.time.get_ticks())
|
||||
if value >= 0:
|
||||
return 255
|
||||
else:
|
||||
return 0
|
||||
187
code/level.py
|
|
@ -1,187 +0,0 @@
|
|||
from random import choice
|
||||
|
||||
from data import *
|
||||
from player import Player
|
||||
from enemy import Enemy
|
||||
|
||||
|
||||
class Level:
|
||||
def __init__(self):
|
||||
self.display_surface = pygame.display.get_surface()
|
||||
self.ui = UI()
|
||||
|
||||
# группы основных спрайтов видимых и нет
|
||||
self.visible_sprites = Camera()
|
||||
self.obstacle_sprites = pygame.sprite.Group()
|
||||
|
||||
# группа спрайтов способных разрушиться
|
||||
self.current_attack = None
|
||||
self.attack_sprites = pygame.sprite.Group()
|
||||
self.attackable_sprites = pygame.sprite.Group()
|
||||
|
||||
# генерация карты
|
||||
self.create_map()
|
||||
|
||||
def create_map(self):
|
||||
layouts = {
|
||||
'barryer': import_csv_layout('../data/map/барьеры.csv'),
|
||||
'stone': import_csv_layout('../data/map/камни.csv'),
|
||||
'entities': import_csv_layout('../data/map/мобы.csv')
|
||||
}
|
||||
graphics = {'stone': import_folder('../data/textures/stone')}
|
||||
|
||||
for style, layout in layouts.items():
|
||||
for row_index, row in enumerate(layout):
|
||||
for col_index, col in enumerate(row):
|
||||
if col != '-1':
|
||||
x = col_index * TILESIZE
|
||||
y = row_index * TILESIZE
|
||||
if style == 'barryer':
|
||||
Tile((x, y), [self.obstacle_sprites], 'invisible')
|
||||
if style == 'stone':
|
||||
random_grass_image = choice(graphics['stone'])
|
||||
Tile((x, y), [self.visible_sprites, self.obstacle_sprites, self.attackable_sprites],
|
||||
'stone', random_grass_image)
|
||||
if style == 'entities':
|
||||
if col == '2':
|
||||
self.player = Player((x, y), [self.visible_sprites], self.obstacle_sprites,
|
||||
self.destroy_attack, self.create_attack)
|
||||
else:
|
||||
Enemy("ninja", (x, y), [self.visible_sprites, self.attackable_sprites],
|
||||
self.obstacle_sprites, self.damage_player, self.add_exp)
|
||||
|
||||
def create_attack(self): # создание атаки и спрайта оружия
|
||||
self.current_attack = Weapon(self.player, [self.visible_sprites, self.attack_sprites])
|
||||
|
||||
def destroy_attack(self): # разрушение разрушаемых объектов
|
||||
if self.current_attack:
|
||||
self.current_attack.kill()
|
||||
self.current_attack = None
|
||||
|
||||
def player_attack(self): # удары по другим объектам
|
||||
if self.attack_sprites:
|
||||
for attack_sprite in self.attack_sprites:
|
||||
collision_sprites = pygame.sprite.spritecollide(attack_sprite, self.attackable_sprites, False)
|
||||
if collision_sprites:
|
||||
for target_sprite in collision_sprites:
|
||||
if target_sprite.sprite_type == 'stone': # камни разрушаются с одного удара
|
||||
target_sprite.kill()
|
||||
else: # мобы получают урон
|
||||
target_sprite.get_damage(self.player)
|
||||
|
||||
def damage_player(self, amount):
|
||||
self.player.health -= amount
|
||||
self.player.hurt_time = pygame.time.get_ticks()
|
||||
|
||||
def add_exp(self, amount):
|
||||
self.player.exp += amount
|
||||
|
||||
def run(self):
|
||||
self.visible_sprites.custom_draw(self.player)
|
||||
self.ui.display(self.player)
|
||||
|
||||
self.visible_sprites.update()
|
||||
self.visible_sprites.enemy_update(self.player)
|
||||
self.player_attack()
|
||||
|
||||
|
||||
# КАМЕРА СЛЕДЯЩАЯ ЗА ПЕРСОНАЖЕМ
|
||||
class Camera(pygame.sprite.Group):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.display_surface = pygame.display.get_surface()
|
||||
self.half_width = self.display_surface.get_size()[0] // 2
|
||||
self.half_height = self.display_surface.get_size()[1] // 2
|
||||
self.offset = pygame.math.Vector2()
|
||||
|
||||
# отрисовка основной карты
|
||||
self.floor_surf = pygame.image.load('../data/map/map.png').convert()
|
||||
self.floor_rect = self.floor_surf.get_rect(topleft=(0, 0))
|
||||
|
||||
def custom_draw(self, player):
|
||||
self.offset.x = player.rect.centerx - self.half_width # ПОЛУЧЕНИЕ ПОЗИЦИИ ИГРОКА
|
||||
self.offset.y = player.rect.centery - self.half_height
|
||||
|
||||
floor_offset_pos = self.floor_rect.topleft - self.offset # ОТРИСОВКА ОСНОВНОЙ КАРТЫ ПОД ИГРОКОМ
|
||||
self.display_surface.blit(self.floor_surf, floor_offset_pos)
|
||||
|
||||
for sprite in sorted(self.sprites(), key=lambda sprite: sprite.rect.centery):
|
||||
offset_pos = sprite.rect.topleft - self.offset
|
||||
self.display_surface.blit(sprite.image, offset_pos)
|
||||
|
||||
def enemy_update(self, player): # ОТРИСОВКА МОБОВ
|
||||
enemy_sprites = []
|
||||
for sprite in self.sprites():
|
||||
if hasattr(sprite, 'sprite_type') and sprite.sprite_type == 'enemy':
|
||||
enemy_sprites.append(sprite)
|
||||
|
||||
for enemy in enemy_sprites:
|
||||
enemy.enemy_update(player)
|
||||
|
||||
|
||||
# КЛАСС ОТРИСОВКИ ПЛИТОК
|
||||
class Tile(pygame.sprite.Sprite):
|
||||
def __init__(self, pos, groups, sprite_type, surface=pygame.Surface((TILESIZE, TILESIZE))):
|
||||
super().__init__(groups)
|
||||
self.sprite_type = sprite_type
|
||||
y_offset = HITBOX[sprite_type]
|
||||
self.image = surface
|
||||
|
||||
if sprite_type == 'object':
|
||||
self.rect = self.image.get_rect(topleft=(pos[0], pos[1] - TILESIZE))
|
||||
else:
|
||||
self.rect = self.image.get_rect(topleft=pos)
|
||||
|
||||
self.hitbox = self.rect.inflate(0, y_offset)
|
||||
|
||||
|
||||
# КЛАСС ОРУЖИЯ
|
||||
class Weapon(pygame.sprite.Sprite):
|
||||
def __init__(self, player, groups):
|
||||
super().__init__(groups)
|
||||
self.sprite_type = 'weapon'
|
||||
self.image = pygame.image.load(f'../data/textures/sword/{player.status.split("_")[0]}.png').convert_alpha()
|
||||
|
||||
# отрисовка оружия по отношению к герою
|
||||
if player.status == 'right':
|
||||
self.rect = self.image.get_rect(midleft=player.rect.midright + pygame.math.Vector2(-3, 16))
|
||||
elif player.status == 'left':
|
||||
self.rect = self.image.get_rect(midright=player.rect.midleft + pygame.math.Vector2(3, 16))
|
||||
elif player.status == 'down':
|
||||
self.rect = self.image.get_rect(midtop=player.rect.midbottom + pygame.math.Vector2(-10, 0))
|
||||
else:
|
||||
self.rect = self.image.get_rect(midbottom=player.rect.midtop + pygame.math.Vector2(-10, 20))
|
||||
|
||||
|
||||
# КЛАСС ИНТРЕФЕЙСА
|
||||
class UI:
|
||||
def __init__(self):
|
||||
self.screen = pygame.display.get_surface()
|
||||
self.font = pygame.font.SysFont("arial", 24) # размер и формат чисел опыта
|
||||
|
||||
def health_bar(self, player):
|
||||
pygame.draw.rect(self.screen, '#222222', pygame.Rect(10, 10, 120, 30))
|
||||
|
||||
# перевод кол-ва здоровья в полоску
|
||||
ratio = player.health / player.stats['health']
|
||||
current_width = pygame.Rect(10, 10, 120, 30).width * ratio
|
||||
current_rect = pygame.Rect(10, 10, 120, 30).copy()
|
||||
current_rect.width = current_width
|
||||
|
||||
pygame.draw.rect(self.screen, 'red', current_rect)
|
||||
pygame.draw.rect(self.screen, 'black', pygame.Rect(10, 10, 120, 30), 3)
|
||||
|
||||
def show_exp(self, exp):
|
||||
text_surf = self.font.render(str(int(exp)), False, 'white')
|
||||
x = self.screen.get_size()[0] - 20 # место ячейки опыта
|
||||
y = self.screen.get_size()[1] - 1040
|
||||
text_rect = text_surf.get_rect(bottomright=(x, y))
|
||||
|
||||
pygame.draw.rect(self.screen, '#222222', text_rect.inflate(20, 20)) # отрисовка опыта и серого фона
|
||||
self.screen.blit(text_surf, text_rect)
|
||||
|
||||
pygame.draw.rect(self.screen, 'black', text_rect.inflate(20, 20), 3) # отрисовка чёрной рамки
|
||||
|
||||
def display(self, player):
|
||||
self.health_bar(player)
|
||||
self.show_exp(player.exp)
|
||||
39
code/main.py
|
|
@ -1,39 +0,0 @@
|
|||
import sys
|
||||
|
||||
from data import *
|
||||
from level import Level
|
||||
|
||||
|
||||
class Game:
|
||||
def __init__(self):
|
||||
pygame.init()
|
||||
self.screen = pygame.display.set_mode((WIDTH, HEIGTH))
|
||||
pygame.display.set_caption('Pixel Gamble')
|
||||
self.clock = pygame.time.Clock()
|
||||
|
||||
self.level = Level()
|
||||
|
||||
main_sound = pygame.mixer.Sound('../data/audio/main.wav')
|
||||
main_sound.set_volume(0.5)
|
||||
main_sound.play(loops=-1)
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_ESCAPE:
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
|
||||
self.screen.fill('black')
|
||||
self.level.run()
|
||||
pygame.display.update()
|
||||
self.clock.tick(FPS)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
game = Game()
|
||||
game.run()
|
||||
128
code/player.py
|
|
@ -1,128 +0,0 @@
|
|||
from data import *
|
||||
from entity import Entity
|
||||
|
||||
|
||||
class Player(Entity):
|
||||
def __init__(self, pos, groups, obstacle_sprites, destroy_attack, create_attack):
|
||||
super().__init__(groups)
|
||||
self.image = pygame.image.load('../data/textures/player/player.png').convert_alpha()
|
||||
self.rect = self.image.get_rect(topleft=pos)
|
||||
self.hitbox = self.rect.inflate(-6, HITBOX['player'])
|
||||
|
||||
# стартовое положение спрайта
|
||||
self.import_player_assets()
|
||||
self.status = 'down'
|
||||
|
||||
# параметры героя
|
||||
self.attacking = False
|
||||
self.attack_cooldown = 400
|
||||
self.attack_time = None
|
||||
self.obstacle_sprites = obstacle_sprites
|
||||
|
||||
# оружик героя
|
||||
self.destroy_attack = destroy_attack
|
||||
self.weapon_index = 0
|
||||
self.create_attack = create_attack
|
||||
self.weapon = list(weapon_data.keys())[self.weapon_index]
|
||||
self.can_switch_weapon = True
|
||||
self.weapon_switch_time = None
|
||||
self.switch_duration_cooldown = 200
|
||||
|
||||
# характеристики героя
|
||||
self.stats = {'health': 300, 'attack': 10, 'speed': 5}
|
||||
self.max_stats = {'health': 300, 'attack': 20, 'speed': 10}
|
||||
self.health = self.stats['health']
|
||||
self.speed = self.stats['speed']
|
||||
self.exp = 0
|
||||
|
||||
# import a sound
|
||||
self.weapon_attack_sound = pygame.mixer.Sound('../data/audio/sword.wav')
|
||||
self.weapon_attack_sound.set_volume(0.4)
|
||||
|
||||
def import_player_assets(self): # получение всех картинок героя
|
||||
self.animations = {'up': [], 'down': [], 'left': [], 'right': [],
|
||||
'right_stand': [], 'left_stand': [], 'up_stand': [], 'down_stand': [],
|
||||
'right_attack': [], 'left_attack': [], 'up_attack': [], 'down_attack': []}
|
||||
|
||||
for animation in self.animations.keys():
|
||||
full_path = '../data/textures/player/' + animation
|
||||
self.animations[animation] = import_folder(full_path)
|
||||
|
||||
def input(self): # кнопки
|
||||
if not self.attacking:
|
||||
keys = pygame.key.get_pressed()
|
||||
mouse = pygame.mouse.get_pressed()
|
||||
|
||||
if keys[pygame.K_w]:
|
||||
self.direction.y = -1
|
||||
self.status = 'up'
|
||||
elif keys[pygame.K_s]:
|
||||
self.direction.y = 1
|
||||
self.status = 'down'
|
||||
else:
|
||||
self.direction.y = 0
|
||||
|
||||
if keys[pygame.K_d]:
|
||||
self.direction.x = 1
|
||||
self.status = 'right'
|
||||
elif keys[pygame.K_a]:
|
||||
self.direction.x = -1
|
||||
self.status = 'left'
|
||||
else:
|
||||
self.direction.x = 0
|
||||
|
||||
if mouse[0]:
|
||||
self.attacking = True
|
||||
self.attack_time = pygame.time.get_ticks()
|
||||
self.create_attack()
|
||||
self.weapon_attack_sound.play()
|
||||
|
||||
def get_status(self): # положение героя на поле
|
||||
if self.direction.x == 0 and self.direction.y == 0:
|
||||
if not 'stand' in self.status and not 'attack' in self.status:
|
||||
self.status = self.status + '_stand'
|
||||
|
||||
if self.attacking:
|
||||
self.direction.x = 0
|
||||
self.direction.y = 0
|
||||
if not 'attack' in self.status:
|
||||
if 'stand' in self.status:
|
||||
self.status = self.status.replace('_stand', '_attack')
|
||||
else:
|
||||
self.status = self.status + '_attack'
|
||||
else:
|
||||
if 'attack' in self.status:
|
||||
self.status = self.status.replace('_attack', '')
|
||||
|
||||
def cooldowns(self): # таймер востановления удара
|
||||
current_time = pygame.time.get_ticks()
|
||||
|
||||
if self.attacking:
|
||||
if current_time - self.attack_time >= self.attack_cooldown + weapon_data[self.weapon]['cooldown']:
|
||||
self.attacking = False
|
||||
self.destroy_attack()
|
||||
|
||||
if not self.can_switch_weapon:
|
||||
if current_time - self.weapon_switch_time >= self.switch_duration_cooldown:
|
||||
self.can_switch_weapon = True
|
||||
|
||||
def animate(self): # анимирование героя
|
||||
animation = self.animations[self.status]
|
||||
self.frame_index += self.animation_speed
|
||||
if self.frame_index >= len(animation):
|
||||
self.frame_index = 0
|
||||
|
||||
self.image = animation[int(self.frame_index)]
|
||||
self.rect = self.image.get_rect(center=self.hitbox.center)
|
||||
|
||||
def get_full_weapon_damage(self): # нанесение врагу урона
|
||||
base_damage = self.stats['attack']
|
||||
weapon_damage = weapon_data[self.weapon]['damage']
|
||||
return base_damage + weapon_damage
|
||||
|
||||
def update(self):
|
||||
self.input()
|
||||
self.cooldowns()
|
||||
self.get_status()
|
||||
self.animate()
|
||||
self.move(self.stats['speed'])
|
||||
BIN
data/map/map.png
|
Before Width: | Height: | Size: 265 KiB |
|
|
@ -1,17 +0,0 @@
|
|||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,-1
|
||||
-1,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,-1
|
||||
-1,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,395,-1
|
||||
-1,395,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,395,-1
|
||||
-1,395,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,395,-1
|
||||
-1,395,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,395,-1
|
||||
-1,395,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,395,-1
|
||||
-1,395,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,395,-1
|
||||
-1,395,-1,-1,-1,-1,-1,-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1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
|
|
Before Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 557 B |
|
Before Width: | Height: | Size: 558 B |
|
Before Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 557 B |
|
Before Width: | Height: | Size: 558 B |
|
Before Width: | Height: | Size: 555 B |
|
Before Width: | Height: | Size: 557 B |
|
Before Width: | Height: | Size: 558 B |
|
Before Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 404 B |
|
Before Width: | Height: | Size: 399 B |
|
Before Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 392 B |
|
Before Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 421 B |
|
Before Width: | Height: | Size: 401 B |
|
Before Width: | Height: | Size: 400 B |
|
Before Width: | Height: | Size: 415 B |
|
Before Width: | Height: | Size: 402 B |
|
Before Width: | Height: | Size: 440 B |
|
Before Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 401 B |
|
Before Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 417 B |
|
Before Width: | Height: | Size: 411 B |
|
Before Width: | Height: | Size: 284 B |
|
Before Width: | Height: | Size: 337 B |
|
Before Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 284 B |
|
Before Width: | Height: | Size: 443 B |
|
Before Width: | Height: | Size: 317 B |
|
Before Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 319 B |
|
Before Width: | Height: | Size: 461 B |
|
Before Width: | Height: | Size: 459 B |
|
Before Width: | Height: | Size: 432 B |
|
Before Width: | Height: | Size: 452 B |
|
Before Width: | Height: | Size: 462 B |
|
Before Width: | Height: | Size: 398 B |
|
Before Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 440 B |
|
Before Width: | Height: | Size: 443 B |
|
Before Width: | Height: | Size: 461 B |
|
Before Width: | Height: | Size: 459 B |
|
Before Width: | Height: | Size: 432 B |
|
Before Width: | Height: | Size: 452 B |
|
Before Width: | Height: | Size: 462 B |
|
Before Width: | Height: | Size: 398 B |
|
Before Width: | Height: | Size: 404 B |
|
Before Width: | Height: | Size: 399 B |
|
Before Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 392 B |
|
Before Width: | Height: | Size: 403 B |
|
Before Width: | Height: | Size: 421 B |
|
Before Width: | Height: | Size: 401 B |
|
Before Width: | Height: | Size: 400 B |
|
Before Width: | Height: | Size: 415 B |
|
Before Width: | Height: | Size: 402 B |
|
Before Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 401 B |
|
Before Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 417 B |
|
Before Width: | Height: | Size: 411 B |
|
Before Width: | Height: | Size: 284 B |
|
Before Width: | Height: | Size: 337 B |
|
Before Width: | Height: | Size: 328 B |
|
Before Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 284 B |
|
Before Width: | Height: | Size: 317 B |
|
Before Width: | Height: | Size: 333 B |
|
Before Width: | Height: | Size: 319 B |
|
Before Width: | Height: | Size: 700 B |
|
Before Width: | Height: | Size: 688 B |
|
Before Width: | Height: | Size: 694 B |
|
Before Width: | Height: | Size: 720 B |
|
Before Width: | Height: | Size: 720 B |
|
Before Width: | Height: | Size: 681 B |
|
Before Width: | Height: | Size: 705 B |