Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scrolling Text
#4
(11-01-2024, 08:43 AM)johnno56 Wrote: Ok. Here is an "oldie" question.

Hi Johnno,

One solution using a table to hold your lines of text:

Code:
visible screen_w = 640,screen_h = 480
'Open a window
set window "Scrolling text",screen_w,screen_h
'enable double buffering
set redraw off
text = []
text_number = 0
number_of_lines = 12
##############################################################################################
#######################################   GAME LOOP  #########################################
##############################################################################################
do

'clear the screen
set color 255,255,255
cls
set color 0,0,0

if keydown(KEY_SPACE,true)
    text[sizeof(text)] = "line " + str(text_number)
    text_number = text_number + 1
endif

if sizeof(text) > 0
   
    set justification left
   
    for t = 0 to sizeof(text) - 1
        if sizeof(text) > number_of_lines
            set caret 20, 10  - (sizeof(text)- number_of_lines) * screen_h / number_of_lines + t * screen_h / number_of_lines
        else
            set caret 20,10 + t * screen_h / number_of_lines
        endif
       
        write text[t]
     
    next
endif

set caret 600,20
set justification right
write "PRESS SPACE BAR TO ADD A LINE OF TEXT"

'copy back buffer to the screen
redraw
'cap FPS to 60
fwait 60

until keydown(KEY_ESCAPE)

#########################################################################################
#################################  FUNCTIONS  ###########################################
#########################################################################################

There will of course be more elegant solutions, and I may have misunderstood your question, so I look forward to seeing alternatives....

Please let me know if there are other things needed for this task?

All the best - Kevin.
Reply


Messages In This Thread
Scrolling Text - by johnno56 - 11-01-2024, 08:43 AM
RE: Scrolling Text - by kevin - 11-01-2024, 02:37 PM
RE: Scrolling Text - by Marcus - 11-01-2024, 09:02 PM
RE: Scrolling Text - by kevin - 11-02-2024, 05:39 PM
RE: Scrolling Text - by johnno56 - 11-03-2024, 04:09 AM
RE: Scrolling Text - by kevin - 11-03-2024, 05:02 AM
RE: Scrolling Text - by johnno56 - 11-03-2024, 08:03 AM
RE: Scrolling Text - by kevin - 11-03-2024, 02:53 PM
RE: Scrolling Text - by johnno56 - 11-03-2024, 07:07 PM
RE: Scrolling Text - by 1micha.elok - 11-04-2024, 01:08 AM
RE: Scrolling Text - by kevin - 11-04-2024, 02:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)