0% found this document useful (0 votes)
428 views

Scrolling Text For PSP Lua

This document describes Lua code for scrolling text across the screen. It defines variables for text position, color, and scroll speed. The main loop clears the screen and reads controls. A for loop extracts each character from the text string and prints it to the screen at an offset position, incrementing by the scroll speed each iteration. If the text reaches the left side, the position resets to start scrolling from the right.

Uploaded by

ahmd72
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
428 views

Scrolling Text For PSP Lua

This document describes Lua code for scrolling text across the screen. It defines variables for text position, color, and scroll speed. The main loop clears the screen and reads controls. A for loop extracts each character from the text string and prints it to the screen at an offset position, incrementing by the scroll speed each iteration. If the text reaches the left side, the position resets to start scrolling from the right.

Uploaded by

ahmd72
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

--Defining some variables -- The position from where the text should be blitted positionx=240 red=Color.

new(255,0,0) --The text that has to be scrolled text = "hello world from Lua" --The speed at which the text should be scrolled scrollspeed=4 while true do --Clear the screen at the start of the loop screen:clear() --Check for controls pad = Controls.read() --Here is the main code which is used to scroll the text --What it does is that using a for loop we define a variable i --which runs from 1 to the number of characters in the variable "text" for i=1, #text do --next another variable is defined c and using string.sub we extract one charact er from text and store it in c local c = string.sub(text,i, i) --Now we print this one the screen screen:print(positionx+i*10, 126, c, red) end --What this code does is check that if the text has reached to the left end of t he screen or not, --If not then it subtracts scrollspeed from scrollx --If it has reached the end then scrollx becomes 480 so that it scrolls from the beginning if positionx>(-#text*11) then positionx=positionx-scrollspeed else positionx=480 end screen.flip() screen.waitVblankStart() end

You might also like