Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/image blit #28

Closed
wants to merge 2 commits into from
Closed

Conversation

will8211
Copy link

Hi! I'm working on "Roguelike Tutorial, using python3+tdl" on roguebasin. It's based on Jotaf's "Complete Roguelike Tutorial, using python+libtcod".

http://www.roguebasin.com/index.php?title=Roguelike_Tutorial,_using_python3%2Btdl

For part 10, there's a call to tcod's image_blit_2x.

In this fork, I've added an image_blit method to _BaseConsole. It takes the name of an image as a string and x/y coordinates for the placement of the upper left corner. It converts the image to a TCOD image and passes the variables to TCOD_image_blit_2x or TCOD_image_blit_rect depending on a flag called "subcell_res". In the future, it could also be used to allow image scaling and through TCOD_image_blit.

It would be great if you would be willing to add this the master branch. I can provide the project I used for testing on request.

Thanks!
Will

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 72.823% when pulling 6404363 on will8211:feature/image_blit into f81e127 on HexDecimal:master.

2 similar comments
@coveralls
Copy link

coveralls commented May 28, 2017

Coverage Status

Coverage decreased (-0.3%) to 72.823% when pulling 6404363 on will8211:feature/image_blit into f81e127 on HexDecimal:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 72.823% when pulling 6404363 on will8211:feature/image_blit into f81e127 on HexDecimal:master.

@HexDecimal
Copy link
Collaborator

The tdl_image variable points to C data not managed by the Python garbage collector. Not manually freeing it will cause a memory leak.

I expect a method like this to be called rather frequently, but the way it's set up is I/O bound, this could cause a lot of lag per call.

The tcod_console attribute is exclusive to the tdl.Console class. This method will break when called on a Window instance. It's easy to fix but I'm not sure that I'll keep supporting the Window class in the future.

I'm going to work on porting libtcod-cffi's tcod.image.Image class to work with the tdl.Console class. It will be easy for me to setup, but it won't be able to blit to Window objects. Will that be okay?

@will8211
Copy link
Author

will8211 commented May 29, 2017 via email

@HexDecimal
Copy link
Collaborator

I've released a new version of tdl. I haven't tested this specific code yet. The feature you asked for will look something like this:

tcod.image_load(filename).blit_2x(tdl_console, dest_x, dest_y)

@HexDecimal HexDecimal closed this May 29, 2017
@will8211
Copy link
Author

will8211 commented May 29, 2017 via email

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.

None yet

3 participants