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

Confusion with blt function #508

Closed
edthedev opened this issue Dec 14, 2023 · 7 comments
Closed

Confusion with blt function #508

edthedev opened this issue Dec 14, 2023 · 7 comments

Comments

@edthedev
Copy link

Context

The blt function was the first thing I tried, and it appeared to fail silently.
Nowhere in the documentation of blt is the need to call load with a resource file specified.
And calling blt without calling load does not result in any warning or error.

@edthedev
Copy link
Author

The existence of #497 is the only thing that tipped me off to the true nature of the issue.

@kitao
Copy link
Owner

kitao commented Dec 16, 2023

I understand the situation you're facing well.
On the other hand, I am still thinking about how to explain it.
The reason is, the blt function is an instruction to 'copy' from the image bank, and it works in any situation and will result in an error if there are invalid arguments.

The reason it seems like nothing is happening is because you are copying a 'black image bank' onto a 'black screen', so the operation is actually being executed.

Moreover, this image bank doesn't require loading to produce images. As shown in example 04, you can create pictures using the set command for definitions, or through various other APIs.

This situation is similar to sound-related commands. The play command can reproduce sound, but in its initial state, no sound is set for each sound, so 'silence' is played. So, should I write that 'to produce sound with sound commands, you need to set which sound to play'? However, I think nobody would find it strange if the sound in their head doesn't play when they use the play command without setting a sound.

Applying the same logic to images, the same principle can be stated. What was the user expecting to be displayed when they used the blt command without setting an image beforehand?

Considering this, it feels like stating that a prior load is necessary is an insufficient explanation, and a different approach or explanation is needed.

@arcade-mntra
Copy link

arcade-mntra commented Dec 16, 2023

This explains why I was getting a black square when using the blt function while testing pyxel on pyxelstudio.net.
I use TIC-80 where the spr(image_num,x,y) is sufficient to display the image from the sprite editor and was doing the same with the blt() in pyxel.

Perhaps in the "How to use" section a small code snippet could be added that demonstrates,
how to load an image/sound from the sprite/sound editor and use it. Currently all three examples in the How to use section show how to draw shapes (rect, circ) but not sprites.

@kitao
Copy link
Owner

kitao commented Dec 28, 2023

I understand the situation! People who come from environments like PICO-8 or TIC-80, where the editor and tools are integrated and only one type of resource can be used, might mistakenly think that the data created with the tool is automatically loaded.

The 'How to Use' section is intended to be as brief as possible, providing working code. It's not suitable for checking samples that prepare and load resource files.

On the other hand, at the beginning of the 'Resource Editor' section, I've already explained how to read resource data using the load function. The question now is how many people might skip this part and not read any of Pyxel's sample code at all, and to what extent we should cater to these individuals. For now, let me keep the current documentation and continue to observe how it is used.

@kitao kitao closed this as completed Dec 28, 2023
@arcade-mntra
Copy link

The 'How to Use' section is intended to be as brief as possible, providing working code. It's not suitable for checking samples that prepare and load resource files.

Fair enough. In the blt() and bltm() section the user can be reminded of the need to load the resource for the functions to work.

I have a follow up on the pyxelstudio.net, it would make sense for the resources to be loaded automatically behind the scenes. This would make it on par with the web versions of PICO-8 or Tic-80 in ease of use for educators to introduce kids to learn python and make simple games.

@merwok
Copy link
Contributor

merwok commented Dec 29, 2023

pyxelstudio is a project separate from pyxel, you should send your suggestion to them! (email address on the website)

@arcade-mntra
Copy link

Hey, thanks for the heads up. I was unaware it was a separate project.

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

No branches or pull requests

4 participants