GLBasic forum

Other languages => GLBasic - de => Topic started by: Tenorm on 2009-Apr-04

Title: Sprites 'cutten', wie?
Post by: Tenorm on 2009-Apr-04
Hi,

wie kann ich nur einen bestimmten Bereich eines Sprites zeichnen, z.B. von einem 128x128 Pixel Sprite nur ein Quadrat von 32x32, dessen Position aber variirt. Soll ne Minikarte werden ;)

Danke schon mal

Tenorm
Title: Re: Sprites 'cutten', wie?
Post by: Moru on 2009-Apr-04
Look in the manual for LOADANIM, that might be what you want. Unless you want to show a 32x32 piece of a big picture? In that case look for VIEWPORT instead :-)
Title: Re: Sprites 'cutten', wie?
Post by: Tenorm on 2009-Apr-04
viewport sounds intressting, thank you!

Hab ich im Handbuch ?bersehen, sry!
Title: Re: Sprites 'cutten', wie?
Post by: Schranz0r on 2009-Apr-04
Jo, Viewport und dann "scrollen" das Ding :)
Title: Re: Sprites 'cutten', wie?
Post by: Tenorm on 2009-Apr-05
Kann man eigendlich auch irgendwie nen Kreis machen => runde Karte...
Title: Re: Sprites 'cutten', wie?
Post by: Moru on 2009-Apr-05
First way:
Set up the VIEWPORT, draw the map, then draw another sprite over that has a round hole in the middle that is transparent, then you have a circle-map.

Second way
do a CREATESCREEN, draw your map on this and mask out the edges so you get a round disc like above and then you draw this screen like a sprite on your gamescreen.

Just ideas how to do it, no direct solution, sorry :-)
Title: Re: Sprites 'cutten', wie?
Post by: Kitty Hello on 2009-Apr-06
I used the 2nd way in the PuzzleBox remake, when I fade in/out the screen.
But instead of a sprite, I used a POLYVECTOR function that clears the screen:

Code (glbasic) Select



WHILE TRUE
MOUSESTATE mx, my, b1, b2


MarioOut(mx / 800)
SHOWSCREEN



WEND


// -------------------------------- //
// Mario-Stlye fadeout
// -------------------------------- //
FUNCTION MarioOut: delta
LOCAL i, r, st, p, x, y, c
LOCAL windowx%, windowy%
GETSCREENSIZE windowx, windowy
i = windowx/2
x = windowx/2
y = windowy/2
x = SQR(x*x + y*y)

c=RGB(255,255,255)
st=6
r = MAX(0, delta * windowx - 16)

// top right
STARTPOLY -1
POLYVECTOR windowx,0,0,0,c
POLYVECTOR windowx/2,0, 0,0,c
FOR i=0 TO 90 STEP st
POLYVECTOR windowx/2+r*SIN(i),windowy/2-r*COS(i),0,0,c
NEXT
POLYVECTOR windowx,windowy/2,0,0,c
ENDPOLY

// bottom right
STARTPOLY -1
POLYVECTOR windowx,windowy,0,0,c
POLYVECTOR windowx,windowy/2, 0,0,c
FOR i=90 TO 180 STEP st
POLYVECTOR windowx/2+r*SIN(i),windowy/2-r*COS(i),0,0,c
NEXT
POLYVECTOR windowx/2,windowy,0,0,c
ENDPOLY

// bottom left
STARTPOLY -1
POLYVECTOR 0,windowy,0,0,c
POLYVECTOR windowx/2,windowy, 0,0,c
FOR i=180 TO 270 STEP st
POLYVECTOR windowx/2+r*SIN(i),windowy/2-r*COS(i),0,0,c
NEXT
POLYVECTOR 0,windowy/2,0,0,c
ENDPOLY

// top left
STARTPOLY -1
POLYVECTOR 0,0,0,0,c
POLYVECTOR 0,windowy/2+1, 0,0,c
FOR i=270 TO 360 STEP st
POLYVECTOR windowx/2+r*SIN(i)+1,windowy/2-r*COS(i),0,0,c
NEXT
POLYVECTOR windowx/2,0,0,0,c
ENDPOLY
ENDFUNCTION

Title: Re: Sprites 'cutten', wie?
Post by: Tenorm on 2009-Apr-06
Thank you!  :good: