[Kde-games-devel] KBounce - Bug or feature?

Danyluk Tamás tamas.danyluk2 at gmail.com
Thu Mar 25 12:15:35 CET 2010


Dear Developers,
I am very new to mailing lists and open source programming, but I
ported KBounce (newest SVN) to J2ME recently as a school project.
I think I found a bug in it.
If you click the very left empty tile with horizontal cursor, or the
very top empty tile with vertical cursor, no wall will be built.
This behavior is caused by the following code:
board.cpp 296:

    // This small constant is added to each of the coordinates to
    // avoid positive collision test result when tested rect lies
    // on the edge of non-free space
    qreal D = 0.01;
    ....
    p = rect.topRight();
    int ur = m_tiles[static_cast<int>( p.x() - D )][static_cast<int>(
p.y() + D )];
    if ( ur != Free) normal += KBounceVector( -1, 1 );

It makes the "right wall" collide with tile(0,y), because
m_tiles[1-0.01] is m_tiles[0].
The same way the "down wall" collides with tile(x,0).

To correct this (i think) unresponsive behaviour, you should insert this code to
wall.cpp 218

if (m_dir == Right)
{
        m_boundingRect.setRight(x + 1);
}
else if (m_dir == Down)
{
        m_boundingRect.setBottom(y + 1);
}

It works fine in my java implementation, but i didnt try to build the original.
Please give it a try if you think it makes the program better.
By the way my J2ME portcan be found here:
http://kennysp2.info/programs/jbounce/microemu-demo.html
Thanks...

Danyluk Tamás


More information about the kde-games-devel mailing list