views:

75

answers:

1

heres what Im working with now

if (osl_keys->held.down)
{
sprite_position = DOWN;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->y += 16;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->y += 16;
}
if (osl_keys->held.up)
{
sprite_position = UP;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->y -= 16;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->y -= 16;
}
if (osl_keys->held.right)
{
sprite_position = RIGHT;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->x += 16;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->x += 16;
}
if (osl_keys->held.left)
{
sprite_position = LEFT;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->x -= 16;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->x -= 16;
}
sceKernelDelayThread(750000);

and I have difinantly decided to have each sprite be 32x32 so collision may be more aplicable

by lokiare1 you still have to check for collision with the tiles. The most thorough way to do collision is to check to see the location of each visible pixel of a sprite against every other pixel of every other sprite, then return a pointer to the sprite that is collided with. This would be very slow. The method I describe should be a slow and dirty working collision detection. If I'm wrong please tell me how I'm wrong.

This is the part i am having trouble imagining(I like to make sure things work in my head before I try it out that way I dont hop to something random) I have spent a few amount of nights sitting in the shower trying to think of a way or it to check if something was there

Im thinking of something that presets that tile x,y is solid so if a solid object is infront of it dont move else move Im working in my post >.>

if (osl_keys->held.down)
{
if (y+1 == bush=>y)
{
sprite_march = 4;
SpriteAnimate();
else
{
sprite_position = DOWN;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->y += 16;
SpriteAnimate();
sceKernelDelayThread(20000);
sprite->y += 16;
}

But then again how would i be able to shorten the amount of code by just asking (y+1 == solid) im not sure how to go about that

+1  A: 

This isn't an answer but a general style note. Do you notice that your code is repetitive? Because it is. Your first post of code can be shortened a lot:

int down_direction = 0, right_direction = 0;
if (osl_keys->held.down)
{
    down_direction = 16;
    sprite_position = DOWN;
}
else if (osl_keys->held.up)
{
    down_direction = -16;
    sprite_position = UP;
}
else if (osl_keys->held.right)
{
    right_direction = 16;
    sprite_position = RIGHT;
}
else if (osl_keys->held.left)
{
    right_direction = -16;
    sprite_position = LEFT;
}

for (int i = 0; i < 2; ++i)
{
    SpriteAnimate();
    sceKernelDelayThread(20000);
    sprite->x += right_direction;
    sprite->y += down_direction;
}
sceKernelDelayThread(750000);

There, isn't that better?

To answer your question, you don't want to track the pixel position of your sprite. You want to track the row and column position. Then just check to the side before you move, if the target tile is solid.

rlbond
thats what im trying to figure out but i dont really understand the integers by myself
Christopher