1

You can be surprised, but the genre of my project which has been mentioned in DATlib topic, is RPG actually, but unusual RPG - because ingame space I chosen is indistinctive for RPGs and very similar to beat'em-up!'s space.
And, as you might guess, the meetings with enemy (unlike a most of 8- and 16-bit RPGs) will not be random, but will use to be caused with player and enemy sprites collision in non-combat mode, like in Xenosaga series games.

I already added a first rudiments of combat system (the main problem at this moment is to make attacking player sprite smoothly walk toward enemy before attack instead of "teleportation" which we have now). The enemy turns also will be added later.
I planning to create a body of role and combat system on the base of Xenosaga Episode II code reverse-engineering results.
tromb Fichier joint : r8A7
tromb Fichier joint : 8ziG
tromb Fichier joint : CrKt

Also I need an original graphics very much. However, Yoh's sprite must be redrawn from the Haohmaru (from the first part of Samurai Shodown exactly) poses and motions, and Ryo sprite must look like Robert Baun from Burning Fight.
avatar

2

What should I do to ensure smooth execution of all operations (which is prescribed in piece of code below) sequence (character's walking toward the enemy -> character's attack -> character's return to initial position -> enemy's turn -> enemy's attack -> enemy's return -> player's turn, etc.) step by step?

if(turn==0) { if(p1e&JOY_A) { //aSpriteMove(&demoSpr,108,0); aSpriteSetAnim(&demoSpr,1); for(i=0; i<108; i++) { x++; } aSpriteSetAnim(&demoSpr,4); damage=1; enemy_hp-=damage; turn=1; fixPrintf1(1,26,3,3,"Enemy lost %d HP.", damage); waitVBlank(); //aSpriteMove(&demoSpr,-108,0); } if(p1e&JOY_B) { //aSpriteMove(&demoSpr,108,0); aSpriteSetAnim(&demoSpr,1); for(i=0; i<108; i++) { x++; } aSpriteSetAnim(&demoSpr,5); damage=2; enemy_hp-=damage; turn=1; fixPrintf1(1,26,3,3,"Enemy lost %d HP.", damage); waitVBlank(); //aSpriteMove(&demoSpr,-108,0); } if(p1e&JOY_C) { //aSpriteMove(&demoSpr,108,0); aSpriteSetAnim(&demoSpr,1); for(i=0; i<108; i++) { x++; } aSpriteSetAnim(&demoSpr,6); damage=3; enemy_hp-=damage; turn=1; fixPrintf1(1,26,3,3,"Enemy lost %d HP.", damage); waitVBlank(); //aSpriteMove(&demoSpr,-108,0); } } if(turn==1) { //aSpriteMove(&Enemy,-108,0); aSpriteSetAnim(&Enemy,2); for(i=0; i<108; i++) { enemyX--; } aSpriteSetAnim(&Enemy,3); damage=rand()%3; char_hp-=damage; turn=0; fixPrintf1(1,26,3,3,"Player lost %d HP.", damage); waitVBlank(); //aSpriteMove(&Enemy,108,0); }
You can find this code in the battle() function of main file.
avatar

3

At last I solved my problem with attacking player's and enemy's movements.
Now you can see in the attached video, how battles looks.

tromb Fichier joint : DATdemo.avi

Now I need to know, how to remove from the screen specific inscriptions only - without hurt of all remaining fix layer - after some time. Also I need to remove after returning from battle function the enemy sprite player collided before battle.
avatar

4

My initial thoughts for what they are worth are....

- Speed setting so you can set how fast your players move. (I believe the default speed should be faster than what you displayed)
- Reactions upon hit have your characters react to each other will look great!
- Curious to see a 4 on 6 scenario or something to ensure your sprite sizes are not too big to all fit on the screen.
At that point you might consider shrinking to view large battles!

I am sure this is all in the pipe but thought I would give some sort of feedback....

Keep up the good work!

Write a blank print statement in the same spot to clear what is currently there.....

fixPrint(2,3,4,3,"SOME TEXT"); fixPrint(2,3,4,3," "); //The blank space will erase whatever was written in that spot previously
You must play with the placement of the characters you are replacing by adjusting the first two digits....IF memory serves me correctly.....

In the code above you are not using structs...I believe in a situation like this it would be ideal to group variables together....

EX: All player one variables in a struct.
EX: All enemy variables in a struct.

If you don't do this early on you will be me years ago and you don't want that....structs will make your code and ideas manageable trust me.

But what do I know....

5

Mega Shocked (./4):
Write a blank print statement in the same spot to clear what is currently there.....

fixPrint(2,3,4,3,"SOME TEXT"); fixPrint(2,3,4,3," "); //The blank space will erase whatever was written in that spot previously

Thank you! Then what functions allows coder to work with time - to propose a few seconds for a text before disappearing?
avatar

6

There might be better ways but I would use a counter

#define TIME 100 BYTE textTimer=0; while (1) { if (++textTimer == TIME) { textTimer=0; // write text or erase text } }
When the scene is simple you will need more TIME and as things get busier you will need less TIME.

7

Don't do time delays that way ; it's not reliable, and the compiler may even remove the delay completely.

If you need a time delay, either count VBlanks (50 or 60 per second, depending on the system region), or use the timer interrupt.
avatar
Zeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo

8

Now I successed to put enemy out of visible screen after returning from battle function, but looks like I did something wrong in the code of sprites clearing before escape from battle.

tromb Fichier joint : lWlj

Mega Shocked (./4):At that point you might consider shrinking to view large battles!

I must say, this feature will fit to some scenes perfectly!

Zerosquare (./7):
Don't do time delays that way ; it's not reliable, and the compiler may even remove the delay completely.

If you need a time delay, either count VBlanks (50 or 60 per second, depending on the system region), or use the timer interrupt.

Thank you! But please, tell about timer interrupt usage for this more detailed.
avatar

9

It is explained in the Neo Geo Dev Wiki : https://wiki.neogeodev.org/index.php?title=Timer_interrupt
avatar
Zeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo

10

Also, about VBlank count - such function there was in old (used in SDK before DATlib creation) video library and called _vbl_count. Has DATlib an analogue of _vbl_count or programmer will have to add it manually?
avatar

11

Sorry, no idea -- I don't even code on NeoGeo smile
avatar
Zeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo

12

Zerosquare (./11):
Sorry, no idea -- I don't even code on NeoGeo smile

I'll hold over replacing old counter with a VBlank count function then.

But, all the same, what I forgot to clear screen from during battle function escaping?
avatar

13

This is not console-specific advice, it works the same for all consoles smile
avatar
Zeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo

14

Hi Zerosquare,

Waiting on vertical blanks is always built into every scene we program on the Neo...
if the previous code had a VBL would it be viable for the purpose of timing in your opinion?
Kind of like counting Vertical Blanks like you suggested?

If this would suffice then maybe my example could be used for timing purposes.

#define TIME 100 BYTE textTimer=0; while (1) { waitVBlank(); //Waiting on vertical blank per cycle if (++textTimer == TIME) { textTimer=0; // write text or erase text } }

15

Yes, that works smile
avatar
Zeroblog

« Tout homme porte sur l'épaule gauche un singe et, sur l'épaule droite, un perroquet. » — Jean Cocteau
« Moi je cherche plus de logique non plus. C'est surement pour cela que j'apprécie les Ataris, ils sont aussi logiques que moi ! » — GT Turbo

16

Sweetness! Thanks for the feedback Zerosquare!

VasiliyFamiliya I guess you could do the timing that way. Your scene most definately calls waitVBlank () so you could try that approach. If you use a different method please let us know it would be cool to see a different solution to the problem.

Your GFX issue does not seem to be GFX at all. Looks like your issue is with palettes. I would advise not to piggy back off of HPMan's colorStream demo but to first just piggy back off of his Scroller demo.

The difference is that the Scroller demo will have the pallettes allocated to the background no shuffling or additional slots will be required. You can draw your charcaters on top. Scroll your Scroller backwards and forwards as long as your palettes look right initially they will continue to look right.

In your example palettes are constantly being shuffled due to the colorStream. If you aren't careful you will find that scroller palettes can and will override your sprite palettes.

Just avoid this by having a simple Scroller at first. You can always add the colorStream later if you have to or you could just jump to different scrollers for your battles. You have options here.

Sorry for babbling for those reading who think I am out to lunch.

17

I converted the battle background from colorStream to normal scroller, but it didn't helped me.

tromb Fichier joint : 52Z8

Mega Shocked (./14):
Hi Zerosquare,

Waiting on vertical blanks is always built into every scene we program on the Neo...
if the previous code had a VBL would it be viable for the purpose of timing in your opinion?
Kind of like counting Vertical Blanks like you suggested?

If this would suffice then maybe my example could be used for timing purposes.

#define TIME 100 BYTE textTimer=0; while (1) { waitVBlank(); //Waiting on vertical blank per cycle if (++textTimer == TIME) { textTimer=0; // write text or erase text } }

Thank you! Now I can to propose text showing duration independently of during battle turn and phase!
avatar

18

Hi VasiliyFamiliya,

Please post your code. I will do my best to see if I can find where the conflict is.

19

Mega Shocked (./18):
Hi VasiliyFamiliya,

Please post your code. I will do my best to see if I can find where the conflict is.

OK.
avatar

20

anywhere you are doing this....

aSpriteInit(&demoSpr,&bmary_spr,53,16 + ffbg_a.palInfo->count + ffbg_b.palInfo->count + ffbg_c.palInfo->count,x,y,0,FLIP_NONE,AS_FLAGS_DEFAULT);
palJobPut(16 + ffbg_a.palInfo->count + ffbg_b.palInfo->count + ffbg_c.palInfo->count,bmary_spr.palInfo->count,&bmary_spr.palInfo->data);

Please stop.....

If I want Blue Mary to use pal slot 25 the code would like this...

aSpriteInit(&demoSpr,&bmary_spr,53,25,x,y,0,FLIP_NONE,AS_FLAGS_DEFAULT);
palJobPut(25,bmary_spr.palInfo->count,&bmary_spr.palInfo->data);

Adding this to that and that to this is clouding your issue. Make simple definitions for your scrollers,sprites and pictures....You can get elaborate after you get the basics down....

EX: I would start my pal slots at 16 and above because 0-15 is used for the fix layer aka your text
With that in mind if your background has 5 pals and you Init your scroller at pal slot 16 then Blue Mary would start at 21 because she should not overwrite your background palette.
The same principal is true when allocating sprites.

Your images depict palette slots that are being used by another graphic causing the ugly colours.

EX: All I would start with is 1 background, 1 Blue Mary and 1 Cigar Man.....
I would not include extra scrollers to complicate matters.

Remember simple Inits so you can clearly understand what the function's need. You will need to be very well versed in these function's.

21

Mega Shocked (./20):
anywhere you are doing this....

aSpriteInit(&demoSpr,&bmary_spr,53,16 + ffbg_a.palInfo->count + ffbg_b.palInfo->count + ffbg_c.palInfo->count,x,y,0,FLIP_NONE,AS_FLAGS_DEFAULT);
palJobPut(16 + ffbg_a.palInfo->count + ffbg_b.palInfo->count + ffbg_c.palInfo->count,bmary_spr.palInfo->count,&bmary_spr.palInfo->data);

Please stop.....

If I want Blue Mary to use pal slot 25 the code would like this...

aSpriteInit(&demoSpr,&bmary_spr,53,25,x,y,0,FLIP_NONE,AS_FLAGS_DEFAULT);
palJobPut(25,bmary_spr.palInfo->count,&bmary_spr.palInfo->data);

Adding this to that and that to this is clouding your issue. Make simple definitions for your scrollers,sprites and pictures....You can get elaborate after you get the basics down....

EX: I would start my pal slots at 16 and above because 0-15 is used for the fix layer aka your text
With that in mind if your background has 5 pals and you Init your scroller at pal slot 16 then Blue Mary would start at 21 because she should not overwrite your background palette.
The same principal is true when allocating sprites.

Your images depict palette slots that are being used by another graphic causing the ugly colours.

EX: All I would start with is 1 background, 1 Blue Mary and 1 Cigar Man.....
I would not include extra scrollers to complicate matters.

Remember simple Inits so you can clearly understand what the function's need. You will need to be very well versed in these function's.

Thank you. Now I fixed all I could, but for some reason the bus on the beach is disappearing after return from battle. Also I need to do something with a problem arising right away after end of battle and disappearing after scrolling beginning only - when all background is a blank grey colour, and removed enemy sprite is still visible (althought a contact with it not causes the battle already).

tromb Fichier joint : OLFB
avatar

22

Some quick advice. For what it's worth.

One easy way to hide your character is to move it off screen by moving the x coordinate.

The Bus is a separate layer....If you aren't Init'ing that pic that is probably why it is not displaying....
Who cares about the bus?....make a background GFX for your game and use that....

Ideally only work with 3 assets....P1,P2, and 1 Background Scroller and move on from there...
Clean your code to be as few lines as possible problems will stand out and be easier to address.

23

Mega Shocked (./22):The Bus is a separate layer....If you aren't Init'ing that pic that is probably why it is not displaying....
Who cares about the bus?....make a background GFX for your game and use that....

Ideally only work with 3 assets....P1,P2, and 1 Background Scroller and move on from there...

Now I changed a background, and also expanded the walking field.

tromb Fichier joint : OQMS
avatar

24

I don't mean to highjack this thread, but I thought this code might be helpful. I've been messing round with palettes and sprites trying to figure out how they are set in memory for each sprite. When I needed multiple sprites of the same image or animation, only baseSprite is incremented. Each multiple sprite uses the same palette or palettes.

There might be a better way to do this, but this is what is working right now. I did notice that buildchar outputs the sprite and palette count, so you could input the counts manually.

//Load images currentBaseSprite = 16; //set sprite locations currentBasePalette = 16; //set pal location pictureInit(&layerOne, &Stars,currentBaseSprite,currentBasePalette,0,0,FLIP_NONE); palJobPut(currentBasePalette, Stars.palInfo->count,Stars.palInfo->data); //update basepalette and basesprite currentBaseSprite += Stars.tileWidth; currentBasePalette += Stars.palInfo->count; pictureInit(&testPlayer.pic, &playerShip, currentBaseSprite, currentBasePalette, testPlayer.x, testPlayer.y, FLIP_NONE); //copy pic to mem palJobPut(currentBasePalette, playerShip.palInfo->count, playerShip.palInfo->data); //copy pal to mem //populate player data testPlayer.x = 0; //player x y testPlayer.y = 224/2 + 16; testPlayer.width = 20; testPlayer.height = 20; testPlayer.spriteNum = currentBaseSprite; change_sprite_zoom(currentBaseSprite, 10, 10*16, 2); oldX = testPlayer.x; oldY = testPlayer.y; currentBaseSprite += playerShip.tileWidth; currentBasePalette += playerShip.palInfo->count; for(ii = 0; ii < ENEMY_MAX; ii++) { enemy[ii].x = routine.wayPoint[ii].x; enemy[ii].y = routine.wayPoint[ii].y; enemy[ii].width = (ORANGE_ENEMY5.tileWidth * 16) * (10/16); enemy[ii].height = (ORANGE_ENEMY5.tileHeight * 16) * (10/16); enemy[ii].xVel = -2; enemy[ii].yVel = 1; enemy[ii].alive = 1; enemy[ii].hits = routine.attack.power; enemy[ii].shotAlive = 0; enemy[ii].shotXorg = 0; enemy[ii].shotYorg = 15; enemy[ii].randShotTime = rand()%100; change_sprite_zoom(currentBaseSprite, 10, 10*16, 2); //enemy picture pictureInit(&enemy[ii].pic, &ORANGE_ENEMY5, currentBaseSprite, currentBasePalette, enemy[ii].x, enemy[ii].y, FLIP_NONE); //copy player palJobPut(currentBasePalette, ORANGE_ENEMY5.palInfo->count, ORANGE_ENEMY5.palInfo->data); //copy pal to mem //inc sprite data currentBaseSprite += ORANGE_ENEMY5.tileWidth;//increment sprite location //next enemy } currentBasePalette += ORANGE_ENEMY5.palInfo->count; //increment pal location //setup player shot pictures for(ii = 0; ii < PLAYER_MAX_SHOTS; ii++) { shot[ii].x = 400; shot[ii].y = 400; shot[ii].alive = 0; pictureInit(&shot[ii].pic, &playerShot, currentBaseSprite, currentBasePalette, shot[ii].x, shot[ii].y, FLIP_NONE); currentBaseSprite += playerShot.tileWidth; } palJobPut(currentBasePalette, playerShot.palInfo->count, playerShot.palInfo->data); currentBasePalette += playerShot_Palettes.count; //setup enemy shot pictures for(ii = 0; ii < PLAYER_MAX_SHOTS; ii++) { eshot[ii].x = 400; eshot[ii].y = 400; eshot[ii].alive = 0; eshot[ii].enemyNum = -1; pictureInit(&eshot[ii].pic, &enemyLaser, currentBaseSprite, currentBasePalette, eshot[ii].x, eshot[ii].y, FLIP_NONE); change_sprite_zoom(currentBaseSprite, 7, 7*16, 1); currentBaseSprite += enemyLaser.tileWidth; } palJobPut(currentBasePalette, enemyLaser.palInfo->count, enemyLaser.palInfo->data); currentBasePalette += enemyLaser.palInfo->count; //populate explosions for(ii = 0; ii < EXPLOSION_MAX; ii++) { explosionSpr[ii].x = 400; explosionSpr[ii].y = 0; explosionSpr[ii].xVel = 0.25; explosionSpr[ii].yVel = 0.5; //amount to fall explosionSpr[ii].alive = 0; explosionSpr[ii].remove = 0; explosionSpr[ii].currentBaseSprite = currentBaseSprite; explosionSpr[ii].currentBasePalette = currentBasePalette; aSpriteInit(&explosionSpr[ii].spr,&explosion,currentBaseSprite,currentBasePalette, explosionSpr[ii].x,explosionSpr[ii].y,0,FLIP_NONE,AS_FLAGS_DEFAULT); //explosionSpr[ii].spr.stepNum = 0; currentBaseSprite += explosion.maxWidth * explosion.frameCount; } palJobPut(currentBasePalette,explosion.palInfo->count, explosion.palInfo->data); currentBasePalette += explosion.palInfo->count;
avatar

25

hine62 (./24):
I don't mean to highjack this thread, but I thought this code might be helpful. I've been messing round with palettes and sprites trying to figure out how they are set in memory for each sprite. When I needed multiple sprites of the same image or animation, only baseSprite is incremented. Each multiple sprite uses the same palette or palettes.

There might be a better way to do this, but this is what is working right now. I did notice that buildchar outputs the sprite and palette count, so you could input the counts manually.

//Load images currentBaseSprite = 16; //set sprite locations currentBasePalette = 16; //set pal location pictureInit(&layerOne, &Stars,currentBaseSprite,currentBasePalette,0,0,FLIP_NONE); palJobPut(currentBasePalette, Stars.palInfo->count,Stars.palInfo->data); //update basepalette and basesprite currentBaseSprite += Stars.tileWidth; currentBasePalette += Stars.palInfo->count; pictureInit(&testPlayer.pic, &playerShip, currentBaseSprite, currentBasePalette, testPlayer.x, testPlayer.y, FLIP_NONE); //copy pic to mem palJobPut(currentBasePalette, playerShip.palInfo->count, playerShip.palInfo->data); //copy pal to mem //populate player data testPlayer.x = 0; //player x y testPlayer.y = 224/2 + 16; testPlayer.width = 20; testPlayer.height = 20; testPlayer.spriteNum = currentBaseSprite; change_sprite_zoom(currentBaseSprite, 10, 10*16, 2); oldX = testPlayer.x; oldY = testPlayer.y; currentBaseSprite += playerShip.tileWidth; currentBasePalette += playerShip.palInfo->count; for(ii = 0; ii < ENEMY_MAX; ii++) { enemy[ii].x = routine.wayPoint[ii].x; enemy[ii].y = routine.wayPoint[ii].y; enemy[ii].width = (ORANGE_ENEMY5.tileWidth * 16) * (10/16); enemy[ii].height = (ORANGE_ENEMY5.tileHeight * 16) * (10/16); enemy[ii].xVel = -2; enemy[ii].yVel = 1; enemy[ii].alive = 1; enemy[ii].hits = routine.attack.power; enemy[ii].shotAlive = 0; enemy[ii].shotXorg = 0; enemy[ii].shotYorg = 15; enemy[ii].randShotTime = rand()%100; change_sprite_zoom(currentBaseSprite, 10, 10*16, 2); //enemy picture pictureInit(&enemy[ii].pic, &ORANGE_ENEMY5, currentBaseSprite, currentBasePalette, enemy[ii].x, enemy[ii].y, FLIP_NONE); //copy player palJobPut(currentBasePalette, ORANGE_ENEMY5.palInfo->count, ORANGE_ENEMY5.palInfo->data); //copy pal to mem //inc sprite data currentBaseSprite += ORANGE_ENEMY5.tileWidth;//increment sprite location //next enemy } currentBasePalette += ORANGE_ENEMY5.palInfo->count; //increment pal location //setup player shot pictures for(ii = 0; ii < PLAYER_MAX_SHOTS; ii++) { shot[ii].x = 400; shot[ii].y = 400; shot[ii].alive = 0; pictureInit(&shot[ii].pic, &playerShot, currentBaseSprite, currentBasePalette, shot[ii].x, shot[ii].y, FLIP_NONE); currentBaseSprite += playerShot.tileWidth; } palJobPut(currentBasePalette, playerShot.palInfo->count, playerShot.palInfo->data); currentBasePalette += playerShot_Palettes.count; //setup enemy shot pictures for(ii = 0; ii < PLAYER_MAX_SHOTS; ii++) { eshot[ii].x = 400; eshot[ii].y = 400; eshot[ii].alive = 0; eshot[ii].enemyNum = -1; pictureInit(&eshot[ii].pic, &enemyLaser, currentBaseSprite, currentBasePalette, eshot[ii].x, eshot[ii].y, FLIP_NONE); change_sprite_zoom(currentBaseSprite, 7, 7*16, 1); currentBaseSprite += enemyLaser.tileWidth; } palJobPut(currentBasePalette, enemyLaser.palInfo->count, enemyLaser.palInfo->data); currentBasePalette += enemyLaser.palInfo->count; //populate explosions for(ii = 0; ii < EXPLOSION_MAX; ii++) { explosionSpr[ii].x = 400; explosionSpr[ii].y = 0; explosionSpr[ii].xVel = 0.25; explosionSpr[ii].yVel = 0.5; //amount to fall explosionSpr[ii].alive = 0; explosionSpr[ii].remove = 0; explosionSpr[ii].currentBaseSprite = currentBaseSprite; explosionSpr[ii].currentBasePalette = currentBasePalette; aSpriteInit(&explosionSpr[ii].spr,&explosion,currentBaseSprite,currentBasePalette, explosionSpr[ii].x,explosionSpr[ii].y,0,FLIP_NONE,AS_FLAGS_DEFAULT); //explosionSpr[ii].spr.stepNum = 0; currentBaseSprite += explosion.maxWidth * explosion.frameCount; } palJobPut(currentBasePalette,explosion.palInfo->count, explosion.palInfo->data); currentBasePalette += explosion.palInfo->count;

Thank you. Maybe, I'll use it as spites number growing.
avatar

26

The lose possibility is also added.tromb Fichier joint :

YcQ4
avatar

27

Hit getting animation is [ur=https://drive.google.com/file/d/1_TUfvlKpYXquLQbqRk2qXwqJxTg5XCp8/view?usp=sharingl]added[/url].

tromb Fichier joint : uvs180523-001.BMPtromb Fichier joint : uvs180523-003.BMPtromb Fichier joint : uvs180523-004.BMPtromb Fichier joint : uvs180523-002.BMP
avatar

28

I fixed a bug with "untouchable" enemy double in the right end of scroller (see the piece of code I used to solve this problem below). But now enemy sprite begun to visibly shift right after scrolling till right end of background.

Before: tromb Fichier joint : xi1e

After: tromb Fichier joint : pIjX

What is reason of this?

if((p1&JOY_LEFT)&&(x<=32&&x>0)) { scrl_x--; if ((scrl_x>FRONT_MIN_X)&&(enemyX<320+(enemy_spr.maxWidth*16))) { enemyX++; aSpriteSetPos(&Enemy,enemyX,enemyY); } } if((p1&JOY_RIGHT)&&(x>=288&&x<320)) { scrl_x++; if ((scrl_x<FRONT_MAX_X)&&(enemyX>0-(enemy_spr.maxWidth*16))) { enemyX--; aSpriteSetPos(&Enemy,enemyX,enemyY); } }
avatar

29

I have been told your compiler can produce bad results if you do not clearly separate your logic.
All four If statements have the issue pointed out below....

This might not be the root of your problem but it is ideal to do this moving forward.

if ( (p1&JOY_LEFT) && ( (x<=32) && (x>0) ) )

30

I added made a corrections where it's required, but result hasn't any changes:

if((p1&JOY_UP)&&((y<=112)&&(y>0))) scrl_y--; if((p1&JOY_DOWN)&&((y>=208)&&(y<224))) scrl_y++; if((p1&JOY_LEFT)&&((x<=32)&&(x>0))) { scrl_x--; if ((scrl_x>FRONT_MIN_X)&&(enemyX<320+(enemy_spr.maxWidth*16))) { enemyX++; aSpriteSetPos(&Enemy,enemyX,enemyY); } } if((p1&JOY_RIGHT)&&((x>=288)&&(x<320))) { scrl_x++; if ((scrl_x<FRONT_MAX_X)&&(enemyX>0-(enemy_spr.maxWidth*16))) { enemyX--; aSpriteSetPos(&Enemy,enemyX,enemyY); } }
avatar