Dark Bit Factory & Gravity
PROGRAMMING => Purebasic => Topic started by: waste on June 09, 2016
-
hi all,
i managed to use the PurebasicUserlib by eNeRGy/dAWN PtkRplay in order to play / locate postion , row with ptp music modules
i would like to start scrolltexts, rasterbars , all graphical stuff based on music rythm ,
how do you deal with that in your intros / demos ? using timers ?
i tryied with conditions like
If Ptk_GetPosition() > 1 And Ptk_GetRow() =1
drawstars()
EndIf
but it's getting hard when adding more effects ... , i use Mp3d lib and EP_fxlib ,
i can have rasters/ sinusscroll / starfield simulteanously , without trying to set them on music ,
for example , my main loop looks like that
Repeat
event =WindowEvent()
MP_AmbientSetLight (RGB(0,0,40))
EP_Move32Scroll(0)
EP_2DStarsDraw()
EP_DisplayRasterBar(0,30)
EP_DisplayRasterBar(1,450)
Until GetAsyncKeyState_(#VK_ESCAPE)
scroll , rasters and stars must be in a loop ,
so i tried :
Procedure DrawStars()
Repeat
event=WindowEvent()
EP_2DStarsDraw()
MP_RenderWorld()
MP_Flip ()
Until Ptk_GetPosition() =20
EndProcedure
when ptk position is = 20 , stars don't stop ... and if i set a scrolltext to start at postion 3 , i think it starts but no display ( to much MP_Flip() perhaps
so i don't know wich way i should choose, select/case , While / wend ? ......
-
Well, hard to tell why it's not working from just the small snippets you provided. I created a small working example for myself and everything works fine. It stops/starts the starfield and finally exits when position=4. Maybe saving the result of Ptk_GetPosition in a global variable (i.e. position=Ptk_GetPosition() ) will already do the trick in your case... Anyway, here's my example. ZIP con exe attached. (Assumes you have the userlib installed already for everyone else!)
Pad.
MAX_STAR=500
STAR_SPEED=6
Global Dim star_x.l(MAX_STAR)
Global Dim star_y.l(MAX_STAR)
Global Dim star_z.l(MAX_STAR)
Global speed=4
InitSprite() : InitKeyboard()
OpenWindow(1, 0, 0, 800, 600, "Ptk_GetPosition() Example", #PB_Window_ScreenCentered )
OpenWindowedScreen(WindowID(1), 0, 0, 800, 600, 0, 0, 0)
Ptk_InitDriver(GetForegroundWindow_(),20)
Ptk_InitModule(?tune,0)
Ptk_Play()
Procedure rnd(min.w,max.w)
a = max - Random (max-min)
ProcedureReturn a
EndProcedure
Procedure setup_stars()
For c.w=0 To 500
star_x(c)= Rnd(-600/2,800/2) << 6
star_y(c)= Rnd(-600/2,800/2) << 6
star_z(c)=Rnd(2,255)
Next
EndProcedure
Procedure UpdateStar()
For c=0 To 500
star_z(c)=star_z(c)-speed
If star_z(c)<=2
star_z(c)=255
EndIf
s_x=(star_x(c)/star_z(c))+(800/2)
s_y=(star_y(c)/star_z(c))+(600/2)
col=255-star_z(c)
FrontColor (RGB(col,col,col))
Box (s_x,s_y,3,3)
Next
EndProcedure
setup_stars()
Repeat
ClearScreen(RGB(0,0,0))
WaitWindowEvent(1)
StartDrawing(ScreenOutput())
position=Ptk_GetPosition()
If position=1 : speed=0 : EndIf
If position=2 : speed=4 : EndIf
If position=3 : speed=0 : EndIf
updatestar()
StopDrawing()
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape) Or position=4
Ptk_Stop()
Ptk_ReleaseDriver()
End
DataSection
tune:
IncludeBinary "Comic Bakery Remix.ptp"
EndDataSection
-
:)
it starts now ! as same time you posted your code,
here is mine without data section and init stuff from beginning, just main loop and procedures
Procedure DrawStars()
event=WindowEvent()
EP_2DStarsDraw()
EndProcedure
Procedure DrawSineScroll()
event=WindowEvent()
EP_Move32Scroll(0)
EndProcedure
Procedure DrawRasters()
event=WindowEvent()
EP_DisplayRasterBar(0,30)
EP_DisplayRasterBar(1,450)
EndProcedure
;-------Main-------------
Repeat
event =WindowEvent()
MP_AmbientSetLight (RGB(0,0,40))
MP_DrawText(0,0,"Position: " +Str(Ptk_GetPosition()))
If Ptk_GetPosition() >= 1
DrawStars()
EndIf
If Ptk_GetPosition() >=3
DrawSineScroll()
EndIf
If Ptk_GetPosition() >=4
DrawRasters()
EndIf
MP_RenderWorld()
MP_Flip ()
Until GetAsyncKeyState_(#VK_ESCAPE)
Ptk_Stop()
Ptk_ReleaseDriver()
End
will try with a global variable to save position and stop stars , thank you for you quick help
-
can not test :(
don't have the libs
-
attachment ProtrekkrReplay_V254.rar
very usefull lib,
-
thanks