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 

idea for sidescrolling

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



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Tue Sep 20, 2005 12:36 am    Post subject: idea for sidescrolling Reply with quote

well its not only an idea (will try it when i am done with bomberman)

here some idea of the code
note: works already, but got still a bug when the value displayed onscreen(upper one hits 500|1000|1500..which are the limits of the images....)... hell WHY?
(only tested on lp-win32)
Code:

--load the images

layer = {
   buffer = Image.createEmpty(480, 272)
}

slices = {
   Image.load("slice1.png"), --500x272px
   Image.load("slice2.png"), --500x272px
   Image.load("slice3.png")  --500x272px
}

-- 0..1500
shade = {
   start=0,
   ende=480
}
drawslices = 0

function limited(val)
   val = math.ceil(val/500)
   if val>table.getn(slices) or val==0 then
      return 1
   end
   return val
end

while not Controls.read():start() do
   shade.ende = shade.ende+1
   shade.start = shade.start+1
   if shade.ende>=1500 then
      shade.ende=0
   end
   if shade.start>=1500 then
      shade.start=0
   end
   --move the background to left
   
   layer.buffer:clear()
   drawslices = 500-math.mod(shade.start,500)
   layer.buffer:blit(0,0,slices[limited(shade.start)],math.mod(shade.start,500),0,drawslices,272)
   layer.buffer:blit(drawslices,0,slices[limited(shade.ende)],0,0,math.mod(shade.ende,500),272)
   layer.buffer:print(25, 100,shade.start ,Color.new(255,0,46))
   layer.buffer:print(25, 110,shade.ende ,Color.new(255,0,46))
   -- update screen
   screen:blit(0,0,layer.buffer)
   screen.flip()
end

1) would be nice if someone shows me the bug
2) would be great if someone can use the code as an base for sidescroller (as i got an idea HOW to use it ;) )

greets
LuMo, who is interested, why this code flickers sometimes
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
Giuliano



Joined: 13 Sep 2005
Posts: 78

PostPosted: Tue Sep 20, 2005 9:49 am    Post subject: Reply with quote

You need to wait for vBlank to stop the flickering ..
The image size restraints are inconvinient but I have already coded a tile engine and an isometric tile engine that creates the "slices" and puts them together.. it's not that hard, just takes a bit of trial and error until you get it all lined up correctly
Back to top
View user's profile Send private message
soulphalanx



Joined: 22 Aug 2005
Posts: 35

PostPosted: Tue Sep 20, 2005 1:15 pm    Post subject: Reply with quote

wanna post?
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Tue Sep 20, 2005 10:18 pm    Post subject: Reply with quote

@Giuliano
1) this is not supposed to be a "tile" engine...
1.2) tiles of 500x272 (larger than psp-display) would make no sense...
2) the vBlank is not required (same results with vBlank)
2.1) it does NOT flicker!
2.2) it flashes just when the images are swapped @500|1000|1500

you can download the whole ready2run-package at my homepage
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
skar



Joined: 20 Sep 2005
Posts: 6

PostPosted: Wed Sep 21, 2005 12:45 am    Post subject: Reply with quote

Thank you Lumo for your help on my thread...
Your code works very well, I will use it for my scrolling game.

I don't understand why the screen flash @500l1000 but not 1500 for me.

If I used it and find a solution I will let you know.
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Sep 21, 2005 1:22 am    Post subject: should be fixed now Reply with quote

i guess i got the little bug (was really little)

i uploaded the updated archive to my webpage!

greets
Lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
skar



Joined: 20 Sep 2005
Posts: 6

PostPosted: Wed Sep 21, 2005 3:07 am    Post subject: Reply with quote

501 a little...

For me it is now ok the problem was the scrolling background, the speed is ok now and I use your code to deal with it.

Thanx
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Sep 21, 2005 3:13 am    Post subject: Reply with quote

skar wrote:

For me it is now ok the problem was the scrolling background, the speed is ok now and I use your code to deal with it.

you can adjust the speed... change the increase to 0.5 or whatever
(keypressed...)

btw, fine to see your problems gone :)

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
Giuliano



Joined: 13 Sep 2005
Posts: 78

PostPosted: Wed Sep 21, 2005 6:08 am    Post subject: Reply with quote

Sorry I didn't try to use the code or have much time to really look at it.. I was just giving general solutions
Back to top
View user's profile Send private message
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