That's kinda crazy, if you move on an angle it goes straight to target
maybe there is some reason for this (more interesting character paths?.. naw that's not it). Here's what I came up with to slide some blocks around a room that will move 60 pixels in a straight line unless something stops them, if then a little sparkle animation at point of impact. I removed the GUI part and the 'pushing' animations, so hopefully I didn't delete any crucial variables, but at least it can give some others ideas for a work-around.
(feel free to clean it up or let me know if I am going way beyond what is necessary...
)
Code: ags

(feel free to clean it up or let me know if I am going way beyond what is necessary...

int spriteEdgeX;
int spriteEdgeY;
int roller;
int limit;
int start;
bool obstruction;
Object *objStrike;
Object *objSlide;
void boink() // Call this if object strikes something, will bring a 16x16 character named cBoink to the point of impact and animate
{
if (spriteEdgeX < 0) spriteEdgeX = 1; // and keep it on the screen
if (spriteEdgeY < 0) spriteEdgeY = 1;
if (spriteEdgeX > 640) spriteEdgeX = 640;
if (spriteEdgeY > 480) spriteEdgeY = 480;
cBoink.ChangeRoom(player.Room, (spriteEdgeX + GetViewportX()), (spriteEdgeY + GetViewportY()) + 8);
cBoink.Transparency = 20;
cBoink.Animate(0, 3, eOnce, eBlock);
cBoink.Transparency = 100;
obstruction = true;
}
bool checkStrikeY() // runs along the Y-Axis of the sprite checking for obstructions
{
while (spriteEdgeY != limit)
{
if (GetWalkableAreaAt(spriteEdgeX, spriteEdgeY)) // is it walkable?
{
if (Object.GetAtScreenXY(spriteEdgeX, spriteEdgeY) != null) // is there an object?
{
objStrike = Object.GetAtScreenXY(spriteEdgeX, spriteEdgeY);
if (objStrike.Solid) // it the object solid?
{
boink(); // call the Boink function and set obstruction to true.
spriteEdgeY = limit;
}
else {
obstruction = false; // nothing in the way!
spriteEdgeY --;
}
}
else
{
obstruction = false; // nothing in the way!
spriteEdgeY --;
}
}
else {
// the pixel is not walkable, so call boink
boink();
spriteEdgeY = limit;
}
}
spriteEdgeY = start;
}
bool checkStrikeX() // runs along the X-Axis of the sprite checking for obstructions
{
while (spriteEdgeX != limit)
{
if (GetWalkableAreaAt(spriteEdgeX, spriteEdgeY))
{
if (Object.GetAtScreenXY(spriteEdgeX, spriteEdgeY) != null)
{
objStrike = Object.GetAtScreenXY(spriteEdgeX, spriteEdgeY);
if (objStrike.Solid && objStrike != objSlide)
{
boink(); // there is an object there and it is solid!
spriteEdgeX = limit;
}
else {
obstruction = false;
spriteEdgeX ++; // nothing in the way!
}
}
else {
obstruction = false;
spriteEdgeX ++; // nothing in the way!
}
}
else {
boink();
spriteEdgeX = limit;
}
}
spriteEdgeX = start;
}
function PushAnimate(int Way, int ObjPush)
{
roller = 0;
objSlide = object[objPush];
int pushX = objSlide.X;
int pushY = objSlide.Y;
if (Way == 1) { // Left
spriteEdgeY = (pushY - 1) - GetViewportY(); // Bottom edge
start = spriteEdgeY;
limit = (pushY - GetViewportY()) - (Game.SpriteHeight[objSlide.Graphic]/2) + 1; //Isometric Top edge
}
else if (Way == 2) { // Up
spriteEdgeX = (pushX - GetViewportX()) + 1; // Left edge
start = spriteEdgeX;
limit = ((pushX - GetViewportX()) + Game.SpriteWidth[objSlide.Graphic]) - 2; //Right edge
}
else if (Way == 3) { //Right
spriteEdgeY = (pushY - 1) - GetViewportY(); // Bottom edge
start = spriteEdgeY;
limit = (pushY - GetViewportY()) - (Game.SpriteHeight[objSlide.Graphic]/2) + 1; //Isometric Top edge
}
else if (Way == 4) { //Down
spriteEdgeX = (pushX - GetViewportX()) + 1; // Left edge
start = spriteEdgeX;
limit = ((pushX - GetViewportX()) + Game.SpriteWidth[objSlide.Graphic]) - 2; //Right edge
}
while (roller != 21)
{
if (Way == 1) { //Left
pushX -= 3;
spriteEdgeX = pushX - GetViewportX(); // Left edge
checkStrikeY();
}
else if (Way == 2) { //up
pushY -= 3;
spriteEdgeY = (pushY - GetViewportY()) - (Game.SpriteHeight[objSlide.Graphic]/2); //Isometric Top edge
checkStrikeX();
}
else if (Way == 3) { //Right
pushX += 3;
spriteEdgeX = (pushX - GetViewportX()) + Game.SpriteWidth[objSlide.Graphic]; //Right edge
checkStrikeY();
}
else if (Way == 4) { //Down
pushY += 3;
spriteEdgeY = pushY - GetViewportY(); // Bottom edge
checkStrikeX();
}
if (!obstruction)
{
objSlide.SetPosition(pushX, pushY);
roller ++; // If nothing in the way, advance the object.
}
else
roller = 21;
Wait(1);
}
}