11-02-2024, 05:39 PM
(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.