Page 1 of 1

One more command for Sprites

Posted: Sat Jul 30, 2005 3:49 pm
by va!n
I have requested this, very long ago... what do you think about something like:

HandleSprite(SpriteID,X,Y)
MidHandleSprite(SpriteID)

So your sprites are not ever handled at 0,0 !! Changing the Handle would be nice for some stuff like rotating around the centre (MidHandle) of a Sprite or Image!

Posted: Sun Jul 31, 2005 5:33 am
by Fou-Lu
I don't think it's absolutely necessary, but it would be good. I've already seen that in darkbasic, it was called spriteoffset. When you say SpriteID, you mean the number of the sprite, right?

Posted: Sun Jul 31, 2005 12:56 pm
by va!n
Fou-Lu wrote:I don't think it's absolutely necessary, but it would be good. I've already seen that in darkbasic, it was called spriteoffset. When you say SpriteID, you mean the number of the sprite, right?

yes, SpriteID should be SpriteNumber ;)
I think a command like this would be very usefull, even if you have a sprite object with a size of 80x80 for example and want rotate it around position 40,40 instead at 0,0! :wink:

Posted: Sun Jul 31, 2005 6:29 pm
by Blade
RotateSprite3D() rotates on the center of the sprite, not 0,0.

I want the Handle feature would be nice too :)

Posted: Sun Jul 31, 2005 7:13 pm
by Fou-Lu
TransformSprite3D() can change the handle of a sprite3D.You could create a procedure to rotate a sprite3D in the middle:

Code: Select all

initsprite()
initsprite3d()
initmouse()

openscreen(640,480,32,"")

Procedure Mid_Rotate_Sprite3D(sprite.l,angle.f,size.f)
x1=cos(angle-2.3561944)*size*0.707106
y1=sin(angle-2.3561944)*size*0.707106
x2=-y1
y2=x1
x3=-x1
y3=-y1
x4=-x2
y4=-y2
TransformSprite3D(sprite,x1,y1,x2,y2,x3,y3,x4,y4)
endprocedure

createsprite(1,64,64,#pb_sprite_texture)
startdrawing(spriteoutput(1))
for gy=0 to 63
for gx=0 to 63
plot(gx,gy,gx*4+(gy*4<<16))
next gx
next gy
stopdrawing()

createsprite3d(1,1)

repeat
rot.f=rot+0.1
clearscreen(0,0,0)
start3d()
mid_rotate_sprite3d(1,rot,64)
displaysprite3d(1,mousex(),mousey(),255)
stop3d()
flipbuffers()
examinemouse()
until mousebutton(1)
Is this what you want?

Anyway, I think there could be a feature like that.

Posted: Sun Jul 31, 2005 7:47 pm
by va!n
Fou-Lu wrote:TransformSprite3D() can change the handle of a sprite3D.You could create a procedure to rotate a sprite3D in the middle:
Is this what you want?

Anyway, I think there could be a feature like that.
yes,thats what i mean! didnt noticed that it still exist! thanks ;)

Posted: Sun Jul 31, 2005 7:49 pm
by Fou-Lu
Ah, you're welcome. :oops: