Qbasicnews.com

Full Version: general game graphics
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
okay, thanks na_th_an. i think i'll copy the part they'll move over, then put it back later. i'm using get and put. now i have to figure out whether to use AND, OR, XOR, PSET, etc, when putting them on the screen. i think i'll manage that mayself, if not, i'll come back here whining again. thanks for the help.
okay- i have another problem.

i'm using sprites that i made in PP256, but when i load them, it loads the black area around the sprite, so they destroy the background when they move around. i'm trying to get just the area that's not black to load.

also, when i run this, it is now giving me a subscript out of range, hilighting the redim array(memsize) line in the loadput sub



Code:
' ///Sub Declarations\\\
DECLARE SUB LoadPUT (File$, array%())
DECLARE SUB init ()


DEFINT A-Z     'what is this?

'$DYNAMIC                 'some variables!
DIM squid(0)
DIM SHARED BG1(0)
DIM SHARED BG2(0)
DIM SHARED xcoor(9)
DIM SHARED ycoor(9)
DIM SHARED bmap(9, 9)
DIM SHARED grx, gry



SCREEN 13


LoadPUT "SQUID.put", squid()
LoadPUT "BG1.put", BG1()
LoadPUT "BG2.put", BG2()

CLS
CALL init

xpos = 1
ypos = 1
grx = 1
gry = 1


DO

PUT (xpos, ypos), squid, PRESET
inky = VAL(INKEY$)


IF inky = 6 THEN
IF xpos <= 257 THEN xpos = xpos + 32: grx = grx + 1
END IF
IF inky = 4 THEN
IF xpos >= 33 THEN xpos = xpos - 32: grx = grx - 1
END IF
IF inky = 8 THEN
IF ypos >= 21 THEN ypos = ypos - 20: gry = gry - 1
END IF
IF inky = 2 THEN
  IF ypos < 181 THEN ypos = ypos + 20: gry = gry + 1
END IF


'put code here later for redrawing the background.
'right now, the picture isn't even erased. not my main worry right
'now though. the program won't even run, i wonder what i
'deleted.



LOOP UNTIL inky = 5




DATA 1,1,1,1,1,2,1,1,1,1
DATA 1,1,2,1,1,1,1,1,2,1
DATA 1,1,1,2,1,2,1,1,1,1
DATA 1,2,1,1,2,1,1,1,1,1
DATA 1,1,2,1,1,1,1,2,1,1
DATA 1,1,1,1,1,2,1,1,1,1
DATA 1,2,1,2,1,1,2,1,1,1
DATA 1,1,1,1,2,1,1,1,1,1
DATA 1,1,2,1,1,1,1,1,1,2
DATA 1,1,2,1,2,2,1,1,1,1

END
'SYSTEM

REM $STATIC
SUB init

xcoor(0) = 1
xcoor(1) = 33
xcoor(2) = 65
xcoor(3) = 97
xcoor(4) = 129
xcoor(5) = 161
xcoor(6) = 193
xcoor(7) = 225
xcoor(8) = 257
xcoor(9) = 289

ycoor(0) = 1
ycoor(1) = 21
ycoor(2) = 41
ycoor(3) = 61
ycoor(4) = 81
ycoor(5) = 101
ycoor(6) = 121
ycoor(7) = 141
ycoor(8) = 161
ycoor(9) = 181




FOR y = 0 TO 9
FOR x = 0 TO 9
READ bmap(x, y)
NEXT x
NEXT y


FOR y = 0 TO 9
FOR x = 0 TO 9
IF bmap(x, y) = 1 THEN
PUT (xcoor(x), ycoor(y)), BG1
END IF
IF bmap(x, y) = 2 THEN
PUT (xcoor(x), ycoor(y)), BG2
END IF
NEXT x
NEXT y


END SUB

SUB LoadPUT (File$, array())

f = FREEFILE
OPEN File$ FOR BINARY AS #1
memsize = (LOF(1) - 7) / 2 - 1
CLOSE #1


REDIM array(memsize)

DEF SEG = VARSEG(array(0))
BLOAD File$, VARPTR(array(0))

END SUB

also- what does DEFINT A-Z mean? maybe that's causing my problem, but i don't know what it even is.

thanks for the help.
The backgound has to be put using PSET.

For transparent sprites you need masks. For each sprite, you need another sprite called "mask" that tells which pixels are transparent and which not (basicly, not exactly but you'll understand it better if you think of it this way).

In a mask for SCREEN 7, a white (colour 15, FFh) pixel means "transparent" and a black (colour 0, 00h) pixel means "solid". In a sprite, transparent sections must be black (colour 0, 00h). Imagine you need a 8x8 pixels ball:

This is the sprite

Code:
00 00 14 14 14 14 00 00
00 14 10 10 10 10 14 00
14 10 10 10 10 10 10 14
14 10 10 10 10 10 10 14
14 10 10 10 10 10 10 14
14 10 10 10 10 10 10 14
00 14 10 10 10 10 14 00
00 00 14 14 14 14 00 00

And this is the mask

Code:
15 15 00 00 00 00 15 15
15 00 00 00 00 00 00 15
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
15 00 00 00 00 00 00 15
15 15 00 00 00 00 15 15

Imagine that you have two arrays, sprite%() and mask%() with those info already GET'd. To blit transparently you have to do two PUTs:

Code:
PUT (x%, y%), mask%(), AND
PUT (x%, y%), mask%(), XOR

Basicly, the first one makes a black circular hole and the second one draws the ball in the hole.

Just remember this:

Transparent pixel = 15 in the mask, 0 in the sprite.
Solid pixel = 0 in the mask, any colour (including 0) in the sprite.
thanks, that would work great- except that i've been using PP256 to make my sprites. maybe there's a way to convert .PUT's to data statements so i can do what you said?

looks like we both posted at the exact same time there.

edit: okay, i've looked. you can save the images from pp256 directly to data statements, so all i have to do make the mask by hand.
PP256 outputs sprites for mode 13h. You have to find the way to draw the sprites and convert it for the SCREEN 7 format. What I did back in time was loading them in screen (I never used sprite editors but Deluxe Paint that wrote to PCX files) and GETting them into arrays.
lol, we posted together again. thanks for the information. i think i can make a mask by myself. i really appreciate all of the help.
Pages: 1 2 3