Any Ideas on how to get the bbkeydown event check
working in purebasic. I think it has something to
do with a callback but I'm not quite sure how to
make it work?
just save the code into the directory with the purebasic
examples
working in purebasic. I think it has something to
do with a callback but I'm not quite sure how to
make it work?
just save the code into the directory with the purebasic
examples
; PureBasic Visual Designer v3.95 build 1485 (PB4Code) Enumeration #Window_0 EndEnumeration ;- Gadget Constants ; Enumeration #Button_0 #Image_2 EndEnumeration ;- Image Plugins ;- Image Globals Global Image0 ;- Catch Images Image0 = CatchImage(0, ?Image0) ;- Images DataSection Image0: IncludeBinary "boing.png" EndDataSection Procedure Open_Window_0() If OpenWindow(#Window_0, 209, -11, 1024, 768, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar ) If CreateGadgetList(WindowID(#Window_0)) ButtonGadget(#Button_0, 900, 20, 45, 25, "") ImageGadget(#Image_2, 128, 24, 800, 600, Image0) EndIf EndIf EndProcedure Declare blitzroutine() Open_Window_0() ; Play with this value! #NUM_CUBES = 200 ; 1000 - 2000 fine here on Core 2 Duo 6300 / Geforce 6800 GS ; Include Blitz3D engine... IncludeFile "blitz3dsdk.pbi" bbSetBlitz3DHWND ( WindowID(#Window_0)) ; Initialise Blitz3D engine... bbBeginBlitz3D () ; Set debug mode (it's on by default -- just added this so you can turn it off)... bbSetBlitz3DDebugMode (0) ; 1 = DEBUG ON, 0 = DEBUG OFF ; Open dislay... bbGraphics3D (800,600,32,2 ) ; Camera... Global cam = bbCreateCamera () bbCameraClsColor (cam, 64, 128, 180) bbCameraRange (cam, 0.1, 1000) bbMoveEntity (cam, 0, 5, 0) ; Light... light = bbCreateLight () bbMoveEntity (light, -10, 5, -1) ; Grass... grasstex = bbLoadTexture ("grass.png") plane = bbCreatePlane () bbEntityTexture (plane, grasstex) ; Cube (will be hidden and 20 copies made)... cubetex = bbLoadTexture ("boing.png") Global cube = bbCreateCube () bbMoveEntity (cube, 0, 0, 5) bbEntityTexture (cube, cubetex) bbHideEntity (cube) ; Point light to centre of world... bbPointEntity (light, cube) ; Create duplicates of cube entity... Global Dim cubes (#NUM_CUBES) For dupe = 1 To #NUM_CUBES cubes (dupe) = bbCopyEntity (cube) bbPositionEntity (cubes (dupe), Random (50) - 25, Random (25) + 2, Random (50)) bbTurnEntity (cubes (dupe), Random (720) - 360, Random (720) - 360, Random (720) - 360) Next Repeat ; Start of the event loop blitzroutine() Event = WindowEvent() ; This line waits until an event is received from Windows If Event<>0 WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures GadgetID = EventGadget() ; Is it a gadget event? EventType = EventType() ; The event type ;You can place code here, and use the result as parameters for the procedures If Event = #PB_Event_Gadget If GadgetID = #Button_0 ElseIf GadgetID = #Image_2 EndIf EndIf EndIf Until Event = #PB_Event_CloseWindow ; End of the event loop bbEndBlitz3D () End ; Procedure blitzroutine() ; Rotate all cubes... For dupe = 1 To #NUM_CUBES bbTurnEntity (cubes (dupe), 0.1, 0.2, 0.3) Next ; Camera control... ; Turn left/right... If bbKeyDown (#KEY_LEFT) bbTurnEntity (cam, 0, 1, 0) Else If bbKeyDown (#KEY_RIGHT) bbTurnEntity (cam, 0, -1, 0) EndIf EndIf ; Tilt up/down... If bbKeyDown (#KEY_UP) bbTurnEntity (cam, 1, 0, 0, 0) ; The last parameter here makes sure we rotate Else ; on the 3D world's y-axis. Change to 1 to see If bbKeyDown (#KEY_DOWN) ; the undesired effect of rotating on the entity's bbTurnEntity (cam, -1, 0, 0, 0) ; own y-axis (at least in this case)... EndIf EndIf ; Forwards/backwards... If bbKeyDown (#KEY_A) bbMoveEntity (cam, 0, 0, 0.25) Else If bbKeyDown (#KEY_Z) bbMoveEntity (cam, 0, 0, -0.25) EndIf EndIf ; Render 3D world to back buffer... bbRenderWorld () ; Show the rendered buffer (flips back buffer to front buffer)... bbFlip () EndProcedure