Prev | Current Page 1003 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

mouseButton() == 1 )
if ( mng.mouseButtonState() == 1 )
{
if ( mng.clickRect( mng.mouseX(), mng.mouseY(), new Rect(bat.x, bat.y,
batR.w + bat.x, batR.h + bat.y) ) )
click = 1;
else
click = 0;
}
else
{
click = 0;
}
case et_mousemove:
if ( click == 1 )
{
bat.x += mng.mouseMoveX();
bat.y += mng.mouseMoveY();
}
case et_quit:
running = false;
default:
}
if( batSrf.collisionPixel( batSrf, batR, batR, new Point( bat.x - bat2.x,
bat.y - bat2.y ) ) )
mng.clear( 0xFF0000 );
else if( batSrf.collisionBox( batR, batR, new Point( bat.x - bat2.x,
bat.y - bat2.y ) ) )
mng.clear( 0xFF9900 );
else
mng.clear( 0x00000000 );
batSrf.draw(Manager.getScreen(), batR, bat );
batSrf.draw(Manager.getScreen(), batR, bat2 );
mng.flip();
}
batSrf.free();
mng.close();
}
}
Part III: Extending the Possibilities
546
Keeping Time with Timers
Programming games is a resource consuming business. So far, all of the examples depicted in this
chapter have made use of the delay method to help slow down the rate of animation, but this is
certainly not the most effective option, and when running in a window, can seem a little buggy.


Pages:
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015