Mixing 2d Sprites and 3D
Mixing 2d Sprites and 3D
I notice in the latest beta this apparently is now possible?. I am working on a 2D platform game using 2D sprites and would like to make use of the particle functionality already built into Purebasic 3d Engine alongside my 2d Sprites.
Is this possible?
Is this possible?
yes, it is possible
i changed few lines in the particle.pb example
i changed few lines in the particle.pb example
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - Particle
;
; (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;
#CameraSpeed = 10
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
Add3DArchive("Data", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
CreateSprite(0,64,64)
StartDrawing(SpriteOutput(0))
;Box(0,0,64,64,#Blue)
Circle(32,32,30,#Red)
StopDrawing()
LoadTexture(0, "flare.png")
CreateMaterial(0, TextureID(0))
DisableMaterialLighting(0, 1)
MaterialBlendingMode (0, #PB_Material_Add)
CreateParticleEmitter(0, 10, 1, 1, 0)
ParticleMaterial (0, MaterialID(0))
ParticleTimeToLive (0, 2, 2)
ParticleEmissionRate(0, 20)
ParticleSize (0, 30, 30)
ParticleColorRange (0, RGB(255,0,0), RGB(255,0,255))
CreateCamera(0, 0, 0, 100, 100)
CameraBackColor(0,-1)
CameraLocate(0,0,0,100)
Repeat
Screen3DEvents()
ClearScreen(RGB(0, 0, 0))
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
If ExamineMouse()
InputEvent3D(MouseX(), MouseY(), MouseButton(1), "")
PointPick(0,MouseX()+32,MouseY()+32)
MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
EndIf
;RotateCamera(0, MouseY, MouseX, RollZ, #PB_Relative)
;MoveCamera (0, KeyX, 0, KeyY)
ParticleEmitterLocate(0,CameraX(0)+PickX()*100,CameraY(0)+PickY()*100,CameraZ(0)+PickZ()*100)
RenderWorld()
Screen3DStats()
DisplayTransparentSprite(0,MouseX(),MouseY())
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
This example does not work here.
With directx9 subsystem, in windowed, the 3d seems to be behind a black screen, where's some random transparent pixels (and sometime a big part of the screen) are permitting to see the flares. By removing CameraBackColor(0,-1) it's ok.
In fullscreen, the program is hanging on createsprite(0, 64, 64) (invalid memory access) and we can't come back to the desktop :/
With directx7, the program is hanging on StartDrawing(SpriteOutput(0)) (specified sprite is not initialised), even with changing parameters of createsprite().
With directx9 subsystem, in windowed, the 3d seems to be behind a black screen, where's some random transparent pixels (and sometime a big part of the screen) are permitting to see the flares. By removing CameraBackColor(0,-1) it's ok.
In fullscreen, the program is hanging on createsprite(0, 64, 64) (invalid memory access) and we can't come back to the desktop :/
With directx7, the program is hanging on StartDrawing(SpriteOutput(0)) (specified sprite is not initialised), even with changing parameters of createsprite().
Last edited by djes on Tue Oct 07, 2008 12:57 pm, edited 1 time in total.
Well, i use subsystem directx9, and windowed mode (800x600).
I can see a sprite (red circle) and particle behind the sprite.
does original particle.pb example work, using directx9 for you ?
I can see a sprite (red circle) and particle behind the sprite.
does original particle.pb example work, using directx9 for you ?
Last edited by Comtois on Tue Oct 07, 2008 12:59 pm, edited 1 time in total.
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
i get this, and particle follow the sprite.

Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada