pspsdkツールチェーンでoslibを使用していますが、何らかの理由でこれが思ったとおりに機能しません
float spritewidth = sprite->stretchX;
float spriteheight = sprite->stretchY;
float bushwidth = bush->stretchX;
float bushheight = bush->stretchY;
//Basic border collision
if (sprite->x <= 0)
sprite->x = 0;
if (sprite->y <= 0)
sprite->y = 0;
if (sprite->x >= 455)
sprite->x = 455;
if (sprite->y >= 237)
sprite->y = 237;
//Bush
if ( (sprite->x + spritewidth > bush->x) &&
(sprite->x < bush->x + bushwidth) &&
(sprite->y + spriteheight > bush->y) &&
(sprite->y < bush->y + bushheight) )
{
bushcol = 1;
}
else
{
bushcol = 0;
}
if (osl_keys->held.down)
{
if (bushcol == 0)
{
sprite->y += 4;
sprite_position = DOWN;
SpriteAnimate();
}
else
{
sprite->y -= 6;
bushcol = 0;
}
}
if (osl_keys->held.up)
{
if (bushcol == 0)
{
sprite->y -= 4;
sprite_position = UP;
SpriteAnimate();
}
else
{
sprite->y += 6;
bushcol = 0;
}
}
if (osl_keys->held.right)
{
if (bushcol == 0)
{
sprite->x += 4;
sprite_position = RIGHT;
SpriteAnimate();
}
else
{
sprite->x -= 6;
bushcol = 0;
}
}
if (osl_keys->held.left)
{
if (bushcol == 0)
{
sprite->x -= 4;
sprite_position = LEFT;
SpriteAnimate();
}
else
{
sprite->x += 6;
bushcol = 0;
}
}
離れようとすると、スプライトは茂みから反対方向に動き始めますが、最終的には自由に落ちます
より良い衝突方法または提案
私はボタンごとにこれを試しましたが、それでも運がありません
if (osl_keys->held.down)
{
if ( (sprite->x + spritewidth > bush->x) &&
(sprite->x < bush->x + bushwidth) &&
(sprite->y + spriteheight > bush->y) &&
(sprite->y < bush->y + bushheight) )
{
sprite->y -= 4;
}
else
{
sprite->y += 2;
sprite_position = DOWN;
SpriteAnimate();
}
}