DSLua Community
Welcome, Guest. Please login or register.
May 21, 2012, 08:27:01 PM
1371 Posts in 262 Topics by 33109 Members
Latest Member: Limewire Download
DSLua Community  |  DSLua - Best scripting language for Nintendo DS  |  Need Help?  |  Problems with a function to load backgrounds(maps) « previous next »
Pages: [1]
Author Topic: Problems with a function to load backgrounds(maps)  (Read 1044 times)
suloku
New Moon
*
Posts: 8


« on: June 19, 2007, 01:57:35 PM »

[UPDATE]
I've just figured out, you only can scroll throughout the dimensions you set in the LoadMap function, as I had this space filled I can't scroll the image.
[/UPDATE]

[UPDATE]
Right now I'm wondering if a map that has the screen size or less can be scrolled...which is totally absurd, but now I think this is the actual problem
[/UPDATE]

[UPDATE2]
WTH? I don't know why, but in 0.6 the maps are correctly processed and displayed, also seems that the scroll problem really was due to map's width and height, but in 0.7, with the correct dldi patch they have lots of graphic errors. I think that the errors weren't there when I tried the program on the DS before, so why do they appear now?

For 0.6 I'm packing the files and for 0.7 I have them in a directory on my card.
[/UPDATE]


Hi all, I've written this little function as to load maps an easy way to use them as backgrounds but I'm having some trouble:

note: the function is in another file than the main program.
Code:
function LoadBG( map, screen, width, height, text )

map_raw = map .. ".raw"
map_pal = map .. ".pal"
map = map .. ".map"

if screen == 1 then

BGTop = Screen.LoadTileBG()
BGTop:LoadPalette( map_pal )
BGTop:LoadTiles( map_raw, 256 ) -- 256 colours

if width == 0 and height == 0 then
BGTop:LoadMap( map, (256/8), (192/8) )
else
BGTop:LoadMap( map, width, height )
end

if text == 1 then
BGTopText = Screen.LoadTextBG()
Screen.Initialize( screen, BGTopText, BGTop  )

else
Screen.Initialize( screen, BGTop )
end

else

BGBot = Screen.LoadTileBG()
BGBot:LoadPalette( map_pal )
BGBot:LoadTiles( map_raw, 256 ) -- 256 colours

if width == 0 and height == 0 then
BGBot:LoadMap( map, (256/8), (192/8) )
else
BGBot:LoadMap( map, width, height )
end

if text == 1 then
BGBotText = Screen.LoadTextBG()
Screen.Initialize( screen, BGBotText, BGBot  )

else
Screen.Initialize( screen, BGBot )
end
end
end

LoadBG( map, screen, width, height, text )

map estands for the file name, then the function adds the extensions to the string and stores it in different variables.

screen is 0 or 1, 0 for bottom and 1 for top

width and height are the size of the map, if 0 is put in there, then the functions falls to default 256/8 and 192/8.

text is also a number. If it is 1 (enabled) the function loads the background after loading a text background, so we have a background capable of being printed text over.


All works fine (background displaying and printing text over it) but for some reason I can't scroll the images (256x192 both top and bottom images).

If everything is right, top map should be in BGTop and bottom one in BGBot, so to scroll the top one i'll use BGTop:ScrollXY( x, y ), but for some reason this don't seem to be working.
« Last Edit: June 20, 2007, 01:53:40 PM by suloku » Logged
manu62300
Waxing Crescent
**
Posts: 89



« Reply #1 on: July 12, 2007, 04:54:09 PM »

Good idea why not screen is 0 , 1 or 2, 0 for bottom, 1 for top and 2 for bottom + top  Wink

And Your function isn't finish...
Logged

XtreamLua.com
La Référence en programmation sur PSP & DS
xtreamlua.miniville.fr
Bon dev...;
Pages: [1]
« previous next »
    Jump to: