31Fermer33
Mega ShockedLe 28/05/2018 à 18:12
All four If statements have the issue pointed out below....

if ((scrl_x>FRONT_MIN_X)&&( (enemyX<320) + (enemy_spr.maxWidth*16)))

I think this is questionable
(enemy_spr.maxWidth*16)

Suppose your sprite is 5 tiles wide most of the time but you have a super move that makes your sprite 20 tiles wide.
MaxWidth will be 20 and that will cause issues when your player is tested against the edge of the background.

Suppose your sprite is only 5 tiles wide. If your sprite has transparency then the edge of the sprite may not perfectly
appear against the left/right side of the background. Their could be invisible space between the sprites foot and the background edge.

What is a best way to realize a coordinates sytem for objects into the game wolrd you all can advice?

Every draw type has an X,Y coordinate so it is always good practice to keep them in variables that you can print to the screen.

EX: Print Player 1 (X,Y,)
EX: Print Player 2 (X,Y)
EX: Print Scroller (X,Y)

Now you can debug your code and see if player 1,2 is moving more than the scroller is and vice versa.

Personally I would move my sprite to the far left side of the screen and write down the Idle X coordinate.
Then I would move my sprite to the far right side of the screen and write down the Idle X coordinate.

I would start by hard coding those values into my logic and I would not use "maxWidth" for this purpose for the reason I described above.

The power of print statements is underestimated. They are my life blood when developing on the Neo.....
At some point you might want to make a sick little debug hud that your sprites, scrollers and pictures can plug into.
The reason is specific variables such as X,Y are constantly staples so why not make a reusable function that reads and displays those values among others?

This should be very helpful on your quest....

http://yuanworks.com/little-ninja-dev-smart-camera-movement/