Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Transparent Sprites on the CMM2
Author | Message | ||||
daveculp Newbie Joined: 02/07/2020 Location: United StatesPosts: 22 |
Im at my wits end with transparent sprites, looking for some help. Im getting back to CMM2 programming and decided to try making a simple game. Ive got a starfield which is just three arrays holding X,Y and color data for three levels of a parallax style star field. I have a player sprite which is just a spaceship cut from a sprite from the free sprite_lib library https://www.widgetworx.com/spritelib/. I set mode 1 at the start and go. I draw small circles where the "stars" are and then draw the sprite, all on page 2 then I do a page copy to page 0. Everything works great except I cannot for the life of me get transparent pixels on the sprite. I'm not looking for semi-transparency, just a standard sprite in which certain pixels are transparent and let things in the background show through. I have saved as a PNG with both transparency data and with the transparent pixels set to 0,0,0 RGB. I use SPRITE LOADPNG to the load it and it never works, even tried out different graphics modes. I use GIMP to edit the sprite. I THINK the problem may lie in the format GIMP uses to save the image data. Any tips? |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8516 |
Are you in a 12-bit colour mode? Transparency only works in 12-bit colour with page 0 and page 1 used for the two layers. Check the manual for more details Edited 2022-01-27 01:44 by matherp |
||||
daveculp Newbie Joined: 02/07/2020 Location: United StatesPosts: 22 |
I did try 12 bit color depth and got the same results. I did read the manual and the manual on graphics programming. I was under the impression that 12 bit depth transparency was mostly for making semi-transparent objects like in the ghost demo but every mode could support sprite transparency in which RGB(0,0,0) was not drawn, meaning it would be "transparent". |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1081 |
Can you try to just LOAD PNG on a convenient page, then SPRITE READ to 'sprite-ify' the rectangle of interest? Visit Vegipete's *Mite Library for cool programs. |
||||
daveculp Newbie Joined: 02/07/2020 Location: United StatesPosts: 22 |
I will give that a try tonight! |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5643 |
RGB(0,0,0) is always black. If you use that for a sprite it's on an opaque black background. You need a PNG with "chequerboard" background, indicating that it's transparent. That's in ARGB4444. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
daveculp Newbie Joined: 02/07/2020 Location: United StatesPosts: 22 |
I will see if GIMP will save in ARGB4444 format. Page 37 of the graphics programing document stated that the ideal format was ARGB8888 so I was using that. Edited 2022-01-27 04:57 by daveculp |
||||
Mixtel90 Guru Joined: 05/10/2019 Location: United KingdomPosts: 5643 |
As far as I was concerned that was the "hard" book. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
daveculp Newbie Joined: 02/07/2020 Location: United StatesPosts: 22 |
I got simple Sprite transparency working on all color depths using a PNG in ARGB8888 format by using SPRITE WRITE instead of SPRITE SHOW. |
||||
Print this page |