|
Forum Index : Microcontroller and PC projects : MMBasic Sprite Z-Order
| Author | Message | ||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 568 |
In the SPRITE show command, what good is the layer parameter? No matter what number I put there, the sprites are shown in the reverse order I put them in the buffer with the show statements. The first shown is always at the back, the second is in the middle and the last one shown is always on top. The layer parameter seems to do nothing. FRAMEBUFFER layer FRAMEBUFFER write "L" SPRITE load "balloon.spr" FOR x=0 TO 280 SPRITE show safe 3,x-15,130,1 SPRITE show safe 2,x,280-x,2 SPRITE show safe 1,x,x,3 FRAMEBUFFER copy L,N NEXT x still shows the cyan sprite (#1) on top, the magenta sprite (#2) in the middle and the yellow sprite (#3) at the back, behind the other two. I tried changing the layer numbers around but there was no change in the display of the sprites. |
||||
| Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1421 |
The layer is just one plane that lies above the normal screen. We don't have an infinite number of them here, as that would require infinite Memory. as I have already explained to you in detail here Since we don't have a Z-buffer, we have to monitor/determine the order of the images ourselves using sprites. To do this, you must assign a Z value in addition to the x and y values of a sprite. This has nothing to do with the sprite or the ‘sprite’ command, but determines the order in which the sprites are drawn for your programme. So you have to make sure yourself that the sprites are drawn in order from far away to very close. Example: For Z=-25 To 25 For n=1 To 20 If Int(Z1(n))=Z Then Sprite write 1,x1(n) , y1(n) EndIf Next n Next Z see this Demo 'no comment |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |