A bit confused with blitting (Pygame)

前端 未结 3 1588
栀梦
栀梦 2020-12-29 03:47

I\'ve just started learning some pygame (quite new to programming overall), and I have some very basic questions about how it works.

I haven\'t found a place yet th

3条回答
  •  情话喂你
    2020-12-29 04:33

    Imagine that you are a painter:

    You have a canvas, and a brush.

    Let's say that your main screen surface will be your canvas, and all the other surfaces, are "in your head" - you know how to draw them already.

    When you call blit, you paint on top of the surface, covering any pixels that were overlapped. That is why you need to repaint the whole screen black so that you won't have any smudges on the painting while moving an object.

    As Mark already said, you can draw a circle with a function, or first blit it to a new surface, and blit that on the screen surface.

    If you have a more complicated surface - curves, text etc. you wouldn't need to have a surface for that, so you don't have to do any expensive calculations, just drawing. The setback is that your program takes up more memory, so you have to choose between those 2.

提交回复
热议问题