The image is split into four positions that will bounce the ball if it hits in the current position. I offset a little into the other colors to make it a little easier and allow for you to hit things that were right on the borders of the colors.
I'm sliding this around on a cube face much like I did the number texture. There was nothing fancy when figuring out the offsets. Hit and miss and tweaking the u/v numbers on the texture editing. I did only apply this texture to a single side of a rectangular cube. You do that by toggling the "select texture" radio button on the editor. Here is the script that changes which color is currently active.
// texture offsets
// h = 0;
// v =
// 0.375 (red=1)
// 0.125 (blue=2)
// -0.125 (green = 3)
// -0.375 (yellow = 4)
integer curval = 1;
doOffset()
{
//llOwnerSay("offset ="+(string)ftmp);
if (curval<0)
{
curval = 3;
}
else if (curval>3)
{
curval = 0;
}
float foffset = 0.375;
if (curval == 1)
{
foffset = 0.125;
}
else if (curval == 2)
{
foffset = -0.125;
}
else if (curval == 3)
{
foffset = -0.375;
}
llOffsetTexture(0.0,foffset,ALL_SIDES);
}
default
{
state_entry()
{
doOffset();
}
touch_start(integer total_number)
{
curval++;
doOffset();
}
}
No comments:
Post a Comment