Horizontal scrolling ofa block(10x10) letters right to left?

Just starting out? Need help? Post your questions and find answers here.
User avatar
vinostien
User
User
Posts: 24
Joined: Tue May 31, 2011 1:11 am
Location: Kim

Horizontal scrolling ofa block(10x10) letters right to left?

Post by vinostien »

---Start transmission---
Hello my name is Vinostien, and new to computers, and very new to coding.
I am tring to make a fun program that will scroll right to left a block (10x20) of letters horizontal that will display my word search puzzles.
I have on idea where to start this coding at, coz the help file has nothing or I do not what it is called to look on the internet for this type of horizontal scroling.
Anything will be very helpful.

vinostien :?
Last edited by vinostien on Mon Jul 11, 2011 3:42 am, edited 1 time in total.
Nituvious
Addict
Addict
Posts: 1027
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by Nituvious »

Hi, welcome to the forums!
I hope this helps you out.

Code: Select all

Declare scrollText(text.s, x.l, y.l)

If InitSprite()
	Global myWindow = OpenWindow(#PB_Any, 0, 0, 300, 300, "Scroll", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
	OpenWindowedScreen(WindowID(myWindow), 0, 0, 300, 300, 1, 0, 0)
	
	Repeat
		ClearScreen(RGB(0,0,0))
		eventID = WaitWindowEvent(1)
		Delay(10)
		scrollText("Hello, world!", 50, 100)
		FlipBuffers()
	Until eventID = #PB_Event_CloseWindow
Else
	End
EndIf

Procedure scrollText(text.s, x.l, y.l)
	Static sprText.l, firstCall.l, newX.l, newY.l	, textWidth.l, textHeight.l
	If Not firstCall.l
		StartDrawing(WindowOutput(myWindow))
		textWidth.l = TextWidth(text.s)
		textHeight.l = TextHeight(text.s)
		StopDrawing()
		sprText.l = CreateSprite(#PB_Any, textWidth.l, textHeight.l)
		StartDrawing(SpriteOutput(sprText))
		DrawText(0, 0, text.s, RGB(0, 10, 200))
		StopDrawing()
		newX.l = x.l
		newY.l = y.l
		firstCall.l = #True
	EndIf
	
	DisplaySprite(sprText.l, newX.l, newY.l)
	
	If newX.l >= -TextWidth
		newX.l - 1
	Else
		newX.l = 300	
	EndIf

EndProcedure
▓▓▓▓▓▒▒▒▒▒░░░░░
User avatar
vinostien
User
User
Posts: 24
Joined: Tue May 31, 2011 1:11 am
Location: Kim

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by vinostien »

here is a sample of 1 of my puzzle.
B Y A L P S I D X P
U E L Z Z U P E U W
F R T P R O G R A M
F A D E L S E U R W
E L R K L B B D A I
R C A B A P J E E N
S E W S Z H M C L D
U D I G N I D O C O
D C N T A H C R C W
A N G E T I R P S O
All this needs to scroll at the same time, Hmm the spacing did not work out on here.
vinostien
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by citystate »

welcome vinostien,

don't forget to check the search function of the forums - there is a good chance someone has asked a similar question in the past.

here's one I found earlier >LINK<
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
User avatar
vinostien
User
User
Posts: 24
Joined: Tue May 31, 2011 1:11 am
Location: Kim

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by vinostien »

Hello
I did find that post and could not run it, error 'content not found' and I did not know how to change the code to work on my laptop, but the code gave me some ideas to try to fix my own code.
thanks again
vinostien
User avatar
vinostien
User
User
Posts: 24
Joined: Tue May 31, 2011 1:11 am
Location: Kim

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by vinostien »

Hmm,
Line 63: GetTickCount_() is nounction (or not available in demo version), macro, array or linked list.
Sorry, I guess I will have to upgrade to the full version to under stand this programing.

vinostien
Nituvious
Addict
Addict
Posts: 1027
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by Nituvious »

You can import or load WinAPI functions directly from the lib or dll that contains them.
▓▓▓▓▓▒▒▒▒▒░░░░░
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by Demivec »

vinostien wrote:Hmm,
Line 63: GetTickCount_() is nounction (or not available in demo version), macro, array or linked list.
Sorry, I guess I will have to upgrade to the full version to under stand this programing.
Upgrading is not a bad option. You can also just substitute the native ElapsedMilliseconds() function for GetTickCount_().
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by netmaestro »

If you want to avoid using DirectX, the canvas gadget is a good choice for something like this. Unfortunately, the Canvas gadget is not available in the demo yet. Here is code for it:

Code: Select all

OpenWindow(0,0,0,640,640,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_Invisible)
LoadFont(0, "courier new", 10, #PB_Font_Bold|#PB_Font_HighQuality)

brush = CreateImage(#PB_Any,20,20)
StartDrawing(ImageOutput(brush))
  Box(0,0,20,20,#White)
  Box(0,0,10,10,RGB(220,220,220))
  Box(10,10,10,10,RGB(220,220,220))
StopDrawing()

Global cBrush = CreateImage(#PB_Any,640,200)
StartDrawing(ImageOutput(cBrush))
  For j=0 To 180 Step 20
    For i = 0 To 620 Step 20
      DrawImage(ImageID(brush),i,j)
    Next
  Next
StopDrawing()

hBrush = CreatePatternBrush_(ImageID(brush))
SetClassLong_(WindowID(0),#GCL_HBRBACKGROUND,hbrush)

HideWindow(0,0)

CanvasGadget(0,0,439,640,200)

CreateImage(0, 200, 200, 32|#PB_Image_Transparent)
StartDrawing(ImageOutput(0))
  DrawingMode(#PB_2DDrawing_AllChannels)
  DrawingFont(FontID(0))
  For j = 0 To 180 Step 20
    For i=0 To 180 Step 20
      Read.b a.b
      DrawText(i,j,Chr(a),RGBA(0,0,0,255),RGBA(0,0,0,0))
    Next
  Next
StopDrawing()

Procedure ReDraw(uID, uMsg, dwUser, dw1, dw2)
  Static x=0
  x+1:If x>=640:x=0:EndIf
  If IsGadget(0) And IsImage(cBrush) And IsImage(0)
    StartDrawing(CanvasOutput(0))
      DrawImage(ImageID(cbrush),0,0)
      DrawAlphaImage(ImageID(0),x,0)
      If x>440
        GrabImage(0,1,640-x,0,200-(640-x),200)
        If IsImage(1) : DrawAlphaImage(ImageID(1),0,0) : EndIf
      EndIf
    StopDrawing()  
  EndIf
EndProcedure

tid = timeSetEvent_(12,1,@ReDraw(),0,#TIME_PERIODIC|$100)

Repeat
  
  EventID = WaitWindowEvent()
  
Until EventID = #PB_Event_CloseWindow 
timeKillEvent_(tid)
End

DataSection
  Data.b 'B', 'Y', 'A', 'L', 'P', 'S', 'I', 'D', 'X', 'P' 
  Data.b 'U', 'E', 'L', 'Z', 'Z', 'U', 'P', 'E', 'U', 'W' 
  Data.b 'F', 'R', 'T', 'P', 'R', 'O', 'G', 'R', 'A', 'M' 
  Data.b 'F', 'A', 'D', 'E', 'L', 'S', 'E', 'U', 'R', 'W' 
  Data.b 'E', 'L', 'R', 'K', 'L', 'B', 'B', 'D', 'A', 'I' 
  Data.b 'R', 'C', 'A', 'B', 'A', 'P', 'J', 'E', 'E', 'N' 
  Data.b 'S', 'E', 'W', 'S', 'Z', 'H', 'M', 'C', 'L', 'D' 
  Data.b 'U', 'D', 'I', 'G', 'N', 'I', 'D', 'O', 'C', 'O' 
  Data.b 'D', 'C', 'N', 'T', 'A', 'H', 'C', 'R', 'C', 'W' 
  Data.b 'A', 'N', 'G', 'E', 'T', 'I', 'R', 'P', 'S', 'O'
EndDataSection
And since you can't compile it with the demo, here's the result for you to run: http://lloydsplace.com/puzzletest.exe
BERESHEIT
User avatar
vinostien
User
User
Posts: 24
Joined: Tue May 31, 2011 1:11 am
Location: Kim

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by vinostien »

Wow that is nice, I like what you did in that coding, however I am so new to the programing that I still have not decided to pay for the full code yet, I would like to learn a bit more about coding before I buy it.

thanks again
vinostien
User avatar
vinostien
User
User
Posts: 24
Joined: Tue May 31, 2011 1:11 am
Location: Kim

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by vinostien »

Hello

Where is a good place to get PureBasic samples that I may download and look at and play with, they must beable to run on the free ver of PB?

thanks
vinostien
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by netmaestro »

Here's the same program with adjustments to make it run on the demo version of Purebasic 4.51:

Code: Select all

; First take steps to make the code "Demo Friendly":

Prototype patternbrush(imageid.l)
OpenLibrary(0, "gdi32.dll")
CreatePatternBrush.patternbrush = GetFunction(0, "CreatePatternBrush")

Prototype setclasslong(hwnd.l, index.l, newclassbits.l)
OpenLibrary(1, "user32.dll")
SetClassLong.setclasslong = GetFunction(1, "SetClassLongA")

Prototype timesetevent(uDelay.l, uResolution.l, lpTimeProc.l, dwUser.l, fuEvent.l)
Prototype timeKillEvent(event.l)
OpenLibrary(2, "winmm.dll")
timeSetEvent.timesetevent = GetFunction(2, "timeSetEvent")
timeKillEvent.timekillevent = GetFunction(2, "timeKillEvent")

#GCL_HBRBACKGROUND = -10
#TIME_PERIODIC = $1

; Now for the program:

OpenWindow(0,0,0,640,640,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu|#PB_Window_Invisible)
LoadFont(0, "courier new", 10, #PB_Font_Bold|#PB_Font_HighQuality)

brush = CreateImage(#PB_Any,20,20)
StartDrawing(ImageOutput(brush))
Box(0,0,20,20,RGB(255,255,255))
Box(0,0,10,10,RGB(220,220,220))
Box(10,10,10,10,RGB(220,220,220))
StopDrawing()

Global cBrush = CreateImage(#PB_Any,640,200)
StartDrawing(ImageOutput(cBrush))
For j=0 To 180 Step 20
  For i = 0 To 620 Step 20
    DrawImage(ImageID(brush),i,j)
  Next
Next
StopDrawing()

hBrush = CreatePatternBrush(ImageID(brush))
SetClassLong(WindowID(0),#GCL_HBRBACKGROUND,hbrush)

HideWindow(0,0)

CreateImage(0, 200, 200, 32|#PB_Image_Transparent)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
DrawingFont(FontID(0))
For j = 0 To 180 Step 20
  For i=0 To 180 Step 20
    Read.b a.b
    DrawText(i,j,Chr(a),RGBA(0,0,0,255),RGBA(0,0,0,0))
  Next
Next
StopDrawing()

ImageGadget(0,0,439,640,200,ImageID(0))

Procedure ReDraw(uID, uMsg, dwUser, dw1, dw2)
  Static x=0
  x+1:If x>=640:x=0:EndIf
  If IsGadget(0) And IsImage(cBrush) And IsImage(0)
    CreateImage(1, 640,200)
    StartDrawing(ImageOutput(1))
    DrawImage(ImageID(cbrush),0,0)
    DrawAlphaImage(ImageID(0),x,0)
    If x>440
      GrabImage(0,2,640-x,0,200-(640-x),200)
      If IsImage(2) : DrawAlphaImage(ImageID(2),0,0) : EndIf
    EndIf
    StopDrawing()  
    SetGadgetState(0, ImageID(1))
  EndIf
EndProcedure

tid = timeSetEvent(12,1,@ReDraw(),0,#TIME_PERIODIC|$100)

Repeat
  
  EventID = WaitWindowEvent()
  
Until EventID = #PB_Event_CloseWindow 
timeKillEvent(tid)

For i=0 To 2
  If IsLibrary(i)
    CloseLibrary(i)
  EndIf
Next

End

DataSection
  Data.b 'B', 'Y', 'A', 'L', 'P', 'S', 'I', 'D', 'X', 'P' 
  Data.b 'U', 'E', 'L', 'Z', 'Z', 'U', 'P', 'E', 'U', 'W' 
  Data.b 'F', 'R', 'T', 'P', 'R', 'O', 'G', 'R', 'A', 'M' 
  Data.b 'F', 'A', 'D', 'E', 'L', 'S', 'E', 'U', 'R', 'W' 
  Data.b 'E', 'L', 'R', 'K', 'L', 'B', 'B', 'D', 'A', 'I' 
  Data.b 'R', 'C', 'A', 'B', 'A', 'P', 'J', 'E', 'E', 'N' 
  Data.b 'S', 'E', 'W', 'S', 'Z', 'H', 'M', 'C', 'L', 'D' 
  Data.b 'U', 'D', 'I', 'G', 'N', 'I', 'D', 'O', 'C', 'O' 
  Data.b 'D', 'C', 'N', 'T', 'A', 'H', 'C', 'R', 'C', 'W' 
  Data.b 'A', 'N', 'G', 'E', 'T', 'I', 'R', 'P', 'S', 'O'
EndDataSection
BERESHEIT
User avatar
vinostien
User
User
Posts: 24
Joined: Tue May 31, 2011 1:11 am
Location: Kim

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by vinostien »

Hello.
Where is a good place to get PureBasic samples that I may download and look at and play with, they must beable to run on the free ver of PB?
I am stil having trouble with the coding, I have run out of info and samples to play with.
any help would be nice
thanks vinostien.
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by Bisonte »

PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
Zach
Addict
Addict
Posts: 1675
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Horizontal scrolling ofa block(10x10) letters right to l

Post by Zach »

I think you should also do some light/medium reading

Please read this - PureBasic Survival Guide

Also, read this book.

PureBasic - A Beginner's Guide To Programming

I know you are very excited about trying to get your idea working in a program, and maybe you have had an interest in it for a while... But I guarantee you that if you put your idea on hold, and spend just 1 week reading both the Survival Guide, and the eBook, you will understand a whole lot more, and be in a much better position to decide if PureBasic and/or Programming in any language, is for you. The eBook in particular will introduce you to the GUI system and how to program with it properly, it really helped me to understand some new stuff.

I'm not "new" to Programming as I tried to learn many times over the years, but when I decided to go with PureBasic, both these links made a lot of it much easier.
I'm sure they will help you too. Hopefully you won't run into too many problems getting any code from the Survival Guide & Book to run with the Demo version, but if you do let us know and we'll try to help get it running for you.
Post Reply