Sorry couldn't think of a better title.
So, I'm trying to implement moving and placing blocks in order to place them as defenses in front of the player's base. I wrote a simple code, just two lines, so that when the player's x and y are within a range of the block's x and y (15 pixels on the x, 10 on the y), and then the player presses a button, the block will jump to be 4 pixels away from the player's x and y ("carrying" the block). Everything works fine until the block gets to blockx=14 (and blocky=9) when the the block will detach from the player (the variable 'nearbase' is no longer true) and will not allow itself to be picked up again (nearbase is never re-set as 1), even if the player's x and y go away from the edge of the screen. I used plotvalue to display that the variables for player and base x and y are correct, stay what they should be and stay within range. There is no problem on the other end of the screen, only in the lower numbers. When the strange behaviour is happening, I ask (via plotting a debug image) if the playerx is within range, it says it isn't, despite the plotvalue clearly showing that, in fact, it is.
playerx and playery are dimensioned as a and b while blockx and blocky are $2557 and $2561 so it doesn't seem to be an overwriting issue.
The block is called 'base' in the code, so blockx=basex.
if playerx<basex+15 && playerx>basex-15 && playery<basey+10 && playery>basey-10 then nearbase=1 else nearbase=0 if joy0fire1 && nearbase=1 then basex=playerx+4:basey=playery+4:basepickedup=1 else basepickedup=0
Anyone know what's going on?