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/0.10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Virashu committed Feb 4, 2024
2 parents 2b29429 + 365f1a4 commit c9198f0
Show file tree
Hide file tree
Showing 71 changed files with 558 additions and 218 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install pylint
# - name: Analysing the code with pylint
# run: |
# pylint $(git ls-files '*.py')
- name: PyLint with dynamic badge
# You may pin to the exact commit or the version.
# uses: Silleellie/pylint-github-action@f5341ef210a203c2c7bbfe5440c03a06b9328866
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
# 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
# requirements-path: # optional, default is requirements.txt
# The path, relative to the root of the repo, of the README.md to update with the pylint badge
# readme-path: # optional, default is README.md
# Text to display in the badge
# badge-text: # optional, default is PyLint
# Color of the badge for pylint scores < 5. Hex, rgb, rgba, hsl, hsla and css named colors can all be used
#color-bad-score: # optional, default is red
# Color of the badge for pylint scores in range [5,8). Hex, rgb, rgba, hsl, hsla and css named colors can all be used
#color-ok-score: # optional, default is orange
# Color of the badge for pylint scores in range [8,10). Hex, rgb, rgba, hsl, hsla and css named colors can all be used
#color-good-score: # optional, default is yellow
# Color of the badge for pylint scores == 10. Hex, rgb, rgba, hsl, hsla and css named colors can all be used
#color-perfect-score: # optional, default is brightgreen

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
_tools

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
74 changes: 37 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# 弾幕 (Danmaku)


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

## Refactoring
- [x] main.py
- [x] bullet.py
- [x] enemy.py
- [x] gameobject.py
- [x] player.py
- [x] utils.py


## TODO
- [x] Levels
- [ ] Boss HP bar
- [ ] Player HP/Bomb info
- [ ] Player points info
- [ ] Main menu
- [ ] Leaderboard
- [x] Sounds
- [x] Music
- [x] Graphics
- [x] Images
- [ ] Level background
- [ ] Effects (particles)
- [x] Bullets
- [ ] Trajectories
- [x] Enemies
- [x] Controls
- [x] Change controls to classic (shift, z, x)
- [ ] Settings
- [ ] Make player hitbox smaller
- [ ] Replace enemies strings with enum
- [ ] Replace resource path strings with constants from db
# 弾幕 (Danmaku)
![pylint](https://img.shields.io/badge/PyLint-9.79-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.

## Refactoring
- [x] main.py
- [x] bullet.py
- [x] enemy.py
- [x] gameobject.py
- [x] player.py
- [x] utils.py


## TODO
- [x] Levels
- [ ] Boss HP bar
- [x] Player HP/Bomb info
- [x] Player points info
- [x] Main menu
- [x] Leaderboard
- [x] Sounds
- [x] Music
- [x] Graphics
- [x] Images
- [x] Level background
- [ ] Effects (particles)
- [x] Bullets
- [ ] Trajectories
- [x] Enemies
- [x] Controls
- [x] Change controls to classic (shift, z, x)
- [ ] Settings
- [ ] Make player hitbox smaller
- [x] Replace resource path strings with constants from db
Binary file modified assets/DataBase.db
Binary file not shown.
Binary file added assets/textures/background/background_0.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 assets/textures/background/background_1.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 assets/textures/background/background_10.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 assets/textures/background/background_11.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 assets/textures/background/background_12.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 assets/textures/background/background_13.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 assets/textures/background/background_14.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 assets/textures/background/background_15.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 assets/textures/background/background_16.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 assets/textures/background/background_17.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 assets/textures/background/background_18.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 assets/textures/background/background_19.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 assets/textures/background/background_2.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 assets/textures/background/background_20.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 assets/textures/background/background_21.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 assets/textures/background/background_22.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 assets/textures/background/background_23.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 assets/textures/background/background_24.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 assets/textures/background/background_25.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 assets/textures/background/background_26.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 assets/textures/background/background_27.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 assets/textures/background/background_28.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 assets/textures/background/background_29.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 assets/textures/background/background_3.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 assets/textures/background/background_30.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 assets/textures/background/background_31.png
Binary file added assets/textures/background/background_32.png
Binary file added assets/textures/background/background_33.png
Binary file added assets/textures/background/background_34.png
Binary file added assets/textures/background/background_35.png
Binary file added assets/textures/background/background_36.png
Binary file added assets/textures/background/background_37.png
Binary file added assets/textures/background/background_38.png
Binary file added assets/textures/background/background_39.png
Binary file added assets/textures/background/background_4.png
Binary file added assets/textures/background/background_40.png
Binary file added assets/textures/background/background_41.png
Binary file added assets/textures/background/background_42.png
Binary file added assets/textures/background/background_43.png
Binary file added assets/textures/background/background_44.png
Binary file added assets/textures/background/background_45.png
Binary file added assets/textures/background/background_46.png
Binary file added assets/textures/background/background_47.png
Binary file added assets/textures/background/background_5.png
Binary file added assets/textures/background/background_6.png
Binary file added assets/textures/background/background_7.png
Binary file added assets/textures/background/background_8.png
Binary file added assets/textures/background/background_9.png
2 changes: 1 addition & 1 deletion danmaku.spec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exe = EXE(
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
Expand Down
47 changes: 47 additions & 0 deletions danmaku/background.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Game level background class declaration."""

import vgame
import pygame


class Background(vgame.graphics.Sprite):
"""Game level background class."""

def __init__(
self,
x: int | float,
y: int | float,
width: int | float,
height: int | float,
):
super().__init__()

self.x = x
self.y = y
self.width = width
self.height = height

# Making it animated
self.last_animation_time = 0
self.current_frame = 0
self.frame_count = 48
self.frame_duration = 100
self.frames = [
f"background/background_{i}.png" for i in range(self.frame_count)
]
self.texture_file = self.frames[0]
self.texture_size = self.width, self.height

def draw(self, graphics: vgame.graphics.Graphics):
graphics.draw_sprite(self)

def animation(self):
"""Animate the sprite."""
t = pygame.time.get_ticks()
if t - self.last_animation_time >= self.frame_duration:
self.texture_file = self.frames[self.current_frame]
self.current_frame = (self.current_frame + 1) % self.frame_count
self.last_animation_time = t

def update(self, delta: int | float):
self.animation()
22 changes: 19 additions & 3 deletions danmaku/bullet.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
"""Entity's bullet declaration."""

import vgame

from danmaku.gameobject import GameObject
from danmaku.database import get_bullet_type


class Bullet(GameObject):
def __init__(self, xy: tuple[int | float, int | float], damage: int | float, type):
args = get_bullet_type(type)
"""Bullet object."""

def __init__(
self, xy: tuple[int | float, int | float], damage: int | float, object_type
):
args = get_bullet_type(object_type)
super().__init__(
xy, (2 * args["radius"], 2 * args["radius"]), args["speed"], 0, damage, 1
)
Expand All @@ -14,7 +22,7 @@ def __init__(self, xy: tuple[int | float, int | float], damage: int | float, typ

self.texture_file = args["texture_file"]
self.texture_size = (2 * self.r, 2 * self.r)
self.my_type = type
self.my_type = object_type

def update(self, delta: int | float):
self.x += self.vx * delta * self.speed
Expand All @@ -25,3 +33,11 @@ def update(self, delta: int | float):
self.width,
self.height,
)

def collision(self, other) -> bool:
# Need to change this because of bombs
# (The bullets that can damage bullets)
return other.collision(self)

def draw(self, graphics: vgame.graphics.Graphics):
graphics.draw_sprite(self)
13 changes: 10 additions & 3 deletions danmaku/button.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
"""Menu button class declaration."""

import pygame
import vgame


class Button(vgame.graphics.Sprite):
"""Menu button class."""

def __init__(
self,
coords: tuple[int | float, int | float],
Expand All @@ -13,6 +17,7 @@ def __init__(
text_color: tuple[int, int, int] = (0, 0, 0),
font_size: int = 24,
):
super().__init__()
self.x, self.y = coords
self.set_rect(pygame.Rect(coords, (width, height)))
self.button_color = button_color
Expand All @@ -26,6 +31,8 @@ def draw(self, graphics: vgame.graphics.Graphics):
)
graphics.text(self.text, (self.x, self.y), self.text_color)

def is_clicked(self, mouse_pos):
if self.rect.collidepoint(mouse_pos):
return True
def is_clicked(self, mouse_pos: tuple[int | float, int | float]) -> bool:
"""Check if button is being clicked."""
return self.rect.collidepoint(mouse_pos)

def update(self, delta: int | float): ...
27 changes: 24 additions & 3 deletions danmaku/database/construct.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from danmaku.database.models import *
"""Construct database with default values.
To be used in development process."""

from danmaku.database.models import db, EnemyTypes, BulletTypes, PlayerTypes


db.connect()

#
# EnemyTypes
#

db.drop_tables([EnemyTypes])
db.create_tables([EnemyTypes])


basic_enemy = EnemyTypes.create(
name="basic enemy",
texture_file="basic_enemy_2.png;basic_enemy_1.png;"
Expand Down Expand Up @@ -51,6 +59,12 @@
)
boss.save()

#
# BulletTypes
#

db.drop_tables([BulletTypes])
db.create_tables([BulletTypes])

basic_enemy_bullet = BulletTypes.create(
name="basic enemy bullet",
Expand All @@ -68,12 +82,19 @@
enemy=False,
texture_file="bullet.png",
radius=10,
speed=150,
speed=300,
vx=0,
vy=-1,
)
basic_player_bullet.save()

#
# PlayerTypes
#

db.drop_tables([PlayerTypes])
db.create_tables([PlayerTypes])

player = PlayerTypes.create(
name="player",
texture_file="player_idle_left.png;player_left_1.png;player_left_2.png;player_left_3.png;"
Expand Down
Loading

0 comments on commit c9198f0

Please sign in to comment.