Qbasicnews.com

Full Version: Sprite masking
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm making a new megaman game, almost like rockman the power battle if you ever heard of it. Its going to be a two player fighting game with different megaman/megaman x characters. Usually when I make a game i use my own sprites with DATA 0,0,0,0 , but this time i'm using sprites loaded in qbasic with a .gif loader. I want to know how to make a mask for them if i have a sprite stored with get. I have some idea, like:

IF COLOROFIMAGEPIXEL =GREEN THEN COLOROFMASKPIXEL =255

where GREEN is the background color around the sprite. i want to change that color GREEN into a transparent 255 (In screen 13) and then GET it. If i knew how to access the individual pixels in the sprite and change them, it would be a lot of help. Maybe with DEF SEG?
Here's a picture, I blew it up a little for clarity.

[Image: megaman.jpg]
Picture doesn't show Sad

I suggest you to use a lib and you have transparency in colour 0 with no need for masks.

Anyhow, if you want to go for the hard path, I'd suggest you to write a small app who loads and paints the GIF on screen. You GET the sprites into an array. You BSAVE that array. Then you use the screen with POINT and PSET to change green for 255 and the rest for 0, then GET the masks into another array and BSAVE it.

In your game, just BLOAD the two files into two arrays et voie la.
I have never heard of point before. I looked it up in help and I think its exactly what I need. Hows this?

BCKGRND=8

for x=1 to 10
for y=1 to 10
MASK(x,y)=-255*(POINT(x,y)=BCKGRND) 'returns 255 or 0
next y
next x

this way i don't need BLOAD. Also, i'm not worried about speed because this program is going to be used only to set up my .bin pictures and my .bin masks.

Thanks!
I've never seen it done that way, but that works
Quote:Picture doesn't show Sad

copy and paste the url into the adddress bar (stupid no hotlinking)
Quote:I have never heard of point before. I looked it up in help and I think its exactly what I need. Hows this?

BCKGRND=8

for x=1 to 10
for y=1 to 10
MASK(x,y)=-255*(POINT(x,y)=BCKGRND) 'returns 255 or 0
next y
next x

this way i don't need BLOAD. Also, i'm not worried about speed because this program is going to be used only to set up my .bin pictures and my .bin masks.

Thanks!

I told you the bload stuff 'cause it will be the same as your .bin stuff but faster Smile
Thats alright, i'm really not worried about speed. The pictures are all around 20x20 so its instant anyway. Also using binary files is easier for me than bload; i end up making errors with bload. But the game code itself will be optimized even though my computer is a 2.2ghz. I try not to use IF or CASE statements in my real programs, and my code example above with 2 dimentional arrays would be turned into a big one dimentional array split into two parts.

My main problem now is loading almost 50 frames for the animation of each character. I only have one working so far, and that's without the other fifty mask frames. Very tedious. Speed won't be a problem because the game will run on a clock, not processing power.

Also, does anyone have any suggestions for which megaman (x)characters i should put in the game? I only have megaman with his rush suit now. I want to have at least two or three before I post the game on my new site (which also isn't finished).
Zero. :*)

nd loose the his panties!!!