| View previous topic :: View next topic |
| Author |
Message |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Tue Sep 20, 2005 12:36 am Post subject: idea for sidescrolling |
|
|
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 |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Tue Sep 20, 2005 9:49 am Post subject: |
|
|
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 |
|
 |
soulphalanx
Joined: 22 Aug 2005 Posts: 35
|
Posted: Tue Sep 20, 2005 1:15 pm Post subject: |
|
|
| wanna post? |
|
| Back to top |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Tue Sep 20, 2005 10:18 pm Post subject: |
|
|
@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 |
|
 |
skar
Joined: 20 Sep 2005 Posts: 6
|
Posted: Wed Sep 21, 2005 12:45 am Post subject: |
|
|
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 |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Wed Sep 21, 2005 1:22 am Post subject: should be fixed now |
|
|
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 |
|
 |
skar
Joined: 20 Sep 2005 Posts: 6
|
Posted: Wed Sep 21, 2005 3:07 am Post subject: |
|
|
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 |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Wed Sep 21, 2005 3:13 am Post subject: |
|
|
| 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 |
|
 |
Giuliano
Joined: 13 Sep 2005 Posts: 78
|
Posted: Wed Sep 21, 2005 6:08 am Post subject: |
|
|
| 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 |
|
 |
|