|
Post by fishfinger on Nov 1, 2017 12:07:34 GMT
I'm just getting started with AGD, but have run into a problem:
If the window area is set to include the very top row of the screen then a sprite moving upwards will leave the screen. However if I move the window area down one block so that the top line is no longer part of the playing screen then the sprite will hit the invisible wall at the top and change direction.
I'm using 4.7, but have recreated the issue in 3.0 as well.
|
|
|
Post by alessandro on Nov 1, 2017 13:57:20 GMT
You must change the values of the X coordinate associated to the SCREENUP command in the sprite event script in accordance with the dimension and position of the game area window. If for instance the sprite is set to move up one screen when its X coordinate is, say, 9 or less, and the maximum X possible value is 16 because the window's highest row is set two lines down the BORDER area, the sprite's X coordinate won't ever reach that value, so it will be unable to leave the screen.
|
|
|
Post by fishfinger on Nov 1, 2017 14:55:20 GMT
I'm not using the SCREENUP command, and only have a single screen. It happens with the default "patrolling U/D" event script for the sprite.
|
|
|
Post by alessandro on Nov 1, 2017 16:10:06 GMT
Then you must make it disappear by removing it when it reaches a certain height, e.g.:
IF X = 8 REMOVE ENDIF
|
|
|
Post by andrewvanbeck on Nov 21, 2017 9:56:31 GMT
If your window is smaller than the screen then it will probably recognise any blocks outside the screen as solid walls. Often its best to have a block border around your screen, because any sprites that escape the screen area can really mess with memory.
When your sprite is exiting the screen, it might just be wrapping its X coordinate around the byte limit, so if it hits -1, that's changed to 254. This probably means the sprite is trying to render onto non-screen memory, and will probably cause issues when you have more screens or content in general.
If you want to have the sprite move up and down, and don't want a block border around the play area, then you will need to add some extra checking code... like
IF 8 > X LET DIRECTION = 1 ENDIF
IF X > 186 LET DIRECTION = 0 ENDIF
IF DIRECTION = 1 IF CANGODOWN SPRITEDOWN ELSE LET DIRECTION = 0 ENDIF ELSE IF CANGOUP SPRITEUP ELSE LET DIRECTION = 1 ENDIF ENDIF
|
|