-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(repo cleaning)sort files to exhibit 2 examples clearly
- Loading branch information
Showing
12 changed files
with
103 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Iterable | ||
|
||
from pyved import component, entity | ||
|
||
|
||
@component | ||
class Position: | ||
x: int | ||
y: int | ||
|
||
|
||
@component | ||
class Speed: | ||
vx: float | ||
vy: float | ||
|
||
|
||
@component | ||
class Health: | ||
max_hp: int | ||
hp: int | ||
|
||
|
||
@component | ||
class Perks: | ||
li_perks: Iterable[str] | ||
|
||
|
||
# --- def entités --- | ||
@entity | ||
class Player(Health, Perks, Position, Speed): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import pygame | ||
|
||
import pyved as pyv | ||
from en_entities import Player | ||
from en_systems import SysInput, SysEntityMover, SysGraphicalRepr | ||
|
||
|
||
# --- | ||
def run_game(): | ||
tester = Player( | ||
x=0, y=256, max_hp=125, hp=None, li_perks=['toughGuy', 'kamikaze'], | ||
vx=0.0, vy=0.0 | ||
) | ||
print(tester) | ||
|
||
pygame.init() # init all imported pygame modules | ||
pygame.display.set_caption('Pong') | ||
screen = pygame.display.set_mode((800, 500)) # w h | ||
clock = pygame.time.Clock() | ||
|
||
entities_mger = pyv.EntityManager() | ||
entities_mger.add( | ||
tester | ||
) | ||
|
||
system_manager = pyv.SystemManager([ | ||
SysInput(entities_mger), | ||
SysEntityMover(entities_mger), | ||
SysGraphicalRepr(entities_mger, screen) | ||
]) | ||
|
||
system_manager.init_all() | ||
|
||
# game_state_info: GameStateInfo = next(entities.get_by_class(GameStateInfo)) | ||
# while game_state_info.play: | ||
# clock.tick_busy_loop(60) # tick_busy_loop точный + ест проц, tick грубый + не ест проц | ||
# system_manager.update_systems() | ||
# pygame.display.flip() # draw changes on screen | ||
|
||
while not system_manager['SysInput'].gameover: | ||
system_manager.proc_all() | ||
pygame.display.flip() | ||
clock.tick_busy_loop(60) | ||
|
||
system_manager.cleanup_all() | ||
print('All Systems stopped') | ||
|
||
|
||
run_game() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.