PDA

View Full Version : please help me with lua scrolling



Buddy4point0
March 27th, 2007, 00:58
hi im learning lua, but i need to find how to make and image scroll and repeat. please any1 who knows how HELP ME!

BlackShark
March 29th, 2007, 07:47
[COLOR="DarkRed"]post ur code...[/CKLOR]

Buddy4point0
March 30th, 2007, 03:21
lol y.
all i needed to know was the function to scoll. which i found

Gizmo356
March 30th, 2007, 03:24
Something like

if player.x>50 then
bg.x=bg.x-2
end

Buddy4point0
March 30th, 2007, 03:28
yea i figured that out thanks

Buddy4point0
April 6th, 2007, 21:00
ok it scrolls fine but i how do i make the picture repeat.
cause right now it just scrolls and leaves black

Gizmo356
April 6th, 2007, 21:02
Im not to sure how to due that but I would either but more than one background image( makes it alot harder to make background scroll ) or just have one really huge background image.

Buddy4point0
April 6th, 2007, 21:32
yea i just have it set so that there are like 10 background images in a line and the just all scroll like that. but after all 10 have scrolled past im left with black. i could just make like 1000 background varialbes but thats kinda the half ass way. im sure theres a better way

Merick Zero
April 7th, 2007, 22:02
the psp screen in 480x272 - when drawing outside that area to the right or to the left, it goes to a max of -480 and -272, to create a continuous scroll of a single image do this

set a varable as an x offset:

X_offset = 0

Blit the three images:

screen:blit(-480+X_offset, 0, image)
screen:blit(X_offset, 0, image)
screen:blit(480+X_offset, 0, image)

when the player is moving left do this:

X_offset = X_offset - 1
if X_offset < -480 then X_offset = 0 end

when moving right, use the same thing only do a +1 instead of a -1, and set it to check if it's >480

if you want to make it srcroll up and down instead, do the same except use a Y offset instead of an X

-Xandu-
April 7th, 2007, 23:03
Try this:


BG = Image.load("Bg2.png")

slide = {}

slide[1] = { x = 0, y = 0, pic = BG }
slide[2] = { x = -480, y = 0, pic = BG }
slide[3] = { x = -960, y = 0, pic = BG }

for blit_slides = 1,2 do
screen:blit(slide[blit_slides].x, slide[blit_slides].y, slide[blit_slides].pic)
oldslidesx = slide[blit_slides].x
end

for repeat_slides = 1, 2 do
if slide[repeat_slides].x > 480 then
slide[repeat_slides].x = -480
end
end

for repeat_slides = 1, 2 do
if slide[repeat_slides].x < -480 then
slide[repeat_slides].x = 480
end


Taken from my unreleased "Pokemon : Ditto's Quest".

Buddy4point0
April 9th, 2007, 19:52
cool thanks that worked. i was thinking something like that but couldnt get it right