idea for sidescrolling

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

Moderators: Shine, Insert_witty_name

Post Reply
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

idea for sidescrolling

Post by LuMo »

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: Select all

--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
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

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
soulphalanx
Posts: 35
Joined: Mon Aug 22, 2005 7:48 am

Post by soulphalanx »

wanna post?
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

@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
skar
Posts: 6
Joined: Tue Sep 20, 2005 9:48 am

Post by skar »

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.
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

should be fixed now

Post by LuMo »

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
skar
Posts: 6
Joined: Tue Sep 20, 2005 9:48 am

Post by skar »

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
LuMo
Posts: 410
Joined: Sun Aug 21, 2005 2:45 am
Location: Austria
Contact:

Post by LuMo »

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
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

Sorry I didn't try to use the code or have much time to really look at it.. I was just giving general solutions
Post Reply