How to do a fluid scrolling

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
fafenstein
Posts: 10
Joined: Mon Dec 12, 2005 8:38 pm

How to do a fluid scrolling

Post by fafenstein »

Hi there,

first i introduce myself :
I'm french about 30 and i don' t know anything in programing....

I'm try to do a text scrolling in lua by using exemple find on this site (shine) and wiki one.

For the font code i use this one :


-- Global Variables
font = Image.load("bmf02_007.png")
LetterPixelsWide = 8
LetterPixelsTall = 8
InputString = [[ !"#$%&'()* ,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ]]

--Functions
function char2font(char_input)

IndexNumber = 0
for i = 1, string.len(InputString) do
if string.sub(InputString, i,i) == char_input then
return IndexNumber
end -- end if
IndexNumber = IndexNumber + LetterPixelsWide
end -- end if
return 0
end -- char2font
function blitChar(target, char, posx, posy)
target:blit(posx,posy, font,char2font(char),0,LetterPixelsWide,LetterPixelsTall,true)
end -- blitChar
function blitString(myTarget, possx, possy, thestring)
incX = 0
for w = 1, string.len(thestring) do
blitChar(myTarget, string.upper(string.sub(thestring, w,w)), possx + incX, possy)
incX = incX + LetterPixelsWide
end -- end for
end -- blitString

--main program
blitString(screen, 10, 10, "Hello World")
screen:flip()
screen.waitVblankStart(600)

---------------------------------------------------------

First problem :

-It' s impossible to lua to load a pgn bigger than PSP screen size, when i load a pgn how is 16*1136 for exemple lua say : "impossible to load image" or a thing like that.....



For scroll i use the exemple of wiki :


---------------------------------------------------------
System.usbDiskModeActivate()
green = Color.new(0, 255, 0)
time = 0
pi = math.atan(1) * 4
while true do
screen:clear()

x = math.sin(pi * 2 / 360 * time) * 150 + 192.5
screen:print(x, 100, "Hello World!", green)
time = time + 1
if time >= 360 then
time = 0
end

screen.waitVblankStart()
screen.flip()

pad = Controls.read()
if pad:start() then
break
end
end
-----------------------------------------------------------

-Animation of my scroll is a pure crap and mybee give epilepsy crisis to how want try to read it.....

Thx in advance to anyone how can answers to this 2 questions and can help me....


Sorry for my crapy english.
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

first problem's answer:
its not possible to load a images bigger than 512*512 yet.
NOTE: you can add some code to the char2font-function, which does nothing more than entering line 2 when you are further than 512 px.
(use mod to do that)

second problem's answer:
if your scrolling is not smooth... check the sample code on my webpage;
there you can find some really basic things, and some more advanced ones too...

still some questions?
shoot!

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
fafenstein
Posts: 10
Joined: Mon Dec 12, 2005 8:38 pm

Post by fafenstein »

Ok thx 4 answer i will go on your web page to lurn some good tips but i ever go on your site (good one) but i never arrive to make work your windows lua player... ;).

If anyone can allready give here a good code for scrolling, don't hesite....

Can we use a font gif whith 2 or more levels ???

I explain :
Not : 123456789 azertyuiop^qsdfghjklmwxcvbn,;,

but :
123456789
azertyuiop
qsdfghjklm

I hope you will understand me.....
Last edited by fafenstein on Wed Dec 28, 2005 8:26 pm, edited 1 time in total.
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

thats what i meant by using math->mod
modulo, which would wrap into a new line...

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
fafenstein
Posts: 10
Joined: Mon Dec 12, 2005 8:38 pm

Post by fafenstein »

Ho yes sorry !!!
I don' t see it in your first post...

Anyway i'm not abble to do this thing whithout exemple . ;b ...
fafenstein
Posts: 10
Joined: Mon Dec 12, 2005 8:38 pm

Post by fafenstein »

So finaly i keep old code because your news isn't beter...

And it was too hard to change font.pgn in new i don't understand the code....

function char2font(char_input)
if char_input == '' or char_input==nil then
--print('empty string or nil')
return 0
else
char = string.byte(char_input)
if char>=65 and char <=90 then --a..z return (char-65)*8+216 elseif char>=48 and char<=57 then --0..9
return (char-48)*8+103


May be some explications for newbee like me should be helpfull...

So finaly and after 9H i do a scroll in the game i do (modify to be honest), i think i loose to much time for nothing.....

Maybe after finish my job on this game i will read the lua help book...

Thx to lumo for his trying and thx for his little code how lurn me lot's of things.
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

Code: Select all

function char2font&#40;char_input&#41;
if char_input == '' or char_input==nil then
--print&#40;'empty string or nil'&#41;
return 0
else
char = string.byte&#40;char_input&#41;
if char>=65 and char <=90 then --a..z return &#40;char-65&#41;*8+216 elseif char>=48 and char<=57 then --0..9
return &#40;char-48&#41;*8+103 
the ONLY thing this part of the code does is...
return 0 if its an empty char --> nothing returned
or return the position of the character on the picture (number of pixels before the character starts.)

greets
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Post Reply