[windows] kaleidoscope sprite test
Posted: Fri Sep 06, 2002 6:17 am
Code updated for 5.20+
Restored from previous forum. Originally posted by chr1sb.
It's really just my little test of sprite3D functions but you can make interesting patterns by moving the mouse - for example, try moving your mouse in smooth figure of 8 shapes around the centre of the screen.
Not sure what the minimum PC requirment is - it only uses one 16x16 3D sprite but draws it 1024 times each frame.
Note: ScreenDepth can be 16 but this causes a strange green effect like I mentioned in one of my other posts. I think this is maybe something to do with the 16bit mode uses more bits for the green component of the color than for red and blue?
chr1sb
Restored from previous forum. Originally posted by chr1sb.
It's really just my little test of sprite3D functions but you can make interesting patterns by moving the mouse - for example, try moving your mouse in smooth figure of 8 shapes around the centre of the screen.
Not sure what the minimum PC requirment is - it only uses one 16x16 3D sprite but draws it 1024 times each frame.
Code: Select all
Global ScreenWidth = 640
Global ScreenHeight = 480
Global ScreenDepth = 32
Global PointCount=%11111111
Global ScreenTitle.s = "Mandaloid"
Global cursorpos.point
Global mb_left.w=0
Global mb_right.w=0
Global angle.f=0
Dim PointArray.Point(PointCount)
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Can't start DirectX", 0)
End
EndIf
If OpenScreen(ScreenWidth,ScreenHeight,ScreenDepth,ScreenTitle)
CreateSprite(0,16,16,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(0))
Box(0,0,16,16,RGB(128,128,128))
Box(1,1,14,14,RGB(255,255,255))
Box(2,2,12,12,RGB(128,128,128))
Box(3,3,10,10,RGB(0,0,0))
StopDrawing()
SpriteQuality(1)
Repeat
FlipBuffers()
ClearScreen(0)
GetCursorPos_(@CursorPos)
PointArray(count)\x=CursorPos\x
PointArray(count)\y=CursorPos\y
For f=0 To PointCount
currentzoom=(((PointCount-f))>>2)+1
offset=currentzoom>>1
currentpoint=((f+count) & PointCount)
x=PointArray(currentpoint)\x
y=PointArray(currentpoint)\y
Trans=f/2
RotateSprite(0, 0, 0)
ZoomSprite(0, currentzoom, currentzoom)
RotateSprite(0, Angle, 1)
DisplaySprite(0,x-offset,y-offset)
DisplaySprite(0,(ScreenWidth-x)-offset,(ScreenHeight-y)-offset)
RotateSprite(0, 0, 0)
ZoomSprite(0, currentzoom, currentzoom)
RotateSprite(0, -Angle, 1)
DisplaySprite(0,(ScreenWidth-x)-offset,y-offset)
DisplaySprite(0,x-offset,(ScreenHeight-y)-offset)
Angle=Angle+0.1
If angle=360
angle=0
EndIf
Next
count=(count+1) & PointCount
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)
Else
MessageRequester("Error", "Can't open screen", 0)
EndIf
End
chr1sb