Page 1 of 1

old code drawing issue

Posted: Wed Aug 30, 2023 7:01 pm
by rootuid
I'm looking at some old code viewtopic.php?p=444710#p444710 written by oreopa in 2014

Code: Select all

Global Dim a_PAL(15) ; pepto palette
a_PAL(0) = $000000
a_PAL(1) = $FFFFFF
a_PAL(2) = $2B3768
a_PAL(3) = $B2A470
a_PAL(4) = $863D6F
a_PAL(5) = $438D58
a_PAL(6) = $792835
a_PAL(7) = $6FC7B8
a_PAL(8) = $254F6F
a_PAL(9) = $003943
a_PAL(10) = $59679A
a_PAL(11) = $444444
a_PAL(12) = $6C6C6C
a_PAL(13) = $84D29A
a_PAL(14) = $B55E6C
a_PAL(15) = $959595

If InitSprite()
	If OpenWindow(0, 0, 0, 820, 620, "Old School Decrunch Effect...", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
		If OpenWindowedScreen(WindowID(0), 10, 10, 800, 600, #True, 10, 10, #PB_Screen_NoSynchronization) ; x, y position, width, height, autostretch
			If CreateSprite(1,ScreenWidth(),256*2)
				If StartDrawing(SpriteOutput(1))
						For y = 0 To OutputHeight()-2 Step 2
							Box(0,y,OutputWidth(),2,a_pal(Random(15)))
						Next y
					StopDrawing()
				EndIf
				
				Repeat
					Repeat
						MyEvent = WindowEvent()
						If MyEvent = #PB_Event_CloseWindow
							Quit = #True
							Break
						EndIf
					Until MyEvent = 0
					
					FlipBuffers()
					If IsScreenActive()
						ClearScreen(0)
						
						For a = 0 To ScreenHeight()-1 Step 4
							x=0
							While x<ScreenWidth()
								length = Random(ScreenWidth()/8)
								ClipSprite(1,0,Random(256)*2,length,2)
								DisplaySprite(1,x,a)
								x+length
							Wend
						Next a
					StopDrawing()
					Delay(Random(100))
					
				EndIf
			Until Quit = #True
		EndIf
	EndIf
EndIf
EndIf

which executes but only runs in the bottom left corner of the screen.

Image

Why is that? I'm guessing something has changed in the Purebasic syntax since the code was first written many years ago?

Or is it a Mac issue as I'm running on a Mac ?

Re: old code drawing issue

Posted: Wed Aug 30, 2023 7:37 pm
by jacdelad
Maybe a scaling issue? Can you run it with 100% scaling?

Re: old code drawing issue

Posted: Wed Aug 30, 2023 10:57 pm
by rootuid
Thanks for your suggestion jacdelad. The application starts in a window but only renders in the bottom left corner but when I maximise the window the effect takes over the full screen which is what I was looking for. Thanks.

Re: old code drawing issue

Posted: Thu Aug 31, 2023 4:08 pm
by Mijikai
I suspect that a event is missing.

You can try to add this call after the screen is created:

Code: Select all

ResizeWindow(0,#PB_Ignore,#PB_Ignore,#PB_Ignore,#PB_Ignore)

Re: old code drawing issue

Posted: Tue Jul 16, 2024 12:47 am
by rootuid
Same code , different version (PureBasic 6.11 LTS - C Backend (MacOS X - arm64)) of Purebasic and it works.

I think it a bug fixed here https://www.purebasic.fr/english/viewtopic.php?t=83613

Re: old code drawing issue

Posted: Tue Jul 16, 2024 8:21 am
by Mindphazer
rootuid wrote: Tue Jul 16, 2024 12:47 am Same code , different version (PureBasic 6.11 LTS - C Backend (MacOS X - arm64)) of Purebasic and it works.

I think it a bug fixed here https://www.purebasic.fr/english/viewtopic.php?t=83613
Exactly