void OverWorldCharacter::controlCallback(PadControls controls)
{
Location next = loc;
// if(controls.right() && controls.up())
// {
// if(room->is_walkable(Location(next.x+speed.x,next.y-speed.y)))
// {
// next.x += speed.x;
// next.y -= speed.y;
// }
// }
// else if(controls.right() && controls.down())
// {
// if(room->is_walkable(Location(next.x+speed.x,next.y+speed.y)))
// {
// next.x += speed.x;
// next.y += speed.y;
// }
// }
// else if(controls.left() && controls.up())
// {
// if(room->is_walkable(Location(next.x-speed.x,next.y-speed.y)))
// {
// next.x -= speed.x;
// next.y -= speed.y;
// }
// }
// else if(controls.left() && controls.down())
// {
// if(room->is_walkable(Location(next.x-speed.x,next.y+speed.y)))
// {
// next.x -= speed.x;
// next.y += speed.y;
// }
// }
u8 pdirect = direction;
if(controls.right())
{
if(room->is_walkable(Location(next.x+speed.x,next.y)))
next.x += speed.x;
else if(room->is_walkable(Location(next.x+speed.x,next.y-speed.y)))
next = Location(next.x+speed.x,next.y-speed.y);
else if(room->is_walkable(Location(next.x+speed.x,next.y+speed.y)))
next = Location(next.x+speed.x,next.y+speed.y);
direction |= EAST;
// standing_direction = standing_direction & ~EAST;
standing_direction = 0;
}
if(controls.left())
{
if(room->is_walkable(Location(next.x-speed.x,next.y)))
next.x -= speed.x;
else if(room->is_walkable(Location(next.x-speed.x,next.y+speed.y)))
next = Location(next.x-speed.x,next.y+speed.y);
else if(room->is_walkable(Location(next.x-speed.x,next.y-speed.y)))
next = Location(next.x-speed.x,next.y-speed.y);
direction |= WEST;
// standing_direction = standing_direction & ~WEST;
standing_direction = 0;
}
if(controls.down())
{
if(room->is_walkable(Location(next.x,next.y+speed.y)))
next.y += speed.y;
else if(room->is_walkable(Location(next.x+speed.x,next.y+speed.y)))
next = Location(next.x+speed.x,next.y+speed.y);
else if(room->is_walkable(Location(next.x-speed.x,next.y+speed.y)))
next = Location(next.x-speed.x,next.y+speed.y);
direction |= SOUTH;
// standing_direction = standing_direction & ~SOUTH;
standing_direction = 0;
}
if(controls.up())
{
if(room->is_walkable(Location(next.x,next.y-speed.y)))
next.y -=speed.y;
else if(room->is_walkable(Location(next.x-speed.x,next.y-speed.y)))
next = Location(next.x-speed.x,next.y-speed.y);
else if(room->is_walkable(Location(next.x+speed.x,next.y-speed.y)))
next = Location(next.x+speed.x,next.y-speed.y);
direction |= NORTH;
// standing_direction = standing_direction & ~NORTH;
standing_direction = 0;
}
if(next.x != loc.x || next.y != loc.y)
{
loc = next;
// room->moveTo((480.0f/2.0f)-lan_loc.x,(272.0f/2.0f)-lan_loc.y);
room->moveTo(240.0f-loc.x,136-loc.y);
}
// if(controls.pressed() & PSP_CTRL_UP)
// direction |= NORTH;
// if(controls.pressed() & PSP_CTRL_DOWN)
// direction |= SOUTH;
// if(controls.pressed() & PSP_CTRL_RIGHT)
// direction |= EAST;
// if(controls.pressed() & PSP_CTRL_LEFT)
// direction |= WEST;
if(controls.released() & PSP_CTRL_UP)
{
direction = direction & ~NORTH;
standing_direction |= NORTH;
}
if(controls.released() & PSP_CTRL_DOWN)
{
direction = direction & ~SOUTH;
standing_direction |= SOUTH;
}
if(controls.released() & PSP_CTRL_RIGHT)
{
direction = direction & ~EAST;
standing_direction |= EAST;
}
if(controls.released() & PSP_CTRL_LEFT)
{
direction = direction & ~WEST;
standing_direction |= WEST;
}
if(sprite == NULL) return;
if(pdirect != direction)
{
pdirect = direction;
if(direction & NORTHEAST)
{
}
else if(direction & NORTHWEST)
{
}
else if(direction & SOUTHEAST)
{
}
else if(direction & SOUTHWEST)
{
}
else
{
sprite->stopAnim();
if(standing_direction & EAST)
sprite->setFrame(2,0);
else if(standing_direction & NORTH)
sprite->setFrame(0,0);
else if(standing_direction & SOUTH)
sprite->setFrame(4,0);
}
}
//Updates sprite
sprite->update();
}
Help with controls
i'm trying to get the controls working and i can't figure it out so while i try to figure it out i would like the help from those here.
My character moves in an isometric world that isn't really isometric. I draw the image to the screen then setup bounds based on points and if it is inside of those bounds then it can move. I'm having problems getting the isometric controls right here is what i have so far.
[Edited by - coolkehon on August 16, 2009 9:14:51 AM]
Could you edit your post and enclose the code in [source] tags? That'll make it easier to read.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement