forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to do a fluid scrolling

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
fafenstein



Joined: 12 Dec 2005
Posts: 10

PostPosted: Wed Dec 28, 2005 5:24 pm    Post subject: How to do a fluid scrolling Reply with quote

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.
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Dec 28, 2005 7:38 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
fafenstein



Joined: 12 Dec 2005
Posts: 10

PostPosted: Wed Dec 28, 2005 7:43 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Dec 28, 2005 7:57 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
fafenstein



Joined: 12 Dec 2005
Posts: 10

PostPosted: Wed Dec 28, 2005 8:25 pm    Post subject: Reply with quote

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

Anyway i'm not abble to do this thing whithout exemple . ;b ...
Back to top
View user's profile Send private message
fafenstein



Joined: 12 Dec 2005
Posts: 10

PostPosted: Thu Dec 29, 2005 5:32 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Thu Dec 29, 2005 8:04 pm    Post subject: Reply with quote

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

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group