Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Virashu committed Feb 21, 2024
2 parents 76e75e3 + 1bf9ea8 commit 1ea5c78
Show file tree
Hide file tree
Showing 49 changed files with 1,667 additions and 846 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: Silleellie/pylint-github-action@v2
with:
# The path, relative to the root of the repo, of the package(s) or pyton file(s) to lint
lint-path: danmaku
lint-path: danmaku/**/*.py
# Python version which will install all dependencies and lint package(s)
python-version: "3.10"
# The path, relative to the root of the repo, of the requirements to install
Expand Down
35 changes: 28 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
# 弾幕 (Danmaku)
![pylint](https://img.shields.io/badge/PyLint-9.71-yellow?logo=python&logoColor=white)
![pylint](https://img.shields.io/badge/PyLint-9.95-yellow?logo=python&logoColor=white)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

## Goal
To create a bullet hell game similar to TouHou Project, Undertale, etc.

## How to build

```
poetry shell
poetry install
```
or
```
python3 -m venv .venv
.\.venv\Scripts\activate
pip install --upgrade -r .\requirements.txt
```
Then,
```
.\build
```

## For developers

Most important things is written down [here](./docs/mecs.md)

## Refactoring
- [x] main.py
- [x] bullet.py
Expand All @@ -18,7 +39,7 @@ To create a bullet hell game similar to TouHou Project, Undertale, etc.

- [x] Game mechanics
- [x] Drops
- [ ] HP (?)
- [ ] HP (?)
- [x] XP
- [x] Powerups
- [ ] Coins (?)
Expand All @@ -38,13 +59,13 @@ To create a bullet hell game similar to TouHou Project, Undertale, etc.
- [ ] Effects (particles)
- [ ] Scaling
- [ ] Fullscreen
- [ ] Boss HP bar
- [x] Boss HP bar
- [x] Player HP/Bomb info
- [x] Player points info
- [ ] UI
- [x] UI
- [x] Main menu
- [x] Main menu style
- [ ] Background
- [x] Background
- [x] Leaderboard
- [x] Settings
- [x] DB
Expand All @@ -66,6 +87,6 @@ To create a bullet hell game similar to TouHou Project, Undertale, etc.
- [x] Replace resource path strings with constants from db
- [x] Sounds
- [x] Death
- [ ] Shoot
- [ ] Hit
- [x] Shoot
- [x] Hit
- [x] Music
Binary file modified assets/DataBase.db
Binary file not shown.
Binary file added assets/sounds/game.wav
Binary file not shown.
Binary file added assets/sounds/hit.wav
Binary file not shown.
Binary file added assets/sounds/lose.wav
Binary file not shown.
Binary file added assets/sounds/menu.wav
Binary file not shown.
Binary file added assets/sounds/shoot.wav
Binary file not shown.
Binary file added assets/sounds/win.wav
Binary file not shown.
Binary file removed assets/textures/basic_enemy.png
Binary file not shown.
Binary file added assets/textures/menu.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 removed assets/textures/player.png
Binary file not shown.
Binary file removed assets/textures/strong_enemy.png
Binary file not shown.
63 changes: 0 additions & 63 deletions danmaku/animated.py

This file was deleted.

14 changes: 7 additions & 7 deletions danmaku/database/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

basic_enemy = EnemyTypes.create(
name="basic enemy",
texture_file="basic_enemy_2.png;basic_enemy_1.png;"
"basic_enemy_2.png;basic_enemy_3.png",
texture_file="basic_enemy_down_static_2.png;basic_enemy_down_1.png;"
"basic_enemy_down_static_2.png;basic_enemy_down_3.png",
texture_size_width=50,
texture_size_height=65,
speed=30,
Expand All @@ -31,8 +31,8 @@

strong_enemy = EnemyTypes.create(
name="strong enemy",
texture_file="strong_enemy_2.png;strong_enemy_1.png;"
"strong_enemy_2.png;strong_enemy_3.png",
texture_file="strong_enemy_down_static_2.png;strong_enemy_down_1.png;"
"strong_enemy_down_static_2.png;strong_enemy_down_3.png",
texture_size_width=50,
texture_size_height=65,
speed=20,
Expand All @@ -46,8 +46,8 @@

boss = EnemyTypes.create(
name="boss",
texture_file="strong_enemy_2.png;strong_enemy_1.png;"
"strong_enemy_2.png;strong_enemy_3.png",
texture_file="strong_enemy_down_static_2.png;strong_enemy_down_1.png;"
"strong_enemy_down_static_2.png;strong_enemy_down_3.png",
texture_size_width=60,
texture_size_height=85,
speed=10,
Expand Down Expand Up @@ -128,7 +128,7 @@
texture_size_height=50,
speed=200,
shoot_v=250,
hp=1300,
hp=500,
dm=10,
endurance=1,
hitbox_radius=10,
Expand Down
53 changes: 36 additions & 17 deletions danmaku/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,43 +88,63 @@ def get_saved_objects() -> list:

def get_saved_game() -> dict:
"""Get saved game from database
Returns dict: {"score", "level", "power"}
Returns dict: {"score", "level", "power", "bombs"}
"""
game = tuple(iter(SavedGame.select().dicts()))[-1]
return game


def get_game_history() -> list:
def get_game_history() -> list[dict[str, int]]:
"""Get game history from database
Returns list: [{"score", "level"}]
Returns list: [{"score", "level", "time"}]
"""
games = tuple(iter(SavedGame.select()))
res = []
for i in games:
objects = {
"score": i.score,
"level": i.level,
}
objects = {"score": i.score, "level": i.level, "time": i.time}
res.append(objects)
return res


def delete_last_game():
"""Remove last game record from database"""
games = list(iter(SavedGame.select()))
SavedGame.delete_by_id(games[-1])
SavedGame.update()


def set_saved_objects(name: str, objects: Iterable) -> None:
"""Set saved objects to database"""
for e in objects:
if hasattr(e, "my_type"):
my_type = e.my_type
else:
my_type = ""
if hasattr(e, "health"):
health = e.health
else:
health = 0
if hasattr(e, "damage"):
damage = e.damage
else:
damage = 0
n = SavedObjects.create(
object=name,
object_type=e.my_type,
object_type=my_type,
object_position=f"{e.x}, {e.y}",
object_hp=e.health,
object_damage=e.damage,
object_hp=health,
object_damage=damage,
)
n.save()


def set_saved_game(cur_level: int, score: int, power: int) -> None:
def set_saved_game(
cur_level: int, score: int, power: int, bombs: int, time: float
) -> None:
"""Set saved game to database"""
n = SavedGame.create(score=score, level=cur_level, power=power)
n = SavedGame.create(
score=score, level=cur_level, power=power, bombs=bombs, time=time
)
n.save()


Expand All @@ -136,14 +156,15 @@ def delete_saved_objects() -> None:


def get_settings() -> dict:
"""Get all settings"""
settings = {}
for setting in Settings.select():
match setting.type:
case "int":
value = int(setting.value)
possible_values = list(map(int, setting.possible_values.split(";")))
case "bool":
value = bool(setting.value)
value = setting.value == "True"
possible_values = [True, False]
case "str":
value = setting.value
Expand All @@ -159,17 +180,15 @@ def get_settings() -> dict:


def delete_settings():
"""Delete all settings"""
for setting in Settings.select():
Settings.delete_by_id(setting)
Settings.update()


def set_settings(settings: dict) -> None:
"""Set settings from dictionary"""
for key, value in settings.items():
s = Settings.get(Settings.name == key)
s.value = value
s.save()


if __name__ == "__main__":
print(get_saved_game())
5 changes: 4 additions & 1 deletion danmaku/database/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
CharField,
IntegerField,
BooleanField,
FloatField,
)
from danmaku.utils import resource_path

# look for database file in the same folder, not folder of execution
db = SqliteDatabase(resource_path("DataBase.db"))


# pylint: disable=missing-class-docstring
# pylint: disable=missing-class-docstring,too-few-public-methods


class BaseModel(Model):
Expand Down Expand Up @@ -71,6 +72,8 @@ class SavedGame(BaseModel):
level = IntegerField()
score = IntegerField()
power = IntegerField()
bombs = IntegerField()
time = FloatField()


class Settings(BaseModel):
Expand Down
Loading

0 comments on commit 1ea5c78

Please sign in to comment.