im having alot of problems trying to fan some cards in an arc style
my current code is -
count = LEN(p1cards#[])
start = 380 - (count/2)*40 // x of first card
stepangle = 60/count
angle = 30
FOR i = 0 TO count -1
ROTOSPRITE p1cards#[i], i*40+start, 500-COS(angle)*100, angle
angle = angle - stepangle
IF angle < 0
angle = angle + 360
ENDIF
NEXT
which makes it look like
(http://img407.imageshack.us/img407/9927/unof.png)
please can someone spot my mistake and explain what i am doing wrong
thanks
Yommy x
I propose :
LOADSPRITE "c:/test/test.bmp",1
LOADSPRITE "c:/test/test2.bmp",2
LOADSPRITE "c:/test/test3.bmp",3
maxCard=9
stepAngle=180.0/maxCard
startAngle=270.0
angle2=180.0
s%=1
WHILE TRUE
angle2=180.0
startAngle=270.0
FOR loop%=0 TO maxCard-1
ROTOSPRITE s%,100+(50.0*COS(angle2)),100+(50.0*SIN(angle2)),startAngle
DEC startAngle,stepAngle
INC angle2,stepAngle
INC s%
IF s%>3
s%=1
ENDIF
NEXT
SHOWSCREEN
WEND
Which results in :
(http://i475.photobucket.com/albums/rr115/MrTAToad/moo.jpg)
LOCAL p1cards#[]
DIM p1cards[4]
LOADSPRITE "card.bmp", 0
LOCAL count, start, angle,fullangle
LOCAL screenwidth, screenheight
GETSCREENSIZE screenwidth, screenheight
count = LEN(p1cards#[])
fullangle = 30
LOCAL yy=0
FOR i = 0 TO count -1
LOCAL saggita = 500
LOCAL x, y
LOCAL proc = i; proc = proc / (count-1) // float from 0..1 for each card
angle = fullangle/2-fullangle*proc
// the 300 is the width from 1st to last card -> you can make that count * width_of_card if you like
x = (proc-0.5) * 300.0 + screenwidth/2
y = 400-(COS(angle)-1)*saggita
// ROTOSPRITE 0, x, y, angle
PickCard(0, x,y, angle, TRUE)
PRINT INTEGER(angle), x,y
PRINT x, 0,yy
INC yy,25
NEXT
SHOWSCREEN
MOUSEWAIT
FUNCTION PickCard%: index%, x, y, angle, bDraw%
LOCAL px[], py[]
DIM px[4]
DIM py[4]
LOCAL w, h // card dimensions
LOCAL spx, spy
GETSPRITESIZE index, spx, spy
w=spx/2
h=spy/2 // for example - you can scale if you want
px[0] = -w; py[0] = -h
px[1] = -w; py[1] = h
px[2] = w; py[2] = h
px[3] = w; py[3] = -h
// now rotate that points around the center
TransformPoint(px[0], py[0], x,y, angle)
TransformPoint(px[1], py[1], x,y, angle)
TransformPoint(px[2], py[2], x,y, angle)
TransformPoint(px[3], py[3], x,y, angle)
// Draw a polyvvector
LOCAL c%=RGB(255,255,255)
STARTPOLY index
POLYVECTOR px[0], py[0], 0, 0, c%
POLYVECTOR px[1], py[1], 0, spy,c%
POLYVECTOR px[2], py[2], spx,spy,c%
POLYVECTOR px[3], py[3], spx, 0,c%
ENDPOLY
ENDFUNCTION
FUNCTION TransformPoint: BYREF x, BYREF y, dx, dy, angle
LOCAL px, py
px = x*COS(angle)+y*SIN(angle)
py = -x*SIN(angle)+y*COS(angle)
x=px+dx
y=py+dy
ENDFUNCTION
Tadaa.