Skip to content

Tint rendered lights with light_color - #35

Merged
Osman-Kahraman merged 2 commits into
Osman-Kahraman:mainfrom
resolvicomai:fix/light-color-tint
May 21, 2026
Merged

Tint rendered lights with light_color#35
Osman-Kahraman merged 2 commits into
Osman-Kahraman:mainfrom
resolvicomai:fix/light-color-tint

Conversation

@resolvicomai

Copy link
Copy Markdown
Contributor

Summary

  • Add a light_color argument to Light with the current white behavior as the default.
  • Apply the configured color tint before masking the light texture during rendering.
  • Add a headless Pygame regression test for colored light rendering.

Fixes #33.

Validation

  • PYTHONPATH=. uv run --no-project --with pytest --with pygame==2.6.1 pytest -q tests/test_light.py
  • PYTHONPATH=. uv run --no-project --with ruff ruff check game_engine/core/light.py tests/test_light.py
  • python3 -m py_compile game_engine/core/light.py tests/test_light.py
  • git diff --check

@Osman-Kahraman

Copy link
Copy Markdown
Owner

Thank you for your contribution, but unfortunately it wasn't working your fix in my local machine. I tried this steps to tested it;

  1. Create a Light instance
  2. Set a custom light color (example: red, blue, green)
  3. Render the light onto the scene
  4. Observe the resulting light color

Can you try to fix it or give me proper way to test your changes in this pull request. Thanks...

@resolvicomai

@resolvicomai

resolvicomai commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for testing it. I found the missing path: the first patch tinted direct Light(size, light_color=...) usage, but item lights created from items/info.json were still instantiating Light without passing the configured lights.RGB value.

I pushed commit 125693e to pass lights.RGB into the item light system and to keep an existing light system in sync with that value. I also added a regression test covering the Temp.decorate() path using a sample lights RGB config.

Validation run locally:

  • .venv/bin/python -m pytest -q tests/test_light.py -> 2 passed
  • .venv/bin/python -m compileall -q game_engine tests
  • git diff --check

For manual verification, use an item entry with lights coords/size/RGB, for example RGB [255, 0, 0]. The rendered item light should now use that red tint instead of staying white.

@Osman-Kahraman

Copy link
Copy Markdown
Owner

Thanks for the changes. I've tested and it works perfectly.

@Osman-Kahraman Osman-Kahraman left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Comment thread tests/test_light.py
return surface


def test_render_tints_light_with_light_color(monkeypatch):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good for testing case, I appreciate it...

@Osman-Kahraman
Osman-Kahraman merged commit b675b48 into Osman-Kahraman:main May 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: light_color value does not affect rendered light color

2 participants