

Code: Select all
; text$ = " oo "
text$ = "pure"
; text$ = "peek"
; text$ = "cube"
; text$ = "1337"
; wireframeMode = 1
Procedure.s BuildPixelString(String$, Char$="*", font.i=#PB_Ignore) ;;; (infratec)
Protected Result$, Line$, Img.i, StringWidth.i, StringHeight.i, y.i, x.i
Img = CreateImage(#PB_Any, 1, 1)
If Img
If StartDrawing(ImageOutput(Img))
DrawingFont(FontID(font))
StringWidth = TextWidth(String$)
StringHeight = TextHeight(String$)
StopDrawing()
FreeImage(Img)
Img = CreateImage(#PB_Any, StringWidth, StringHeight)
If Img
If StartDrawing(ImageOutput(Img))
DrawingFont(FontID(font))
DrawText(0, 0, String$, $FFFFFF)
For y = StringHeight - 1 To 0 Step -1
Line$ = ""
For x = 0 To StringWidth - 1
If Point(x, y) = 0
Line$ + " "
Else
Line$ + Char$
EndIf
Next x
Line$ = LSet(Line$, StringWidth, " ")
Result$ + Line$ + #CRLF$
Next y
StopDrawing()
EndIf
FreeImage(Img)
EndIf
EndIf
EndIf
ProcedureReturn Result$
EndProcedure
Procedure.s pixelON(f$, X, Y)
ProcedureReturn Mid(StringField(f$, Y + 1, #CRLF$), X + 1, 1)
EndProcedure
LoadFont(16, "Consolas", 12)
f$ = BuildPixelString(text$, "*", 16)
InitEngine3D() : InitSprite()
InitKeyboard()
Structure Cubes
ms.i
ma.i
tx.i
id.i
direction.i
EndStructure
#NbrCubesX = 40
#NbrCubesY = 24
speed.f = 1.6
Dim cubes.Cubes(#NbrCubesX, #NbrCubesY)
ExamineDesktops()
OpenWindow(0, 0, 0, 10, 10, "Cubes", #PB_Window_ScreenCentered|#PB_Window_Maximize|#PB_Window_BorderLess)
OpenWindowedScreen(WindowID(0), 10,10, DesktopWidth(0)-20, DesktopHeight(0)-20, #True, 0, 0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 10.5, 3.5, 0)
if wireframeMode = 1
CameraRenderMode(0, #PB_Camera_Wireframe)
endif
CreateLight(0, $FFFFFF, -3, -5, 0)
For y = 0 To #NbrCubesY
For x = 0 To #NbrCubesX
With Cubes(x,y)
col = RGB(Random(255, 120), Random(255,120), Random(255, 120))
\tx = CreateTexture(#PB_Any, 10, 10)
StartDrawing(TextureOutput(\tx))
Box(0, 0, 10, 10, col)
StopDrawing()
\ma = CreateMaterial(#PB_Any, TextureID(\tx))
\ms = CreateCube(#PB_Any, 0.3)
If PixelON(f$, x, y) = "*"
\id = CreateEntity(#PB_Any, MeshID(\ms), MaterialID(\ma), x * 0.6, y * 0.6, -16)
EndIf
\direction = Random(50)
EndWith
Next x
Next y
Repeat
Repeat : ev = WindowEvent() : Until ev = 0
For y = 0 To #NbrCubesY
For x = 0 To #NbrCubesX
With cubes(x,y)
If \id
Select \direction
Case 0 To 10
RotateEntity(\id, speed, speed, speed, #PB_Relative)
Case 11 To 20
RotateEntity(\id, -speed, speed, speed, #PB_Relative)
Case 21 To 30
RotateEntity(\id, speed, speed, -speed, #PB_Relative)
Case 31 To 40
RotateEntity(\id, speed, -speed, speed, #PB_Relative)
Default
RotateEntity(\id, -speed, -speed, -speed, #PB_Relative)
EndSelect
EndIf
EndWith
Next x
Next y
RenderWorld()
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)