## News:

*NEW* Current Version on STEAM16.793

Webchat:
Visit the chat

## RotoSprite 3D

#### Kitty Hello

Hier mal eine Funktion, die ein Sprite um 3 Achsen dreht, wobei ich auf X/Z und Y/Z begrenzen würde:

Code (glbasic) Select
`FILLRECT 0,0,31,16,RGB(255,0,0)FILLRECT 8,0,24,31,RGB(255,128,0)GRABSPRITE 0,0,0,32,32FILLRECT 0,0,31,16,RGB(64,64,64)FILLRECT 8,0,24,31,RGB(64,64,64)FILLRECT 12,0,20,31,RGB(99,99,99)GRABSPRITE 1,0,0,32,32WHILE TRUE MOUSESTATE mx, my, b1,b2 phi = GETTIMERALL()/100 PukeSprite(0,1, my*2, mx*2, phi, 100, 100) PRINT mx + " - " + my + " - "+phi, 0,0 SHOWSCREENWEND// rotate a sprite in a terrible way// img1 - upper side// img2 - bottom side (same orientation)// rotX - rotation angle around x axis (right side)// rotY - rotation around up-down axis on screen// rotZ - rotation like ROTOSPRITEFUNCTION PukeSprite: img1, img2, rotX, rotY, rotZ, x,yLOCAL w, h, phi, swap, tx, tyLOCAL s, c, cl, px, py GETSPRITESIZE img1, w,h tx=w ty=h phi = MOD(ABS(rotY), 360) IF phi < 90 OR phi>270 swap = img1 img1=img2 img2=swap ENDIF w = w * COS(phi) phi = MOD(ABS(rotX), 360) IF phi < 90 OR phi>270 swap = img1 img1=img2 img2=swap ENDIF h = h * COS(phi) s=SIN(rotZ) c=COS(rotZ) w=w/2 h=h/2 cl=RGB(255,255,255) STARTPOLY img1 px=-w; py=-h; POLYVECTOR x+px*c+py*s, y-px*s+py*c,  0, 0,cl px=-w; py= h; POLYVECTOR x+px*c+py*s, y-px*s+py*c,  0,ty,cl px= w; py= h; POLYVECTOR x+px*c+py*s, y-px*s+py*c, tx,ty,cl px= w; py=-h; POLYVECTOR x+px*c+py*s, y-px*s+py*c, tx, 0,cl // and back for back face culling px= w; py= h; POLYVECTOR x+px*c+py*s, y-px*s+py*c, tx,ty,cl px=-w; py= h; POLYVECTOR x+px*c+py*s, y-px*s+py*c,  0,ty,cl px=-w; py=-h; POLYVECTOR x+px*c+py*s, y-px*s+py*c,  0, 0,cl ENDPOLYENDFUNCTION`