Kale wrote:Plus another setback is that you cannot mix 2d and 3d commands together as PB requires you to do a FlipBuffer in between the Start3D and End3D, making it impossible to use both
eh? I have coded a little app that uses both. The main loop look likes this:
Code: Select all
...
Start3D()
Repeat
FlipBuffers()
ClearScreen(255, 255, 255)
DisplaySprite(#MAIN_IMAGE, 0, 0)
calculateAlpha()
For x = 0 To #NUMBER_OF_FLAKES-1
DisplaySprite3D(x, flakes(x)\xPos, flakes(x)\yPos, flakes(x)\alpha)
Next x
xMoveFlakes()
yMoveFlakes()
sleep_(1)
Select WindowEvent()
Case #PB_EventCloseWindow
quit = 1
Case #WM_CLOSE
quit = 1
EndSelect
EscapeKey = GetAsyncKeyState_(#VK_ESCAPE)
Until EscapeKey = -32767 Or quit = 1
Stop3D()
...
your wrong there you can mix 2D and 3D sprite here is some of my code in the 3Dsnow example
;----- Main Loop ----
Repeat
FlipBuffers()
ExamineKeyboard()
ExamineMouse()
mx = MouseX()
my = MouseY()
If mx < lastmx
mousegoingleft = 1
Else
If mx > lastmx
mousegoingleft = 0
Else
; mouse didn't move =)
mousegoingleft = 2
EndIf
EndIf
lastmx = mx
lastmy = my
; show the desktop
DisplaySprite(DeskTopSprite, 0, 0) ****** 2D sprite here
If Start3D()
; show the mouse cursor
If mousegoingleft
DisplaySprite3D(MouseCursor3DL, MouseX()-64, MouseY()-80)
Else
DisplaySprite3D(MouseCursor3DR, MouseX()-44, MouseY()-80)
EndIf
; show the fish
Gosub UpdateFish
; show the website logo
; If waitlogo < 5
; waitlogo = waitlogo + 0.0025
; Else
; waitlogo = waitlogo + 0.2
; EndIf
waitlogo = waitlogo + 0.8
If waitlogo < 200
;waitlogo = waitlogo + 0.25
logoposx = (Width/2)-128
logoposy = (Height/2)-128
Else
If waitlogo > 255
waitlogo = 255
EndIf
; logo hits mouse
If mx > (logoposx+128)-100
If mx < (logoposx+128)+100
If my > (logoposy+128)-50
If my < (logoposy+128)+50
logoxvel = logoxvel + (Random(100)-50)/50.0
logoyvel = logoyvel - (Random(50))/50.0
logozvel = logozvel + (Random(100)-50)/50.0
EndIf
EndIf
EndIf
EndIf
If Random(1000) > 800
logoxvel = logoxvel + (Random(100)-50)/150.0
logoyvel = logoyvel +(Random(100)-50)/150.0
logozvel = logozvel +(Random(100)-50)/150.0
EndIf
; logo darts to side
If logoposy > Height - 40
If Random(1000) > 920
logoxvel = logoxvel + (Random(100)-50)
EndIf
Else
If Random(1000) > 995
logoxvel = logoxvel + (Random(100)-50)
EndIf
EndIf
logoposx = logoposx + logoxvel
logoposy = logoposy + logoyvel
logoposz = logoposz + logozvel
If logoposx > Width-256
logoposx = Width - 256
logoxvel = 0
Else
If logoposx < 0
logoposx = 0
logoxvel = 0
EndIf
EndIf
If logoposy > Height-156
logoposy = Height-156
logoyvel = 0
Else
If logoposy < -250
logoposy = -250
logoyvel = 0
EndIf
EndIf
If logoposz > 120
logoposz = 120
logozvel = 0
Else
If logoposz < -20
logoposz = -20
logozvel = 0
EndIf
EndIf
EndIf
******** 3D sprite here
DisplaySprite3D(vrman3D,logoposx, logoposy, waitlogo)
ZoomSprite3D(vrman3D, 256-logoposz, 256-logoposz)
Stop3D()
EndIf
;---Check Inputs
Event = WindowEvent()
If KeyboardPushed(#PB_Key_Escape)
;#PB_Key_All)
result = CloseSaver(MainHWnd)
EndIf
If KeyboardPushed(#PB_Key_Subtract)
screencapture()
EndIf
; see if mouse moved out of mouse range
; todo - make option in dialog for ignore mouse
; If (mx > origmx + MouseRange) Or (mx < origmx - MouseRange) Or (my > origmy + MouseRange) Or (my > origmy + MouseRange)
; result = CloseSaver(MainHWnd)
; EndIf
ForEver
Sean