Code: Select all
Enumeration 1
#Sprite3D1
#Window_Main
#Status_Bar
#Gadget_Button_ClickMe
#Sprite1
#Image_Background
EndEnumeration
Quit = #FALSE
nSprites = 10
Dim ZoomFactor(nSprites)
Dim Zoom(nSprites)
Dim AngleFactor(nSprites)
Dim Angle(nSprites)
Dim XFactor(nSprites)
Dim YFactor(nSprites)
Dim X(nSprites)
Dim Y(nSprites)
Dim Transparency(nSprites)
WindowXSize = GetSystemMetrics_(#SM_CXSCREEN)
WindowYSize = GetSystemMetrics_(#SM_CYSCREEN)
WindowedScreenXSize = 800
WindowedScreenYSize = 600
For i = 1 To nSprites
ZoomFactor(i) = 10
AngleFactor(i) = 1
XFactor(i) = 1
YFactor(i) = 1
Zoom(i) = Random(200)
Angle(i) = Random(360)
X(i) = Random(WindowedScreenXSize)
Y(i) = Random(WindowedScreenYSize)
Transparency(i) = 100
Next
Start = #TRUE
If InitSprite() And InitSprite3D() And InitKeyboard() And InitMouse()
If OpenWindow(#Window_Main, 0, 0, WindowXSize, WindowYSize, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered, "Happy birthday")
If CreateGadgetList(WindowID())
SetGadgetFont(#PB_Default, LoadFont(0, "Verdana", 24, #PB_Font_Bold | #PB_Font_Italic | #PB_Font_HighQuality))
ButtonGadget(#Gadget_Button_ClickMe, 10, 10, WindowXSize - 20, 60, "Click me")
EndIf
BackgroundImageID = CreateImage(#Image_Background, WindowedScreenXSize, WindowedScreenYSize)
StartDrawing(ImageOutput())
For x = 0 To WindowedScreenXSize
LineXY(x, 0, 0, x * WindowedScreenYSize / WindowedScreenXSize, x << 15)
LineXY(x, WindowedScreenYSize, WindowedScreenXSize, x * WindowedScreenYSize / WindowedScreenXSize, x << 15)
Next
StopDrawing()
hCursor1 = LoadCursor_(0, #IDC_ARROW)
hCursor2 = LoadCursor_(0, #IDC_CROSS)
AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Escape, #PB_Shortcut_Escape)
If OpenWindowedScreen(WindowID(), (WindowXSize - WindowedScreenXSize) / 2, (WindowYSize - WindowedScreenYSize - WindowedScreenBottomMargin) / 2, WindowedScreenXSize, WindowedScreenYSize, 0, 0, 0)
SpriteWidth = 128
SpriteHeight = 128
TransparentSpriteColor(-1, 0, 0, $40)
CreateSprite(#Sprite1, SpriteWidth, SpriteHeight, #PB_Sprite_Texture)
StartDrawing(SpriteOutput(#Sprite1))
DrawingFont(LoadFont(0, "Verdana", 10, #PB_Font_Bold | #PB_Font_Italic | #PB_Font_HighQuality))
Box(0, 0, SpriteWidth, SpriteHeight, $400000)
BackColor(0, 0, $40)
FrontColor($FF, $FF, $C0)
DrawingMode(1)
Text.s = "Happy birthday"
Locate((SpriteWidth - TextLength(Text)) / 2, (SpriteHeight - 15) / 2)
DrawText(Text)
Text.s = "LarsG"
Locate((SpriteWidth - TextLength(Text)) / 2, (SpriteHeight + 15) / 2)
DrawText(Text)
DrawingMode(4)
Box(0, 0, SpriteWidth, SpriteHeight, $C0FFFF)
StopDrawing()
CreateSprite3D(#Sprite3D1, #Sprite1)
Sprite3DQuality(1)
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
Quit = #TRUE
Case #PB_Event_Menu
Select EventMenuID()
Case #PB_Shortcut_Escape
Quit = #TRUE
EndSelect
Case #PB_Event_Gadget
Select EventGadgetID()
Case #Gadget_Button_ClickMe
If Start
Start = #FALSE
FreeGadget(#Gadget_Button_ClickMe)
ButtonGadget(#Gadget_Button_ClickMe, 10, 10, WindowXSize - 20, 60, "Quit")
Else
Quit = #TRUE
EndIf
EndSelect
EndSelect
GetCursorPos_(CursorPosition.POINT) - 20
MouseX = CursorPosition\x - WindowX()
MouseY = CursorPosition\y - WindowY()
If MouseX >= WindowXSize - WindowedScreenXSize And MouseX <= WindowXSize And MouseY >= WindowYSize - WindowedScreenYSize And MouseY <= WindowYSize
SetCursor_(hCursor2)
Else
SetCursor_(hCursor1)
EndIf
If Start3D()
FlipBuffers()
ClearScreen($00, $00, $40)
StartDrawing(ScreenOutput())
DrawImage(BackgroundImageID, 0, 0)
If Start = #FALSE
DrawingFont(LoadFont(0, "Verdana", 40, #PB_Font_Bold | #PB_Font_Italic | #PB_Font_HighQuality))
BackColor(0, 0, $40)
FrontColor($FF, $FF, $FF)
DrawingMode(1)
Text.s = "Happy birthday"
XText = (WindowedScreenXSize - TextLength(Text)) / 2
YText = (WindowedScreenYSize - 60) / 2
Locate(XText - 2, YText + 2)
DrawText(Text)
FrontColor(Red(Color), Green(Color), Blue(Color))
Locate(XText, YText)
DrawText(Text)
FrontColor($FF, $FF, $FF)
Text.s = "LarsG"
XText = (WindowedScreenXSize - TextLength(Text)) / 2
YText = (WindowedScreenYSize + 60) / 2
Locate(XText - 2, YText + 2)
DrawText(Text)
FrontColor(Red(Color), Green(Color), Blue(Color))
Locate(XText, YText)
DrawText(Text)
Color + 7
DrawingMode(0)
For i = 12 To 1 Step -1
XCandle = WindowedScreenXSize / 2 + 300 * Sin(i / 4)
YCandle = WindowedScreenYSize / 2 + 150 * Cos(i / 4)
For Candle = 10 To 0 Step - 2
Box(XCandle - Candle + 5, YCandle + 80, Candle, 35, RGB(150 + 10 * Candle, 150 + 10 * Candle, 150 + 10 * Candle))
Next
For Light = 25 To 1 Step -1
Circle(XCandle + Random(2) - 1, YCandle + 3* Light + Random(2) - 1, Light / 4, RGB(Light * 10, Light * 6, 0))
Next
XCandle = WindowedScreenXSize / 2 - 300 * Sin(i / 4)
YCandle = WindowedScreenYSize / 2 + 150 * Cos(i / 4)
For Candle = 10 To 0 Step - 2
Box(XCandle - Candle + 5, YCandle + 80, Candle, 35, RGB(150 + 10 * Candle, 150 + 10 * Candle, 150 + 10 * Candle))
Next
For Light = 25 To 1 Step -1
Circle(XCandle + Random(2) - 1, YCandle + 3* Light + Random(2) - 1, Light / 4, RGB(Light * 10, Light * 6, 0))
Next
Next
EndIf
StopDrawing()
For i = 1 To nSprites
ZoomSprite3D(#Sprite3D1, Zoom(i), Zoom(i))
RotateSprite3D(#Sprite3D1, Angle(i), 0)
DisplaySprite3D(#Sprite3D1, X(i), Y(i), Transparency(i))
Transparency(i) = Transparency(i) + 1
If Transparency(i) > 255
Transparency(i) = 200
EndIf
Zoom(i) + ZoomFactor(i)
If Abs(Zoom(i)) > 256
ZoomFactor(i) = -ZoomFactor(i)
EndIf
Angle(i) + AngleFactor(i)
If Angle(i) > 360
AngleFactor(i) = -AngleFactor(i)
EndIf
X(i) + XFactor(i)
Y(i) + YFactor(i)
If X(i) > WindowedScreenXSize Or X(i) < 0
XFactor(i) = -XFactor(i)
EndIf
If Y(i) > WindowedScreenYSize Or Y(i) < 0
YFactor(i) = -YFactor(i)
EndIf
Next
Stop3D()
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
Quit = #TRUE
EndIf
Delay(1)
Until Quit
Else
MessageRequester("Error", "Can't open the main windowedscreen", 0)
EndIf
Else
MessageRequester("Error", "Can't open the main window", 0)
EndIf
Else
MessageRequester("Error", "Can't init DirectX", 0)
EndIf
End