Posted: 27th Jun 2007 11:50
I've been using the offset command, which gets the image in the right place, but when using sprite collision it is still messed up as the program thinks the image is not offset.
Is there any other way to reposition the point of rotation on a sprite to the center of it, without messing up the sprite collisions?
Posted: 27th Jun 2007 13:58
can you put sample code?

Edit: yep


+ Code Snippet
sync on: sync rate 60
set display mode 1024, 768, 16

car_img = 1
car1 = 1
car2 = 2

create bitmap 1,50,100 
box 0,0,50,100
get image car_img,0,0,50,100
delete bitmap 1 


rem create car number 1
sprite car1, 1024/3, 768/3, car_img
x = sprite width(car1) / 2
y = sprite height(car1) / 2
OFFSET SPRITE car1, x, y

rem create car number 2
sprite car2, 1024/1.5, 768/1.5, car_img
x = sprite width(car2) / 2
y = sprite height(car2) / 2
OFFSET SPRITE car2, x, y


do  

    rem car number 1 control
    m = upkey() - downkey() 
    r = rightkey() - leftkey()    
    
    move sprite car1, m 
    a# = wrapvalue(SPRITE ANGLE(car1)+r) 
    rotate sprite car1, a#
     

    rem car number 2 control
    m = keystate(17) - keystate(31) 
    r = keystate(32) - keystate(30)    
    
    move sprite car2, m 
    a# = wrapvalue(SPRITE ANGLE(car2)+r) 
    rotate sprite car2, a#

    
    set cursor 1,1        
    print "FPS:"+str$(screen fps())
    print "control: car1: arrows, car2: w,s,a,d"
    print "Two car collision: "+str$(SPRITE COLLISION(car1, car2))
    print "Two car hit:" + str$(SPRITE HIT(car1, car2))
    

    sync
loop

Posted: 27th Jun 2007 14:20
well its just the normal offset sprite thing:

+ Code Snippet
offset sprite spr,sprite width(spr)/2,sprite height(spr)/2,img

that centers the image, but whenever you use the eXtends command as below, or even with just the normal DBpro sprite command
+ Code Snippet
spr get collision(spr,spr_2)


the program thinks the sprite image has not moved and the collision command acts accordingly.

I need the image center to be at the sprite co-ordinates, since I need to rotate it. Is there another way?
Posted: 27th Jun 2007 14:37
yep, you need someelse sprite collision dll, or you need do something else :S
Posted: 27th Jun 2007 15:02
Well, Humanoids snippet shows that the DBPro offset command IS working for sprite collision. Remember that the sprite collision bounding box is a box that contains the sprite, even if rotated, collision does not do pixel perfect rotated sprites. Moving the offset to the middle of sprite does indeed move the collision box with it.

Freddix has already said that his extends dll does not take into account any offsetting and he may fix that in a future release.
Posted: 27th Jun 2007 17:13
hmm ok. Well I will have to wait on Freddix then as I need pixel perfect collision, and the DBPro method without eXtends doesnt work with sprite rotation, at least not the version in the eXtends help files.

cheers
Posted: 27th Jun 2007 19:48
You could just manually offset the sprite's position, rather than using offset sprite