Auteur Sujet: Sprite between two Backgrounds  (Lu 11483 fois)

0 Membres et 2 Invités sur ce sujet

Hors ligne faeldaniel

  • Newbie
  • *
  • Messages: 34
    • Voir le profil
Sprite between two Backgrounds
« le: 21 décembre 2012 à 21:04:07 »
Watch this video:
http://www.youtube.com/watch?v=kSPknysJaVY

One of the my tests with sprites and background, it was perfect  ;), would like to put an the spriter BG0 between BG1 and in this example it stayed behind the BG0 and BG1, this is part of my code:

// Copy tiles to VRAM
bgInitTileSet(1, &patterns_bg, &palette_bg, 3, (&patterns_end_bg - &patterns_bg), (&palette_end_bg - &palette_bg), BG_16COLORS, 0x6000);
bgInitTileSet(0, &patterns_fence, &palette_fence, 4, (&patterns_end_fence - &patterns_fence), (&palette_end_fence - &palette_fence), BG_16COLORS, 0x5000);

// Copy Map to VRAM
bgInitMapSet(1, &map_bg, (&map_end_bg - &map_bg),SC_32x32, 0x4800);
bgInitMapSet(0, &map_fence, (&map_end_fence - &map_fence),SC_32x32, 0x4000);

//My Char Kyle Blackthorne
oamInitGfxSet(&gfxpsrite_kyle_1, (&gfxpsrite_end_kyle_1 - &gfxpsrite_kyle_1), &palsprite_kyle_1, 0, 0x0000, OBJ_SIZE32);
oamSet(0,  mycharKyle.x, mycharKyle.y, 0, 0, 0, sprTiles[mycharKyle.positionOffSetSpriter], 0);
oamSetEx(0, OBJ_LARGE, OBJ_SHOW);

setMode(BG_MODE1, 0);  bgSetDisable(2);

With this code he stands in front of all background

oamSet(0,  mycharKyle.x, mycharKyle.y, 3, 0, 0, sprTiles[mycharKyle.positionOffSetSpriter], 0);
I would like to stay sprite between background.  ;D
« Modifié: 21 décembre 2012 à 22:53:22 par faeldaniel »

Hors ligne ccc

  • Newbie
  • *
  • Messages: 24
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #1 le: 04 janvier 2013 à 13:03:35 »
I have not tested but following the instructions of the wiki the priority parameter of the oamSet function is relative to the BG
Citer
priority    priority relative to BG : 0 for Low and 3 is the highest
In your code your backgrounds are numbered 0 and 1.
Your first test the priority at 0 masks you hide your sprites (lowest priority)
Your 2nd test the priority set to high (3) show you the sprites.
So my guess is if you set the priority to 1 your sprite will be between the both BG.

With 3 layers, noted 0,1,2 I supposed than that priority parameter can be set to 2 for example : It's not a binary (0 or 3) value, you can use 0,1,2 or 3  ;)

I hope alekmaul will confirm that point.

PS : sorry for my awful english  :-[

Hors ligne faeldaniel

  • Newbie
  • *
  • Messages: 34
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #2 le: 04 janvier 2013 à 18:59:19 »
had already read it, I thought this was only for the priority Gfxs (sprites) and did not work with the BGS, now that quoted calmly read again the documentation can be really so, however I believe that had already tried.

priority =  priority relative to BG : 0 for Low and 3 is the highest
test again and post the result

Hors ligne faeldaniel

  • Newbie
  • *
  • Messages: 34
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #3 le: 04 janvier 2013 à 19:54:41 »
Thanks Brother it worked perfectly, I believe that had not achieved because the MODE1 the Bg 3 only works with 4 colors however got the result you want to see



Code:
bgInitTileSet(2, &patterns_bg, &palette_bg, 4, (&patterns_end_bg - &patterns_bg), (&palette_end_bg - &palette_bg), BG_4COLORS, 0x6000);
bgInitTileSet(0, &patterns_fence, &palette_fence, 5, (&patterns_end_fence - &patterns_fence), (&palette_end_fence - &palette_fence), BG_16COLORS, 0x5000);

bgInitMapSet(2, &map_bg, (&map_end_bg - &map_bg),SC_32x32, 0x4800);
bgInitMapSet(0, &map_fence, (&map_end_fence - &map_fence),SC_32x32, 0x4000);

oamInitGfxSet(&gfxpsrite_kyle_1, (&gfxpsrite_end_kyle_1 - &gfxpsrite_kyle_1), &palsprite_kyle_1, 0, 0x0000, OBJ_SIZE32);
oamSet(0,  mycharKyle.x, mycharKyle.y, 1, 0, 0, sprTiles[mycharKyle.positionOffSetSpriter], 0);
oamSetEx(0, OBJ_LARGE, OBJ_SHOW);

setMode(BG_MODE1, 0);
 

However lost background-1 and he has 16 colors that makes the background even more beautiful, is it not possible through the previous code?



Hors ligne ccc

  • Newbie
  • *
  • Messages: 24
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #4 le: 08 janvier 2013 à 09:28:50 »
Have you tried this setting  ?
bgInitTileSet(1, &patterns_bg, &palette_bg, 4, (&patterns_end_bg - &patterns_bg), (&palette_end_bg - &palette_bg), BG_4COLORS, 0x6000);
bgInitTileSet(0, &patterns_fence, &palette_fence, 5, (&patterns_end_fence - &patterns_fence), (&palette_end_fence - &palette_fence), BG_16COLORS, 0x5000);

bgInitMapSet(1, &map_bg, (&map_end_bg - &map_bg),SC_32x32, 0x4800);
bgInitMapSet(0, &map_fence, (&map_end_fence - &map_fence),SC_32x32, 0x4000);

oamInitGfxSet(&gfxpsrite_kyle_1, (&gfxpsrite_end_kyle_1 - &gfxpsrite_kyle_1), &palsprite_kyle_1, 0, 0x0000, OBJ_SIZE32);
oamSet(0,  mycharKyle.x, mycharKyle.y, 1, 0, 0, sprTiles[mycharKyle.positionOffSetSpriter], 0);
oamSetEx(0, OBJ_LARGE, OBJ_SHOW);

setMode(BG_MODE1, 0);
 

Hors ligne faeldaniel

  • Newbie
  • *
  • Messages: 34
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #5 le: 09 janvier 2013 à 02:31:17 »
yes, oddly only works with this code I quoted, with your code:

...
oamSet(0,  mycharKyle.x, mycharKyle.y, 0, 0, 0, sprTiles[mycharKyle.positionOffSetSpriter], 0);
...
or
..
oamSet(0,  mycharKyle.x, mycharKyle.y, 1, 0, 0, sprTiles[mycharKyle.positionOffSetSpriter], 0);
..

Stands behind and with that always stays in front

..
oamSet(0,  mycharKyle.x, mycharKyle.y, 2, 0, 0, sprTiles[mycharKyle.positionOffSetSpriter], 0);
..

Hors ligne alekmaul

  • Administrator
  • Hero Member
  • *****
  • Messages: 1149
    • Live Messenger (MSN) - alekmaul@hotmail.fr
    • Voir le profil
    • PortableDev
    • E-mail
Re : Sprite between two Backgrounds
« Réponse #6 le: 10 janvier 2013 à 06:32:23 »
yes, take a look here : http://www.portabledev.com/wiki/doku.php?id=sprites_en

Priority flag (3rd) is : priority relative to BG : 0 for Low and 3 is the highest

Hors ligne ccc

  • Newbie
  • *
  • Messages: 24
    • Voir le profil
Re : Re : Sprite between two Backgrounds
« Réponse #7 le: 10 janvier 2013 à 13:45:39 »
yes, take a look here : http://www.portabledev.com/wiki/doku.php?id=sprites_en

Priority flag (3rd) is : priority relative to BG : 0 for Low and 3 is the highest

That's where I redirected him too.
His problem is that he wants to have, in Mode 1, 2 BG of 16 colors and his sprite between that 2 BG (so in fact a BG and a FG).
He has succeded to put the sprite between the two layers with 0 and 2 as BG's id and 1 as priority flag.
It doesn't seem to work with another combination.
But with that solution he looses the 16 colors of the 2nd background, because of the limitations of Mode 1 I guess
Mode    # Colors for BG
         1   2   3   4
======---=---=---=---=
0        4   4   4   4
1       16  16   4   -
2       16  16   -   -
3      256  16   -   -
4      256   4   -   -
5       16   4   -   -
6       16   -   -   -
7      256   -   -   -
7EXTBG 256 128   -   -

Hors ligne faeldaniel

  • Newbie
  • *
  • Messages: 34
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #8 le: 12 janvier 2013 à 04:11:18 »
I want to develop a game rpg, this technique with sprites between bgs who would want to put trees on top of the sprite thus creating a depth effect, i will make new test with this idea and will post the results
« Modifié: 12 janvier 2013 à 04:13:04 par faeldaniel »

Hors ligne alekmaul

  • Administrator
  • Hero Member
  • *****
  • Messages: 1149
    • Live Messenger (MSN) - alekmaul@hotmail.fr
    • Voir le profil
    • PortableDev
    • E-mail
Re : Sprite between two Backgrounds
« Réponse #9 le: 15 janvier 2013 à 20:44:54 »
Great, thanks , waiting for that.
Began to do a ultima3 RPG for NDS, perhaps will adapt it for SNES ^^

Hors ligne faeldaniel

  • Newbie
  • *
  • Messages: 34
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #10 le: 17 janvier 2013 à 03:01:35 »
Look this brothers:  ;D

http://www.youtube.com/watch?v=dWz7ZWBXdcU

The Graphics is bad  ;) , i am studying color palettes, however this to get an idea of what I intend to do, this case I'll add the character to stay behind the trees. In the future, with an awesome graphic artist, the game will have beautiful graphics.  ::)

I buy the Pier Solar for Sega Genesis saw how far we can get with dedication, the boss of the project is a Brazilian like myself.

alekmaul i loved Ultima, i have this game for Nes ;) i search this games for other consoles.

Waiting for that games too.
« Modifié: 17 janvier 2013 à 03:12:29 par faeldaniel »

Hors ligne faeldaniel

  • Newbie
  • *
  • Messages: 34
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #11 le: 21 janvier 2013 à 03:31:30 »
I made many tests, discovered that this is a problem of lib, because I came to this conclusion? as you can see bgSet trees is 0, so in theory the sprite set as priority 1 would be in front from the trees.
When I start the sprite priority 0 or 1, the sprite is always behind the trees, look this code:

mychar.priority = 0;

//Init spite
oamInitGfxSet(&gfxpsrite, (&gfxpsrite_end - &gfxpsrite), &palsprite, 0, 0x0000, OBJ_SIZE32);
oamSet(0,  mychar.x, mychar.y,  mychar.priority, 0, 0, 0, 0);
oamSetEx(0, OBJ_LARGE, OBJ_SHOW);

//Init Map
bgInitTileSet(0, &patterns, &palette, 0, (&patterns_end - &patterns), 16*2, BG_16COLORS, 0x6000);
bgInitMapSet(0, &map, (&map_end - &map), SC_64x64, 0x5000);

Prints

mychar.priority = 0;

mychar.priority = 1;

but when put as priority 2 sprite goes to the front from the trees

mychar.priority = 2;


alekmaul have any idea what you can this happening?

Hors ligne alekmaul

  • Administrator
  • Hero Member
  • *****
  • Messages: 1149
    • Live Messenger (MSN) - alekmaul@hotmail.fr
    • Voir le profil
    • PortableDev
    • E-mail
Re : Sprite between two Backgrounds
« Réponse #12 le: 22 janvier 2013 à 07:24:25 »
Nope, no idea of that problem, will take a look when i will have time.
You're sure you're refreshing oam memory each time ?

Hors ligne faeldaniel

  • Newbie
  • *
  • Messages: 34
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #13 le: 22 janvier 2013 à 17:33:42 »
you refer to it?

while(1) {
...
...
if (move) bgSetScroll(0, scrX,scrY);

//this is refreshing oam memory?
oamSet(0,  mychar.x, mychar.y,  mychar.priority, mychar.direcionSpriter, 0, sprTiles[mychar.positionOffSetSpriter], 0);

WaitForVBlank();
}


In background mode 2
setMode(BG_MODE2,0);
work as I want

Layer 0
Sprite
Layer 1

but mode 2 only has two layers :'(, different mode 1 having three layers .
« Modifié: 22 janvier 2013 à 21:35:31 par faeldaniel »

Hors ligne faeldaniel

  • Newbie
  • *
  • Messages: 34
    • Voir le profil
Re : Sprite between two Backgrounds
« Réponse #14 le: 28 janvier 2013 à 21:32:41 »
I came to another conclusion, in example "Transparency" I changed the code default for:

      // Initialize SNES
consoleInit();

// Copy tiles to VRAM
bgInitTileSet(0, &LandTiles, &LandPalette, 1, (&LandTiles_end - &LandTiles), (&LandPalette_end - &LandPalette), BG_16COLORS, 0x0000);
bgInitTileSet(1, &CloudTiles, &CloudPalette, 0, (&CloudTiles_end - &CloudTiles), (&CloudPalette_end - &CloudPalette),  BG_4COLORS, 0x1000);

// Copy Map to VRAM
bgInitMapSet(0, &Maps, (&Maps_end - &Maps),SC_32x32, 0x2000);
bgInitMapSet(1, &Mapsc, (&Mapsc_end - &Mapsc),SC_32x32, 0x2400);

// Now Put in 16 color mode and put cloud on top of screen
setMode(BG_MODE1, BG3_MODE1_PRORITY_HIGH); bgSetDisable(2); 

// Set BG3 SubScreen and
bgSetEnableSub(1);

// enable Subscreen Color ADD/SUB and Color addition on BG1 and Backdrop color
setColorEffect(CM_SUBBGOBJ_ENABLE, CM_MSCR_BACK | CM_MSCR_BG1);



its working normally, BG1 front in BG0, but coment this parte the code:

      // Initialize SNES
consoleInit();

// Copy tiles to VRAM
bgInitTileSet(0, &LandTiles, &LandPalette, 1, (&LandTiles_end - &LandTiles), (&LandPalette_end - &LandPalette), BG_16COLORS, 0x0000);
bgInitTileSet(1, &CloudTiles, &CloudPalette, 0, (&CloudTiles_end - &CloudTiles), (&CloudPalette_end - &CloudPalette),  BG_4COLORS, 0x1000);

// Copy Map to VRAM
bgInitMapSet(0, &Maps, (&Maps_end - &Maps),SC_32x32, 0x2000);
bgInitMapSet(1, &Mapsc, (&Mapsc_end - &Mapsc),SC_32x32, 0x2400);

// Now Put in 16 color mode and put cloud on top of screen
setMode(BG_MODE1, BG3_MODE1_PRORITY_HIGH); bgSetDisable(2); 

// Set BG3 SubScreen and
//bgSetEnableSub(1);

// enable Subscreen Color ADD/SUB and Color addition on BG1 and Backdrop color
//setColorEffect(CM_SUBBGOBJ_ENABLE, CM_MSCR_BACK | CM_MSCR_BG1);



The BG1 is behind BG0. I read something about "Main screen" and "Sub screen".

As in this example would be  BG0 in front of the BG1 without transparency in BG_MODE1? it is thus not:
..
bgInitTileSet(1, &LandTiles, &LandPalette, 1, (&LandTiles_end - &LandTiles), (&LandPalette_end - &LandPalette), BG_16COLORS, 0x0000);
bgInitTileSet(0, &CloudTiles, &CloudPalette, 0, (&CloudTiles_end - &CloudTiles), (&CloudPalette_end - &CloudPalette),  BG_4COLORS, 0x1000);

// Copy Map to VRAM
bgInitMapSet(1, &Maps, (&Maps_end - &Maps),SC_32x32, 0x2000);
bgInitMapSet(0, &Mapsc, (&Mapsc_end - &Mapsc),SC_32x32, 0x2400);
..

« Modifié: 28 janvier 2013 à 22:03:34 par faeldaniel »