Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Canonirag_imple #543

Merged
merged 144 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
74abb17
upload new implementations (not integrated)
Jayanaka-98 May 30, 2024
150fba5
Merge pull request #428 from Jaseci-Labs:main
Jayanaka-98 Jun 10, 2024
4f9d0d3
new level generation
Jayanaka-98 Jun 10, 2024
9ba8aff
Merge pull request #449 from Jaseci-Labs:main
Jayanaka-98 Jun 15, 2024
179fd9a
Game working, restart resets the game
Jayanaka-98 Jun 15, 2024
46902ed
chore: Update RPG game level transition logic
Jayanaka-98 Jun 16, 2024
59ca318
Updating the readme about impl6
Jayanaka-98 Jun 17, 2024
cf691a7
renaming file name for better identification
Jayanaka-98 Jun 17, 2024
ebc80d0
Updating RPG journey documentation
Jayanaka-98 Jun 17, 2024
0c1a8f1
Merge pull request #455 from Jaseci-Labs:main
Jayanaka-98 Jun 17, 2024
feda015
Update
Jayanaka-98 Jun 17, 2024
eda210b
Merge pull request #456 from Jaseci-Labs:main
Jayanaka-98 Jun 17, 2024
8792d38
update docstring
Jayanaka-98 Jun 17, 2024
a24aaa3
Merge pull request #470 from Jaseci-Labs:main
Jayanaka-98 Jun 20, 2024
4c2cc5d
Remove semstrings
Jayanaka-98 Jun 27, 2024
9b40a7b
jaclang.core --> mtllm
Jayanaka-98 Jun 27, 2024
41a12f5
docs update
Jayanaka-98 Jun 27, 2024
6c4a364
Update imp 2 towards working state. (init replaced with postinit)
Jayanaka-98 Jul 2, 2024
4fa0927
Merge branch 'main' into RPG-Game-Impl-6
Jayanaka-98 Jul 2, 2024
e620fb1
new approach for symbols
kugesan1105 Jul 14, 2024
372cce3
test updated
kugesan1105 Jul 14, 2024
c0f2017
intial commit with new approach
kugesan1105 Jul 15, 2024
9cc424d
supporting addition, insertion ,deletion on multi level
kugesan1105 Jul 15, 2024
851f957
refactored
kugesan1105 Jul 15, 2024
32a3e04
missing file added
kugesan1105 Jul 15, 2024
6b9dc78
Ultimate Jactastic rpg version
Jayanaka-98 Jul 16, 2024
4016574
Merge pull request #511 from Jaseci-Labs:main
Jayanaka-98 Jul 16, 2024
a9cbcf8
update names and docs
Jayanaka-98 Jul 16, 2024
8cf2565
renamed variables
kugesan1105 Jul 16, 2024
69f4fe9
refactoring 01
kugesan1105 Jul 16, 2024
777582c
modified some logics
kugesan1105 Jul 16, 2024
2377a5a
working properly
kugesan1105 Jul 17, 2024
9b78e1c
tweak: functions extracted and variables renamed
kugesan1105 Jul 17, 2024
aec108e
linting fixed
kugesan1105 Jul 17, 2024
d698401
Merge branch 'main' into refac_01
kugesan1105 Jul 17, 2024
dc442d0
Improve codebase to support testing of update semtokens in change
kugesan1105 Jul 17, 2024
270a2df
test added and refactored
kugesan1105 Jul 17, 2024
3ee9210
refactored test
kugesan1105 Jul 17, 2024
a8194e8
spelling tweak
kugesan1105 Jul 17, 2024
f498cef
modify readability of static_sem_token_attribute
kugesan1105 Jul 17, 2024
ebca616
Going crazy with impl
Jayanaka-98 Jul 18, 2024
2931b5a
Merge branch 'main' into refac_01
marsninja Jul 18, 2024
c9fc9e2
test updated
kugesan1105 Jul 18, 2024
6a862aa
Fix: test issue
kugesan1105 Jul 18, 2024
4f47a57
test fix
kugesan1105 Jul 18, 2024
aa80b42
updated test file
kugesan1105 Jul 18, 2024
0bf499f
refactor: update return statement in Colour1 class
kugesan1105 Jul 19, 2024
a1f7e5a
chore: Remove unnecessary log statement in engine.py
kugesan1105 Jul 19, 2024
c70a81c
Merge branch 'main' into refac_01
marsninja Jul 19, 2024
353fa19
refactor: some tweaks
marsninja Jul 19, 2024
66d390e
Merge pull request #509 from Jaseci-Labs/refac_01
marsninja Jul 19, 2024
af8a324
fix: maybe we go with this
marsninja Jul 19, 2024
3566228
refactor: repo cleaning and print removing
marsninja Jul 21, 2024
5476aad
feat: formmater should handle long expressions tabing in at the operator
marsninja Jul 21, 2024
f574e29
feat: max line length setting added
marsninja Jul 22, 2024
0488409
refactor: Update reserved keyword handling in jaclang compiler
kugesan1105 Jul 22, 2024
9ca51f5
chore: ver bump
marsninja Jul 22, 2024
188b514
refactor: update semantic token management in langserve server.py and…
kugesan1105 Jul 22, 2024
e59812d
Merge branch 'main' into sem_manager_01
kugesan1105 Jul 22, 2024
4099200
refactor: rename sem_manger to sem_manager in engine.py
kugesan1105 Jul 22, 2024
9cfa84c
refactor: Update SemManager to SemTokManager in engine.py and sem_man…
kugesan1105 Jul 22, 2024
d528aed
Merge pull request #450 from Jaseci-Labs/RPG-Game-Impl-6
marsninja Jul 23, 2024
d76cea5
feat: import hints optional
marsninja Jul 23, 2024
801ab53
Fix: updated formater, and long name file
AshishMahendra Jul 23, 2024
2426ad6
refactor: Update reserved keyword handling in jaclang compiler and te…
kugesan1105 Jul 23, 2024
65e4f43
Merge pull request #522 from Jaseci-Labs/sem_manager_01
marsninja Jul 23, 2024
e541304
Merge branch 'main' into format_feat1
marsninja Jul 23, 2024
31e5395
test: keyword esc
marsninja Jul 23, 2024
7f52a70
updated the github workflows
chandralegend Jul 23, 2024
db0afe7
added the function seperation
chandralegend Jul 23, 2024
6de3927
Validation of Sys.Modules names
AshishMahendra Jul 23, 2024
cf6a15f
Reverting deep_imports
AshishMahendra Jul 23, 2024
0a93bed
Update deep_import.jac
AshishMahendra Jul 23, 2024
8fc665b
Update deep_import.jac
AshishMahendra Jul 23, 2024
8448802
Update deep_import.jac
AshishMahendra Jul 23, 2024
2ae1295
updating language_test
AshishMahendra Jul 23, 2024
de7acd1
Merge branch 'sys_mod_fix' of github.com:Jaseci-Labs/jaclang into sys…
AshishMahendra Jul 23, 2024
3504435
removing redundant code
AshishMahendra Jul 23, 2024
fb06894
tweaK
marsninja Jul 23, 2024
2fdb0f3
Merge pull request #518 from Jaseci-Labs/format_feat1
marsninja Jul 23, 2024
2a7ffdb
Merge branch 'main' into sys_mod_fix
marsninja Jul 23, 2024
00b1d97
test: fix
marsninja Jul 23, 2024
f8dce1c
refactor: sensible moves
marsninja Jul 23, 2024
1caa3b0
feat: now auto resolving imports in
marsninja Jul 23, 2024
b52f7aa
feat: new import syntax
marsninja Jul 23, 2024
9f489e8
test: tweak
marsninja Jul 24, 2024
ef6fbde
Merge branch 'main' into streamlit_plugin_update
marsninja Jul 24, 2024
2d72705
tweaks: small stuff
marsninja Jul 24, 2024
a6a9554
refactor: Update reserved keyword handling in jaclang compiler using …
kugesan1105 Jul 24, 2024
13bc1b8
improv: type check update and deep check profiling
marsninja Jul 24, 2024
f80ab64
Merge branch 'main' into conversion_bug_02
marsninja Jul 24, 2024
c0f73cb
hot fix: live for github workflow in github
marsninja Jul 24, 2024
d9dd554
Merge pull request #521 from Jaseci-Labs/conversion_bug_02
marsninja Jul 24, 2024
bd17812
tweak: github flows
marsninja Jul 24, 2024
f51dc21
test: tweak
marsninja Jul 24, 2024
6547ef2
tweak: debug out
marsninja Jul 24, 2024
a83dabd
fix: diagnostics going to impls and tests
marsninja Jul 24, 2024
4ac22b9
errors are better
marsninja Jul 24, 2024
61bb31a
solution works, but wierd errors
marsninja Jul 25, 2024
26dcf77
feat: filename rewrite to support errors
marsninja Jul 25, 2024
9975538
Merge branch 'main' into error_route_upgrade
marsninja Jul 25, 2024
b8c9781
tweak: missing line
marsninja Jul 25, 2024
74a6ba7
better errors
marsninja Jul 25, 2024
2f0a309
Merge branch 'main' into error_route_upgrade
marsninja Jul 25, 2024
c3a92bb
test: added test for stack traces with impls
marsninja Jul 25, 2024
8fb116b
Merge pull request #528 from Jaseci-Labs/error_route_upgrade
marsninja Jul 25, 2024
907fd83
feat: tests now report test
marsninja Jul 25, 2024
6472f8f
cleanup
marsninja Jul 25, 2024
5d3c07a
tweak
marsninja Jul 25, 2024
f153ff2
main merge
AshishMahendra Jul 26, 2024
5331b23
Merge branch 'main' into streamlit_plugin_update
chandralegend Jul 26, 2024
54346ea
reference test fix
AshishMahendra Jul 26, 2024
4786b3b
chore: Update jac_streamlit command entry point added testing AppTest…
chandralegend Jul 26, 2024
ae77eb9
chore: Update jac_streamlit plugin documentation and testing
chandralegend Jul 26, 2024
80528e9
chore: Update jac_streamlit plugin to version 0.0.2 and streamline in…
chandralegend Jul 26, 2024
8c33c27
Update commands.py
chandralegend Jul 26, 2024
bc40fe0
Preventing mypy from type checking all Jac language source code when …
mgtm98 Jul 26, 2024
e4bd495
test: double hello
marsninja Jul 26, 2024
69f5afd
cli_test_fix
AshishMahendra Jul 26, 2024
4ecc9bc
CLI_test fix
AshishMahendra Jul 26, 2024
544497d
name mismatched
AshishMahendra Jul 26, 2024
554a074
cli_name bug fix
AshishMahendra Jul 26, 2024
76829c3
Merge pull request #533 from Jaseci-Labs/cli_test_fix
marsninja Jul 26, 2024
24943c3
Merge branch 'main' into mypy_optimization
marsninja Jul 26, 2024
677c35e
Merge branch 'main' into dbl_hello
AshishMahendra Jul 26, 2024
4df984b
feat: the right typestub strat for jaclang
marsninja Jul 26, 2024
e157054
Merge pull request #530 from Jaseci-Labs/mypy_optimization
marsninja Jul 26, 2024
55b8a70
Merge branch 'main' into sys_mod_fix
marsninja Jul 26, 2024
41396b0
Merge pull request #525 from Jaseci-Labs/sys_mod_fix
marsninja Jul 26, 2024
6f63bbe
Merge branch 'main' into dbl_hello
AshishMahendra Jul 26, 2024
c6c3d31
double import fix
AshishMahendra Jul 26, 2024
913a82b
Merge branch 'main' into streamlit_plugin_update
marsninja Jul 27, 2024
7552449
Merge pull request #524 from Jaseci-Labs/streamlit_plugin_update
marsninja Jul 27, 2024
3852308
Merge branch 'main' into dbl_hello
marsninja Jul 27, 2024
94e9f84
test: more testy test
marsninja Jul 27, 2024
ed54084
tweak
marsninja Jul 27, 2024
f814c0c
module check updated
AshishMahendra Jul 27, 2024
a98cb2e
test: fixed double fail
marsninja Jul 27, 2024
c6b0256
hint: on what to fix to solve streamlit
marsninja Jul 27, 2024
704ceb7
test: mac friendly
marsninja Jul 28, 2024
980a59b
module force-reload added
AshishMahendra Jul 29, 2024
e8e7237
Merge pull request #539 from Jaseci-Labs/mac2_try
marsninja Jul 29, 2024
78a0fe8
Merge branch 'main' into dbl_hello
marsninja Jul 29, 2024
06bf37b
Merge pull request #531 from Jaseci-Labs/dbl_hello
marsninja Jul 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/run_plugin_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Plugin Tests

on:
pull_request:
push:
branches:
- main

jobs:
streamlit:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python 3.12
uses: actions/setup-python@v2
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest

- name: Install Plugin
run: pip install -e support/plugins/streamlit

- name: Run tests
run: pytest support/plugins/streamlit
4 changes: 2 additions & 2 deletions .github/workflows/run_pytest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Tests
name: Tests

on:
pull_request:
Expand All @@ -25,4 +25,4 @@ jobs:
pip install pytest

- name: Run tests
run: pytest -x
run: pytest -x
31 changes: 0 additions & 31 deletions .github/workflows/test_streamlit_plugin.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ repos:
additional_dependencies: [pep8-naming, flake8_import_order, flake8_docstrings, flake8_comprehensions, flake8_bugbear, flake8_annotations, flake8_simplify]
exclude: "examples|vendor|langserve/tests"
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.10.1
hooks:
- id: mypy
exclude: 'venv|__jac_gen__|tests|stubs|support|vendor|examples/reference|setup.py'
exclude: 'venv|__jac_gen__|tests|stubs|support|vendor|examples/reference|setup.py|generated'
args:
- --follow-imports=silent
- --ignore-missing-imports
12 changes: 8 additions & 4 deletions examples/manual_code/circle_pure.impl.jac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Enum for shape types"""

:enum:ShapeType {
CIRCLE="Circle",
UNKNOWN="Unknown"
CIRCLE = "Circle",
UNKNOWN = "Unknown"
}

"""Function to calculate the area of a circle."""
Expand All @@ -23,6 +23,10 @@
}

:can:main_run {
print(f"Area of a circle with radius {RAD} using function: {calculate_area(RAD)}");
print(f"Area of a {c.shape_type.value} with radius {RAD} using class: {c.area()}");
print(
f"Area of a circle with radius {RAD} using function: {calculate_area(RAD)}"
);
print(
f"Area of a {c.shape_type.value} with radius {RAD} using class: {c.area()}"
);
}
3 changes: 2 additions & 1 deletion examples/reference/import_include_statements.jac
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import:py os;
import:py from math, sqrt as square_root;
import:py datetime as dt;
import:jac from base_module_structure, add, subtract;
import:jac from base_module_structure, add;
import from base_module_structure, subtract;

with entry {
for i in range(int(square_root(dt.datetime.now().year))) {
Expand Down
10 changes: 6 additions & 4 deletions examples/rpg_game/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Here there are no significant changes are required for the code structure other

## Less Py more Jac : [jac_impl_2](./jac_impl/jac_impl_2/)

In this iteration of the jac implementation for the RPG, some of the unique features of Jaclang, such as ```has``` variables, were explored. This feature allows for definitions of fields which will self initialize with an auto geneerate ```init```. Furthermore, previously dynamically typed variables has been updated with type annotations.
In this iteration of the jac implementation for the RPG, some of the unique features of Jaclang, such as ```has``` variables, were explored. This feature allows for definitions of fields which will self initialize with an auto generated ```init```. Another change made was that ```init``` functions has been completely removed from the codebase which means only auto generated initialization functions are used using ```has``` variables. However, as there are requirements to run some initialization operations ```postinit``` function is used which will run at the end of the auto generated ```init```. Furthermore, previously dynamically typed variables has been updated with type annotations.

![Jac_1 Vs Jac_2](./Diagrams/Jac_impl_2_comparison.png)

Expand All @@ -28,8 +28,6 @@ This is where we brought out the big guns. Jaclang has a feature where a functio

![Jac_2 Vs Jac3](./Diagrams/Jac_impl_3_comparison.png)

Another change made was that ```init``` functions has been completely removed from the codebase which means only auto generated initialization functions are used using ```has``` variables. However, as there are requirements to run some initialization operations ```postinit``` function is used which will run at the end of the auto generated ```init```.

## Data-Spatial Programming! : [jac_impl_4](./jac_impl/jac_impl_4/)

This implementation is the BOMB! This is the first ever game written in a data-spatial architecture where each level is a node on a graph while the game itself is a walker, traversing on the graph.
Expand All @@ -40,4 +38,8 @@ Without making significant changes to the existing codebase in [jac_impl_3](./ja

## LLM Generating Maps! : [jac_impl_5](./jac_impl/jac_impl_5/)

If the previous version was the BOMB this implementation would be an ICBM. This is a replica of [jac_impl_4](./jac_impl/jac_impl_4/) with an addition AI based map generation feature. This simple game is the world's first game having procedurally generated maps using LLMs based on previous gameplays. This specific implementation requires an OpenAI API key to operate which will generate playable maps using 'gpt-4'.
If the previous version was the BOMB this implementation would be an ICBM. This is a replica of [jac_impl_4](./jac_impl/jac_impl_4/) with an addition AI based map generation feature. This simple game is the world's first game having procedurally generated maps using LLMs based on previous gameplays. This specific implementation requires an OpenAI API key to operate which will generate playable maps using 'gpt-4'. But you can use any model that are [available to use with jac-lang](https://www.jac-lang.org//learn/with_llm/).

## Refined Map Generation! : [jac_impl_6](./jac_impl/jac_impl_6/)

The previous implementation introduced the usage of LLMs to generate each level map. How the LLM implementation is somewhat trivial, and straightforward, which will not be the case of a robust map generator. This is a replica of [jac_impl_5](./jac_impl/jac_impl_5/) with a reimagined version of the map generation feature. In this case we are not generating the entire map, but generated map configurations which allows a symbolic function to generate the map. This new approach is an object-oriented approach which is less prone to generate unplayable maps. Additionally, this version does not utilize any assistance with semstrings, which are optional in mtllm.
15 changes: 8 additions & 7 deletions examples/rpg_game/RPG_DSP_journey.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ This is a tutorial on how to build the same game in Jaclang. Two different imple
- [Data Spatial Implementation](#data-spatial-implementation)
- [Data Spatial architecture](#data-spatial-architecture)
- [Converting RPG into Data-spatial Architecture](#converting-rpg-into-data-spatial-architecture)
- [main.jac](#mainjac)
- [game\_obj.jac](#game_objjac)
- [sprite.jac, config.jac \& map.jac](#spritejac-configjac--mapjac)
- [Runtime Logic of the program : DSP.jac](#runtime-logic-of-the-program--dspjac)
- [Runtime Logic of the program : main\_dsp.jac](#runtime-logic-of-the-program--main_dspjac)
- [Nodes and Walkers](#nodes-and-walkers)
- [Start Screen node](#start-screen-node)
- [Level node](#level-node)
Expand Down Expand Up @@ -399,18 +399,17 @@ The game built in the conventional program can be converted into the data spatia

The fully implemented Data-spatial version can be found at [jac_impl_4](.//jac_impl/jac_impl_4/) if you want to jump in straight.

### main.jac
### game_obj.jac

The only difference in this file is the runtime logic has been removed from here. This is because the main difference in this data-spatial implementation is that the program runtime runs as a graph. Nothing else needs to happen in this file.
This is a direct copy of the main.jac file in previous implementations. The only difference in this file is the runtime logic has been removed from here. This is because the main difference in this data-spatial implementation is that the program runtime runs as a graph. Nothing else needs to happen in this file.

### sprite.jac, config.jac & map.jac

No changes are required on these files as well.

### Runtime Logic of the program : [DSP.jac](.//jac_impl/jac_impl_4/DSP.jac)
### Runtime Logic of the program : [main.jac](.//jac_impl/jac_impl_4/main.jac)

This new file will include the supporting architecture for the build of the data-spatial implementation and the runtime logic for graph traversal.
The imports for this file would be the same as for the main.jac while it will include the main.jac file as well.

```python
import:py pygame;
Expand All @@ -420,7 +419,7 @@ import:py random;
include:jac sprites;
include:jac config;
include:jac map;
include:jac main;
include:jac game_obj;
```

Now the visualization of the graph is really important in order to build the architecture.
Expand Down Expand Up @@ -506,3 +505,5 @@ with entry {
root spawn game();
}
```

<!-- TODO: need to add impl 5 and 6 -->
2 changes: 1 addition & 1 deletion examples/rpg_game/jac_impl/jac_impl_2/main.jac
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ obj Game {
intro_background: pygame.surface.Surface = pygame.image.load('../img/introbackground.png'),
go_background: pygame.surface.Surface = pygame.image.load('../img/gameover.png');

can init() {
can postinit() {
pygame.<>init();
self.font = pygame.font.Font(GENERAL_FONT, 32);
}
Expand Down
94 changes: 52 additions & 42 deletions examples/rpg_game/jac_impl/jac_impl_2/sprites.jac
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@ obj Spritesheet {
Object for the player with type pygame.sprite.Sprite
"""
obj Player :pygame.sprite.Sprite: {
has game: Game,
x: int,
y: int;
has _layer: int = PLAYER_LAYER,
width: int = TILESIZE,
height: int = TILESIZE,
x_change: int = 0,
y_change: int = 0,
facing: str = 'down',
animation_loop: int = 1;
animation_loop: float = 1;

can init(game: None, x: int, y: int) {
self.game = game;
can postinit() {
self._layer = PLAYER_LAYER;
self.groups = self.game.all_sprites;
pygame.sprite.Sprite.init(self, self.groups);
self.x = x * TILESIZE;
self.y = y * TILESIZE;
self._groups = self.game.all_sprites;
pygame.sprite.Sprite.init(self, self._groups);
self.x*=TILESIZE;
self.y*=TILESIZE;
self.image = self.game.character_spritesheet.get_sprite(3, 2, self.width, self.height);
self.rect = self.image.get_rect();
self.rect.x = self.x;
Expand Down Expand Up @@ -201,20 +203,22 @@ obj Player :pygame.sprite.Sprite: {
Object for enemies with type pygame.sprite.Sprite
"""
obj Enemy :pygame.sprite.Sprite: {
has game: Game,
x: int,
y: int;
has _layer: int = ENEMY_LAYER,
width: inr = TILESIZE,
height: int = TILESIZE,
x_change: int = 0,
y_change: int = 0,
animation_loop: int = 0,
animation_loop: float = 0,
movement_loop: int = 0;

can init(game: None, x: int, y: int) {
self.game = game;
self.groups = (self.game.all_sprites, self.game.enemies);
pygame.sprite.Sprite.__init__(self, self.groups);
self.x = x * TILESIZE;
self.y = y * TILESIZE;
can postinit() {
self._groups = (self.game.all_sprites, self.game.enemies);
pygame.sprite.Sprite.__init__(self, self._groups);
self.x*=TILESIZE;
self.y*=TILESIZE;
self.image = self.game.enemy_spritesheet.get_sprite(3, 2, self.width, self.height);
self.facing = random.choice(['up', 'down', 'left', 'right']);
self.max_travel = random.randint(7, 30);
Expand Down Expand Up @@ -334,16 +338,18 @@ obj Enemy :pygame.sprite.Sprite: {
Object for blocks (Walls) with type pygame.sprite.Sprite
"""
obj Block :pygame.sprite.Sprite: {
has game: Game,
x: int,
y: int;
has _layer: int = BLOCK_LAYER,
width: int = TILESIZE,
height: int = TILESIZE;

can init(game: None, x: int, y: int) {
self.game = game;
self.groups = (self.game.all_sprites, self.game.blocks);
pygame.sprite.Sprite.init(self, self.groups);
self.x = x * TILESIZE;
self.y = y * TILESIZE;
can postinit() {
self._groups = (self.game.all_sprites, self.game.blocks);
pygame.sprite.Sprite.init(self, self._groups);
self.x*=TILESIZE;
self.y*=TILESIZE;
self.image = self.game.terrain_spritesheet.get_sprite(960, 448, self.width, self.height);
self.rect = self.image.get_rect();
self.rect.x = self.x;
Expand All @@ -355,16 +361,18 @@ obj Block :pygame.sprite.Sprite: {
Object for ground with type pygame.sprite.Sprite
"""
obj Ground :pygame.sprite.Sprite: {
has game: Game,
x: int,
y: int;
has _layer: int = GROUND_LAYER,
width: int = TILESIZE,
height: int = TILESIZE;

can init(game: None, x: int, y: int) {
self.game = game;
self.groups = self.game.all_sprites;
pygame.sprite.Sprite.init(self, self.groups);
self.x = x * TILESIZE;
self.y = y * TILESIZE;
can postinit() {
self._groups = self.game.all_sprites;
pygame.sprite.Sprite.init(self, self._groups);
self.x*=TILESIZE;
self.y*=TILESIZE;
self.image = self.game.terrain_spritesheet.get_sprite(64, 352, self.width, self.height);
self.rect = self.image.get_rect();
self.rect.x = self.x;
Expand All @@ -376,15 +384,17 @@ obj Ground :pygame.sprite.Sprite: {
Object class for buttons used in the game (Start, Restart)
"""
obj Button {
can init(x: int, y: int, width: int, height: int, fg: tuple, bg: tuple, content: str, fontsize: int) {
self.font = pygame.font.Font(GENERAL_FONT, fontsize);
self.content = content;
self.x = x;
self.y = y;
self.width = width;
self.height = height;
self.fg = fg;
self.bg = bg;
has x: int,
y: int,
width: int,
height: int,
fg: tuple,
bg: tuple,
content: str,
fontsize: int;

can postinit() {
self.font = pygame.font.Font(GENERAL_FONT, self.fontsize);
self.image = pygame.Surface((self.width, self.height));
self.image.fill(self.bg);
self.rect = self.image.get_rect();
Expand All @@ -411,17 +421,17 @@ obj Button {
Object class for attacks by the player
"""
obj Attack :pygame.sprite.Sprite: {
has game: Game,
x: int,
y: int;
has _layer: int = ATTACK_LAYER,
width: int = TILESIZE,
height: int = TILESIZE,
animation_loop: int = 0;
animation_loop: float = 0;

can init(game: None, x: int, y: int) {
self.game = game;
self.groups = (self.game.all_sprites, self.game.attacks);
pygame.sprite.Sprite.init(self, self.groups);
self.x = x;
self.y = y;
can postinit() {
self._groups = (self.game.all_sprites, self.game.attacks);
pygame.sprite.Sprite.init(self, self._groups);
self.image = self.game.attack_spritesheet.get_sprite(0, 0, self.width, self.height);
self.rect = self.image.get_rect();
self.rect.x = self.x;
Expand Down
Loading
Loading