Quote: "Here it is if anyone wants to take a look to see what I'm doing wrong."
Paul's suggestion seemed to help. Using SetScissor(0, 0, 0, 0) fixed it.
//Physics collision example with touch/mouse input, gyro input and simple shader example (windows only for shader)
// Sean Mann 2014-10-28
//although render to image works it won't do well on nonn-power of 2 and
// i don't think it is possible to render to multiple images
// plus you can't render some sprites and not others... so this idea is probably junk
#constant DOT_WIDTH 3.0
#constant MAX_CURSOR_W 20.0
#constant MIN_CURSOR_W 1.0
#constant CURSOR_GROW_SPEED 0.35
#constant cRED "255,0,0"
#constant cGREEN "0,255,0"
#constant cBLUE "0,0,255"
#constant cPURPLE "255,0,255"
#constant DOT_GROUP 2
#constant RING_GROUP 3
#constant iINIT_ALPHA 0
#constant MAX_NUM_COLORS 4
dim colors_used[MAX_NUM_COLORS]
colors_used[0] = MAX_NUM_COLORS
global gCur_init_X# = -100.0
global gCur_init_Y# = -100.0
global gCursorSprite = 0
global gRingBaseSprite = 0
global gRingImage = 0
global gRing_IN_BaseSprite = 0
global gRing_IN_Image = 0
global gBound_w# = 0.0
global gBound_h# = 0.0
global a$ = ""
global bgSpr = 0
deviceType$ = GetDeviceBaseName()
shader = 0
if deviceType$ = "windows" or deviceType$ = "mac"
//shader = LoadShader("Sprite.vs" , "Sprite.ps")
SetScreenResolution(800,1200)
endif
SetGenerateMipMaps(1)
SetDisplayAspect(-1)
SetPhysicsGravity(0,0)
SetPhysicsThreading(-1)
SetScissor( 0, 0, 0, 0 )
SetVSync(1)
//EnableClearColor(1)
//SetPhysicsDebugOn()
global _bg as integer[]
MakeBackground()
MakeBoundaries()
MakeCursor() // must be called before making dots - has base sprite
//200 max
MakeDots(50)
MakeRings()
Message("Tilt to shake the dots." + chr(10) + "Push the dots with the mouse or your finger." + chr(10) + "Get the dots in the circles to win!")
physicsstep#=0.017
time# = timer()
loopcount = 0
renderimage = createrenderimage( 2048 , 2048 , 0, 0 )
rendersprite = createsprite(0)
setspriteimage( rendersprite, renderimage )
// this sprite fills the render image with black to fade out the bluring
black = CreateSprite( 0 )
setspritesize( black, 100, 100 )
SetSpriteColor( black, 0, 0, 0, 0 )
// we set it at a high depth to ensure it's behind everything else
SetSpriteDepth( black, 10000 )
do
// store the time it took to do the loop
looptime = GetFrameTime()
// change the alpha of the black sprite depending on the current framerate
temp = looptime * 1200
// if the alpha is too low we will get noticeable ghosting, so this line limits it to 20
if temp < 20 then temp = 20
SetSpriteColorAlpha( black, temp )
count = 0
while ( count < 4 AND timer()-time# >= physicsstep# )
StepPhysics( physicsstep# )
time# = time# + physicsstep#
count = count + 1
endwhile
Print(a$)
ShakeItUp()
HandleCursor()
if fadeIn_done = 1
win = HandleDots()
endif
if win = 1
Print("You win!")
endif
// when using motion blur we don't use sync, instead we will render to our render image
setrendertoimage( renderimage, 0 )
update(0)
render()
// setting render back to the screen
setrendertoscreen()
// set the render sprite visible and to fill the screen
setspritevisible( rendersprite, 1 )
SetSpriteSize( rendersprite, 100, 100 )
SetSpritePosition( rendersprite, 0, 0 )
// draw the render sprite and update the screen
drawsprite( rendersprite )
swap()
// hide the render sprite
setspritevisible( rendersprite, 0 )
//sync()
inc loopCount
if loopCount = 30
UpdatePhysics()
elseif loopCount > 30 and fadeIn_done = 0
fadeIn_done = FadeInSprites()
endif
if fadeIn_done = 1 and overlaysOn = 0 and shader > 0
overlaysOn = 1
for i = 1 to overlays[0]
SetSpriteShader(overlays[i] , shader)
SetSpriteTransparency(overlays[i] , 2)
next i
endif
loop
END
function MakeCursor()
if gCursorSprite = 0 or GetSpriteExists(gCursorSprite) = 0
img = LoadImage("dot.png")
gCursorSprite = CreateSprite(img)
SetSpriteColor(gCursorSprite , 3 , 234 , 254 , 255)
SetSpriteSize(gCursorSprite , MIN_CURSOR_W , -1)
SetSpriteVisible(gCursorSprite , 0)
SetSpriteDepth(gCursorSprite , 100)
SetSpritePhysicsOn(gCursorSprite , 1)
SetSpritePhysicsCanRotate( gCursorSprite, 0 )
SetSpriteShapeCircle(gCursorSprite , 0 , 0 , MIN_CURSOR_W)
endif
endfunction
function HandleCursor()
pState = 0
touchCount = GetRawTouchCount(1)
if touchCount > 0
//determine most recent touch
touchID = 0
for i = 1 to touchCount
if i = 1
touchID = GetRawFirstTouchEvent(1)
else
touchID = GetRawNextTouchEvent()
endif
next i
else
pState = GetPointerState()
endif
curW# = GetSpriteWidth(gCursorSprite)
if pState = 1 or touchID > 0
//if pointer pressed then follow the pointer and grow until max size
if pState = 1
x# = GetPointerX()
y# = GetPointerY()
elseif touchID > 0
x# = GetRawTouchCurrentX(touchID)
y# = GetRawTouchCurrentY(touchID)
endif
if GetSpriteVisible(gCursorSprite) = 0
SetSpriteVisible(gCursorSprite , 1)
SetSpritePhysicsOn(gCursorSprite , 1)
//Record initial position
gCur_init_X# = x#
gCur_init_Y# = y#
endif
if curW# < MAX_CURSOR_W
newW# = curW# + MAX_CURSOR_W * GetFrameTime() / CURSOR_GROW_SPEED
if newW# > MAX_CURSOR_W
newW# = MAX_CURSOR_W
endif
SetSpriteSize(gCursorSprite , newW# , -1)
SetSpriteShapeCircle(gCursorSprite , 0 , 0 , newW# / 2.0)
endif
SetSpritePositionByOffset(gCursorSprite , x# , y#)
else
//if pointer not pressed
if curW# > MIN_CURSOR_W
newW# = curW# - MAX_CURSOR_W * GetFrameTime() / CURSOR_GROW_SPEED
if newW# =< MIN_CURSOR_W
newW# = MIN_CURSOR_W
endif
SetSpriteSize(gCursorSprite , newW# , -1)
if newW# > MIN_CURSOR_W
SetSpriteShapeCircle(gCursorSprite , 0 , 0 , newW# / 2.0)
endif
else
SetSpriteVisible(gCursorSprite , 0)
SetSpritePosition(gCursorSprite , -100 , -100)
endif
endif
endfunction
function MakeDots(iNumber)
dim dots[iNumber]
dots[0] = iNumber
h# = -1.0
for i = 1 to iNumber
dots[i] = CloneSprite(gCursorSprite)
SetSpriteVisible(dots[i] , 1)
w# = DOT_WIDTH
SetSpriteSize(dots[i] , w# , -1)
if h# < 0.0
h# = GetSpriteHeight(dots[i])
endif
SetSpriteDepth(dots[i] , 200)
SetSpritePhysicsOn(dots[i] , 2)
SetSpritePhysicsCanRotate( dots[i], 0 )
SetSpritePhysicsDamping( dots[i], 0.5)
SetSpritePhysicsRestitution( dots[i] , 1.0)
SetSpriteSnap(dots[i] , 1)
color_num = SetRandomColor(dots[i])
//set the collision group for the rings
//bit 1 is all
//bit 2 is red ring
//bit 3 is green ring
//bit 4 in blue ring
//bit 5 is purple ring
SetSpriteCategoryBit(dots[i] , 1 , 1)
if color_num = 1
SetSpriteCategoryBit(dots[i] , 2 , 1)
SetSpriteCollideBit(dots[i] , 2 , 0 ) //don't collide with red ring
SetSpriteCollideBit(dots[i] , 3 , 1 )
SetSpriteCollideBit(dots[i] , 4 , 1 )
SetSpriteCollideBit(dots[i] , 5 , 1 )
elseif color_num = 2
SetSpriteCategoryBit(dots[i] , 3 , 1)
SetSpriteCollideBit(dots[i] , 2 , 1 )
SetSpriteCollideBit(dots[i] , 3 , 0 ) //don't collide with green ring
SetSpriteCollideBit(dots[i] , 4 , 1 )
SetSpriteCollideBit(dots[i] , 5 , 1 )
elseif color_num = 3
SetSpriteCategoryBit(dots[i] , 4 , 1)
SetSpriteCollideBit(dots[i] , 2 , 1 )
SetSpriteCollideBit(dots[i] , 3 , 1 )
SetSpriteCollideBit(dots[i] , 4 , 0 ) //don't collide with blue ring
SetSpriteCollideBit(dots[i] , 5 , 1 )
elseif color_num = 4
SetSpriteCategoryBit(dots[i] , 5 , 1)
SetSpriteCollideBit(dots[i] , 2 , 1 )
SetSpriteCollideBit(dots[i] , 3 , 1 )
SetSpriteCollideBit(dots[i] , 4 , 1 )
SetSpriteCollideBit(dots[i] , 5 , 0 ) //don't collide with purple ring
endif
//determine x and y
remstart
minX = ceil(gBound_w#) + ceil(2.0 * w#)
maxX = 100 - ceil(gBound_w#) - ceil(2.0 * w#)
x# = Random(minX , maxX)
minY = ceil(gBound_h#) + ceil(2.0 * h#)
maxY = 100 - ceil(gBound_h#) - ceil(2.0 * w#)
y# = Random(minY , maxY)
for j = 1 to i
while GetSpriteInBox(dots[j] , x# , y# , x# + w# , y# + h#) = 1
x# = x# + 1.0
if x# >= maxX
y# = y# + 1.0
if y# >= maxY
y# = minY
endif
x# = minX
endif
endwhile
next j
remend
SetSpritePositionByOffset(dots[i] , 50.0 , 50.0)
vX# = random(0,400) - 200
vY# = random(0,400) - 200
SetSpritePhysicsVelocity(dots[i] , vX# , vY#)
SetSpriteColorAlpha(dots[i] , iINIT_ALPHA)
next i
endfunction
function HandleDots()
//check collision with cursor
dot_count = CountDotsLeft()
dots_in_circles = 0
for i = 1 to dots[0]
if GetSpriteExists(dots[i]) = 1
if GetSpriteCollision(gCursorSprite , dots[i]) = 1
//determine direction
curX# = GetSpriteXByOffset(gCursorSprite)
curY# = GetSpriteYByOffset(gCursorSprite)
dotX# = GetSpriteXByOffset(dots[i])
dotY# = GetSpriteYByOffset(dots[i])
SetSpritePhysicsImpulse( dots[i], curX#, curY#, (dotX# - curX#) / 15.0, (dotY# - curY#) / 15.0 )
endif
//check if inside a ring - later and same color
for r = 1 to rings[0]
rad# = GetSpriteWidth(rings[r]) / 2.0 - 2.0 * 100.0 / GetDeviceWidth()
ctr_x# = GetSpriteXByOffSet(rings[r])
ctr_y# = GetSpriteYByOffSet(rings[r])
if GetSpriteInCircle(dots[i] , ctr_x# , ctr_y# , rad#) = 1
color_num = GetColorNum(rings[r])
collideBit = color_num + 1
dot_x# = GetSpriteXByOffSet(dots[i])
dot_y# = GetSpriteYByOffSet(dots[i])
SetSpritePhysicsVelocity(dots[i] , -dot_x# + ctr_x# , -dot_y# + ctr_y#)
force_scale# = 50.0
vX# = force_scale# * (ctr_x# - dot_x#)
vY# = force_scale# * (ctr_y# - dot_y#)
SetSpritePhysicsForce(dots[i] , ctr_x# , ctr_y# , vX# , vY#)
inc dots_in_circles
endif
next r
//check for dots collision and combine
for j = 1 to dots[0]
if j <> i and GetSpriteExists(dots[j]) = 1 and GetSpriteExists(dots[i]) = 1
dot_j_vX# = GetSpritePhysicsVelocityX(dots[j])
dot_j_vY# = GetSpritePhysicsVelocityY(dots[j])
dot_i_vX# = GetSpritePhysicsVelocityX(dots[i])
dot_i_vY# = GetSpritePhysicsVelocityY(dots[i])
if GetPhysicsCollision(dots[j] , dots[i]) = 1
if CompareSpriteColor(dots[j] , dots[i]) = 1
//get the width for the new width
dot_j_w# = GetSpriteWidth(dots[j])
dot_i_w# = GetSpriteWidth(dots[i])
if dot_j_w# > dot_i_w#
del_dot = i
keep_dot = j
vX# = dot_j_vX#
vY# = dot_j_vY#
else
del_dot = j
keep_dot = i
vX# = dot_i_vX#
vY# = dot_i_vY#
endif
dot_i_area# = dot_i_w# * dot_i_w#
dot_j_area# = dot_j_w# * dot_j_w#
new_w# = sqrt(dot_i_area# + dot_j_area#)
SetSpriteSize(dots[keep_dot] , new_w# , -1)
SetSpriteShapeCircle(dots[keep_dot] , 0 , 0 , new_w# / 2.0)
//set the mass to the smaller dot's mass
mass# = GetSpritePhysicsMass(dots[del_dot])
SetSpritePhysicsMass(dots[keep_dot] , mass#)
//set velocity to the larger dot's velocity
SetSpritePhysicsVelocity(dots[keep_dot] , vX# , vY#)
//delete absorbed sprite
DeleteSprite(dots[del_dot])
endif
endif
endif
next j
endif
next i
win = 0
if dot_count = dots_in_circles
win = 1
endif
//Print("dots left = " + str(dot_count))
//Print("in circles = " + str(dots_in_circles))
endfunction win
function SetRandomColor(iSpriteID)
color_num = Random(1,MAX_NUM_COLORS)
if color_num = 1
color$ = cRED
elseif color_num = 2
color$ = cGREEN
elseif color_num = 3
color$ = cBLUE
elseif color_num = 4
color$ = cPURPLE
endif
colors_used[color_num] = 1
_SetSpriteColor(iSpriteID , color$)
endfunction color_num
function CompareSpriteColor(iSprite1 , iSprite2)
pass = 0
if GetSpriteExists(iSprite1) = 1 and GetSpriteExists(iSprite2) = 1
r1 = GetSpriteColorRed(iSprite1)
g1 = GetSpriteColorGreen(iSprite1)
b1 = GetSpriteColorBlue(iSprite1)
r2 = GetSpriteColorRed(iSprite2)
g2 = GetSpriteColorGreen(iSprite2)
b2 = GetSpriteColorBlue(iSprite2)
if r1 = r2 and g1 = g2 and b1 = b2
pass = 1
endif
endif
endfunction pass
function MakeRings()
numRings = GetNumColors()
dim rings[numRings]
rings[0] = numRings
dim overlays[numRings]
overlays[0] = numRings
color_num = 0
for i = 1 to numRings
inc color_num
if color_num > 4 then color_num = 1
if color_num = 1
color$ = cRED
elseif color_num = 2
color$ = cGREEN
elseif color_num = 3
color$ = cBLUE
elseif color_num = 4
color$ = cPURPLE
endif
if GetSpriteExists(gRingBaseSprite) = 0
if GetImageExists(gRingImg) = 0
gRingImg = LoadImage("ring.png")
endif
gRingBaseSprite = CreateSprite(gRingImg)
thisRing = gRingBaseSprite
else
thisRing = CloneSprite(gRingBaseSprite)
endif
w# = 1.5 * DetermineMaxDotSize(color$)
SetSpriteSize(thisRing , w# , -1)
h# = GetSpriteHeight(thisRing)
//determine x and y
/*
minX = ceil(gBound_w#) + ceil(4.0 * w#)
maxX = 100 - ceil(gBound_w#) - ceil(4.0 * w#)
x# = Random(minX , maxX)
minY = ceil(gBound_h#) + ceil(4.0 * h#)
maxY = 100 - ceil(gBound_h#) - ceil(4.0 * h#)
y# = Random(minY , maxY)
*/
select i
case 1:
x# = 0.5 * w# + gBound_W#
y# = 0.5 * h# + gBound_H#
endcase
case 2:
x# = 100.0 - 0.5 * w# - gBound_W#
y# = 0.5*h# + gBound_H#
endcase
case 3:
x# = gBound_W# + 0.5 * w#
y# = 100.0 - 0.5 * h# - gBound_H#
endcase
case 4:
x# = 100.0 - 0.5*w# - gBound_W#
y# = 100.0 - 0.5*h# - gBound_H#
endcase
case default:
endcase
endselect
SetSpriteDepth(thisRing , 300)
SetSpritePositionByOffset(thisRing , x# , y#)
SetSpritePhysicsOn(thisRing , 1) //should bump all dots out of the bounds of the ring and prevent ring overlap
rings[i] = thisRing
_SetSpriteColor(thisRing , color$)
SetSpriteColorAlpha(thisRing , iINIT_ALPHA)
overlay = CreateSprite(0)
SetSpriteSize(overlay , w#, 0.85 * h#)
SetSpritePositionByOffset(overlay , x#, y#)
SetSpriteDepth(overlay , 200)
SetSpriteColorAlpha(overlay , iINIT_ALPHA)
overlays[i] = overlay
next i
endfunction
function UpdatePhysics()
//allow dots of the same color to enter the rings all others repel
for i = 1 to rings[0]
SetSpritePhysicsDelete(rings[i])
SetSpritePhysicsOn(rings[i] , 1)
r# = GetSpriteWidth(rings[i]) / 2.0 - 1.0 * 100.0 / GetDeviceWidth()
SetSpriteShapeCircle(rings[i] , 0 , 0 , r#)
//i is equivalent to the color
if i = 1
SetSpriteCategoryBit(rings[i] , 1 , 0)
SetSpriteCategoryBit(rings[i] , 2 , 1)
SetSpriteCollideBit(rings[i] , 1 , 0 ) //don't collide with general sprites
elseif i = 2
SetSpriteCategoryBit(rings[i] , 1 , 0)
SetSpriteCategoryBit(rings[i] , 3 , 1)
SetSpriteCollideBit(rings[i] , 1 , 0 ) //don't collide with general sprites
elseif i = 3
SetSpriteCategoryBit(rings[i] , 1 , 0)
SetSpriteCategoryBit(rings[i] , 4 , 1)
SetSpriteCollideBit(rings[i] , 1 , 0 ) //don't collide with general sprites
elseif i = 4
SetSpriteCategoryBit(rings[i] , 1 , 0)
SetSpriteCategoryBit(rings[i] , 5 , 1)
SetSpriteCollideBit(rings[i] , 1 , 0 ) //don't collide with general sprites
endif
SetSpritePhysicsVelocity(rings[i] , 0 , 0)
next i
//make highlights
dim rings_in[rings[0]]
rings_in[0] = rings[0]
for i = 1 to rings[0]
if GetImageExists(gRing_IN_Image) = 0
gRing_IN_Image = LoadImage("ring_in.png")
endif
if GetSpriteExists(gRing_IN_BaseSprite) = 0
thisRing_in = CreateSprite(gRing_IN_Image)
else
thisRing_in = CloneSprite(gRing_IN_BaseSprite)
endif
x# = GetSpriteX(rings[i])
y# = GetSpriteY(rings[i])
w# = GetSpriteWidth(rings[i])
SetSpriteSize(thisRing_in , w# , -1)
SetSpritePosition(thisRing_in , x# , y#)
r = GetSpriteColorRed(rings[i])
b = GetSpriteColorBlue(rings[i])
g = GetSpriteColorGreen(rings[i])
if r = 0 then r = 200
if b = 0 then b = 200
if g = 0 then g = 200
SetSpriteColor(thisRing_in , r , g , b, 255)
rings_in[i] = thisRing_in
SetSpriteColorAlpha(thisRing_in , 0)
next i
for i = 1 to dots[0]
if GetSpriteExists(dots[i]) = 1
SetSpritePhysicsVelocity(dots[i] , 0 , 0)
endif
next i
endfunction
function GetNumColors()
count = 0
for i = 1 to colors_used[0]
if colors_used[i] = 1
inc count
endif
next i
endfunction count
function DetermineMaxDotSize(sColor$)
maxDotSize# = 0.0
for i = 1 to dots[0]
if GetSpriteColorString(dots[i]) = sColor$
dotArea# = dotArea# + DOT_WIDTH * DOT_WIDTH
endif
next i
maxDotSize# = sqrt(dotArea#)
endfunction maxDotSize#
function _SetSpriteColor(iID , sColor$)
if GetSpriteExists(iID) = 1
r = val(GetStringToken(sColor$ , "," , 1))
g = val(GetStringToken(sColor$ , "," , 2))
b = val(GetStringToken(sColor$ , "," , 3))
SetSpriteColor(iID , r , g , b , 255)
endif
endfunction
function GetSpriteColorString(iSpriteID)
if GetSpriteExists(iSpriteID) = 1
r = GetSpriteColorRed(iSpriteID)
g = GetSpriteColorGreen(iSpriteID)
b = GetSpriteColorBlue(iSpriteID)
color$ = str(r) + "," + str(g) + "," + str(b)
endif
endfunction color$
function GetColorNum(iSpriteID)
color$ = GetSpriteColorString(iSpriteID)
if color$ = cRED
color_num = 1
elseif color$ = cGREEN
color_num = 2
elseif color$ = cBLUE
color_num = 3
elseif color$ = cPURPLE
color_num = 4
endif
endfunction color_num
function MakeBackground()
depth = 5000
img = LoadImage("starsheet.png")
spr0 = CreateSprite(img)
bgSpr = spr0
SetSpriteAnimation(spr0 , 128 , 128 , 12)
SetSpriteSize(spr0 , 25 , -1)
SetSpriteDepth(spr0 , depth)
x# = 0
w# = GetSpriteWidth(spr0)
h# = GetSpriteHeight(spr0)
num_w = ceil(100.0 / w#)
num_h = ceil(100.0 / h#)
_bg.length = num_h * num_w
iter = 0
for r = 1 to num_h
x# = 0
for c = 1 to num_w
if doOnce = 0
doOnce = 1
spr = spr0
else
spr = CloneSprite(spr0)
endif
SetSpritePosition(spr , x# , y#)
PlaySprite(spr , 8 , 1)
SetSpriteFrame(spr , random(1,GetSpriteFrameCount(spr)))
r_ang = random(0,3)
ang = r_ang * 90
SetSpriteAngle(spr , ang)
x# = x# + w#
inc iter
_bg[iter] = spr
SetSpriteVisible(spr , 0)
next c
y# = y# + h#
next r
_bg[0] = iter
endfunction
function CountDotsLeft()
count = 0
for i = 1 to dots[0]
if GetSpriteExists(dots[i]) = 1
inc count
endif
next i
endfunction count
function MakeBoundaries()
gBound_h# = 5.0
gBound_w# = gBound_h# / GetDisplayAspect()
b = CreateSprite(0)
SetSpriteSize(b , 100.0 , gBound_h#)
SetSpriteVisible(b , 0)
SetSpritePosition(b , 0 , 0)
SetSpritePhysicsOn(b,1)
b = CreateSprite(0)
SetSpriteSize(b , gBound_w# , 100.0)
SetSpriteVisible(b , 0)
SetSpritePosition(b , 0 , 0)
SetSpritePhysicsOn(b,1)
b = CreateSprite(0)
SetSpriteSize(b , gBound_w# , 100.0)
SetSpriteVisible(b , 0)
SetSpritePosition(b , 100.0 - gBound_w# , 0)
SetSpritePhysicsOn(b,1)
b = CreateSprite(0)
SetSpriteSize(b , 100.0 , gBound_h#)
SetSpriteVisible(b , 0)
SetSpritePosition(b , 0 , 100.0 - gBound_h#)
SetSpritePhysicsOn(b,1)
endfunction
function FadeInSprites()
ft# = GetFrameTime()
t# = 1.0
done = 0
for i = 1 to dots[0]
dot_done = FadeInSpriteAsync(dots[i] , ft# , t#)
dot_done_count = dot_done_count + dot_done
next i
for i = 1 to rings[0]
ring_done = FadeInSpriteAsync(rings[i] , ft# , t#)
ring_done_count = ring_done_count + ring_done
next i
for i = 1 to rings_in[0]
ring_in_done = FadeInSpriteAsync(rings_in[i] , ft# , t#)
ring_in_done_count = ring_in_done_count + ring_in_done
next i
if dot_done_count = dots[0] and ring_done_count = rings[0] and ring_in_done_count = rings_in[0]
done = 1
endif
endfunction done
function FadeInSpriteAsync(iSpriteID , ft# , t#)
done = 0
if GetSpriteExists(iSpriteID) = 0
EXITFUNCTION 1
endif
a# = GetSpriteColorAlpha(iSpriteID)
if a# < 255
a# = a# + 255.0 * ft# / t#
if a# >= 255
done = 1
a# = 255
endif
SetSpriteColorAlpha(iSpriteID , a#)
else
done = 1
endif
endfunction done
function ShakeItUp()
minAcc# = 0.95
if GetAccelerometerExists() = 1
accY# = GetRawGyroVelocityX()
accX# = GetRawGyroVelocityY()
xyz = 0
if abs(accX#) > minAcc#
acc# = accX#
xyz = 1
elseif abs(accY#) > minAcc#
acc# = accY#
xyz = 2
endif
if xyz > 0
ShakeDots(xyz , acc#)
endif
endif
endfunction
function ShakeDots(xyz as integer , acc# as float)
maxV# = 0.5
if xyz = 1
vX# = maxV# * acc#
vY# = 0.0
elseif xyz = 2
vX# = 0.0
vY# = maxV# * acc#
endif
for i = 1 to dots[0]
SetSpritePhysicsImpulse(dots[i] , GetSpriteXByOffset(dots[i]), GetSpriteXByOffset(dots[i]) , vX# , vY#)
next i
endfunction
Sean