Author Topic: Sprites 'cutten', wie?  (Read 1751 times)

Tenorm

  • Guest
Sprites 'cutten', wie?
« 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

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1787
    • View Profile
    • Homepage
Re: Sprites 'cutten', wie?
« Reply #1 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 :-)

Tenorm

  • Guest
Re: Sprites 'cutten', wie?
« Reply #2 on: 2009-Apr-04 »
viewport sounds intressting, thank you!

Hab ich im Handbuch ?bersehen, sry!

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5056
  • O Rly?
    • View Profile
Re: Sprites 'cutten', wie?
« Reply #3 on: 2009-Apr-04 »
Jo, Viewport und dann "scrollen" das Ding :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Tenorm

  • Guest
Re: Sprites 'cutten', wie?
« Reply #4 on: 2009-Apr-05 »
Kann man eigendlich auch irgendwie nen Kreis machen => runde Karte...

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1787
    • View Profile
    • Homepage
Re: Sprites 'cutten', wie?
« Reply #5 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 :-)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10739
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Sprites 'cutten', wie?
« Reply #6 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


Tenorm

  • Guest
Re: Sprites 'cutten', wie?
« Reply #7 on: 2009-Apr-06 »
Thank you!  :good: