Author Topic: Rotating, distorting sprite circle (from D-Bug 185 remake)  (Read 2219 times)

0 Members and 1 Guest are viewing this topic.

KrazyK

• Amiga 1200
• Posts: 278
• Karma: 121
Rotating, distorting sprite circle (from D-Bug 185 remake)
« on: July 23, 2013 »
Here's a snippet of code I conjoured up for the sprite circle routine in my D-Bug 185 remake.
Purebasic 5.20 (beta 5)
Feel free to use this code......credit would be nice though...

Code: [Select]
`;D-BUG 185 rotating sprite circle routine;KrazyK;July 2013;For DBFInteractive.com;PB 5.20 Beta 5InitSprite()OpenWindow(1,0,0,640,480,"DBUG 185",#PB_Window_BorderLess|#PB_Window_ScreenCentered|#PB_Window_WindowCentered)OpenWindowedScreen(WindowID(1),0,0,640,480)ShowCursor_(0)StickyWindow(1,1)Global stp.f,t.fGlobal CSPR=2501            ;our starting sprite numberGlobal xpos,ypos#INT=220                    ;transparency value#RADIUS=80                  ;circle radius#NumBalls=16Global stp.f=(#PI*2)/#NumBallsProcedure DetectBalls()       ;very simple routine to detect our boundary box and limit the ball sprites to the edges If xpos <=0 : xpos=0:EndIf                      ;test left edge If (xpos+16) >=640 : xpos=640-32:EndIf        ;test right edge If ypos <=40 : ypos=40:EndIf        ;test top edge If (ypos+16) >440-64 : ypos=440-64-16:EndIf      ;test top edgeEndProcedureProcedure DrawCircle(CX,CY)       t+0.085                                   ;move the balls to the left       If t>=360:t=0:EndIf For BALL=2501 To 2516                    ;16 sprites t.f+stp.f                         ;step around the circle xpos=CX+(Sin(t)*#RADIUS)          ypos=CY+(Cos(t)*#RADIUS)          DetectBalls()                 ;check the bounding box DisplayTransparentSprite(BALL,xpos,ypos,#INT) Next BALLEndProcedureProcedure InitCircle()        ;create some basic sprites.  I used captured bitmaps in the remake.       CreateSprite(1,32,32)       StartDrawing(SpriteOutput(1))              Circle(16,16,16,RGB(198,165,66))       StopDrawing()              CreateSprite(2,32,32)       StartDrawing(SpriteOutput(2))              Circle(16,16,16,RGB(32,165,198))       StopDrawing()        For C=1 To 16 Step 2              CopySprite(1,2500+C) Next C For C=2 To 16 Step 2              CopySprite(2,2500+C) Next CEndProcedurevaluesx=64           ;x speedvaluesy=48           ;y speedstpx.f=(#PI*2)/valuesxstpy.f=(#PI*2)/valuesyInitCircle()Repeat ClearScreen(0) x.f+stpx/1.5                ;circle speed x y.f+stpy.f/1.5              ;circle speed y cxpos=(300+(Sin(x.f)*320)) cypos=(200+(Sin(y.f)*180)) DrawCircle(cxpos,cypos) FlipBuffers() If GetAsyncKeyState_(#VK_ESCAPE):End:EndIfForEver`
« Last Edit: July 23, 2013 by KrazyK »
Challenge Trophies Won:

• Senior Member
• Pentium
• Posts: 978
• Karma: 258
Re: Rotating, distorting sprite circle (from D-Bug 185 remake)
« Reply #1 on: July 23, 2013 »
Nice! Thanks for sharing. K++
Challenge Trophies Won:

emook

• C= 64
• Posts: 88
• Karma: 12
Re: Rotating, distorting sprite circle (from D-Bug 185 remake)
« Reply #2 on: August 11, 2013 »
Lovely work, very smooth - keep em comming

----

jace_stknights

• Amiga 1200
• Posts: 399
• Karma: 32
• PEEK & POKE are not MOVEM!
Re: Rotating, distorting sprite circle (from D-Bug 185 remake)
« Reply #3 on: September 04, 2013 »

Thanx!
Challenge Trophies Won: