old code drawing issue

Just starting out? Need help? Post your questions and find answers here.
rootuid
User
User
Posts: 48
Joined: Sat Nov 23, 2013 11:46 am

old code drawing issue

Post 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 ?
User avatar
jacdelad
Addict
Addict
Posts: 2013
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: old code drawing issue

Post by jacdelad »

Maybe a scaling issue? Can you run it with 100% scaling?
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
rootuid
User
User
Posts: 48
Joined: Sat Nov 23, 2013 11:46 am

Re: old code drawing issue

Post 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.
User avatar
Mijikai
Addict
Addict
Posts: 1520
Joined: Sun Sep 11, 2016 2:17 pm

Re: old code drawing issue

Post 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)
rootuid
User
User
Posts: 48
Joined: Sat Nov 23, 2013 11:46 am

Re: old code drawing issue

Post 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
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 463
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: old code drawing issue

Post 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
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
Post Reply