Moving cross hairs problem

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Vee
Posts: 2
Joined: June 1st, 2012, 3:56 am

Moving cross hairs problem

Post by Vee » June 1st, 2012, 5:04 am

I am having a small problem that i am not to sure on how to fix it and i really need some help.

Problem: When pressing the space bar to slow down the cross hairs speed, it works but i can not go diagonally down to the left.
cross hairs.PNG
red = direction can not go when pressing space (only occurs when pressing space to slow down)
(60.99 KiB) Downloaded 122 times
The problem did not occur the fist time i did the coding wile watching the tutorial, I did not notice it until the end of lesson 7. i don't know if the problem is in my coding therefore i think that i may have changed a setting or some thing (if that is possible). If you know what i have done can you plz tell me.

my game.cpp file/thing

void Game::ComposeFrame()
{
// movement speed

int speed;
speed = 3;

if( kbd.EnterIsPressed() )
{
speed = 8;
}

if( kbd.SpaceIsPressed() )
{
speed = 1;
}

// controlls
if( kbd.RightIsPressed() )
{
x = x + speed;
}

if( kbd.LeftIsPressed() )
{
x = x - speed;
}

if(kbd.UpIsPressed() )
{
y = y - speed;
}

if(kbd.DownIsPressed() )
{
y = y + speed;
}

// colour if in center

int r;
r = 255;

if( x > 300 && x < 500 && y > 200 && y < 400)
{
r = 0;
}

// outer boundary
if( x < 5 )
{
x = 5;
}

if( x > 794 )
{
x = 794;
}

if( y > 594 )
{
y = 594;
}

if( y < 5 )
{
y = 5;
}

// draw cross hairs

gfx.PutPixel( x, y,255,100,100 );
gfx.PutPixel( -5 + x, y,r,255,255 );
gfx.PutPixel( -4 + x, y,r,255,255 );
gfx.PutPixel( -3 + x, y,r,255,255 );
gfx.PutPixel( 3 + x, y,r,255,255 );
gfx.PutPixel( 4 + x, y,r,255,255 );
gfx.PutPixel( 5 + x, y,r,255,255 );
gfx.PutPixel( x, -5 + y,r,255,255 );
gfx.PutPixel( x, -4 + y,r,255,255 );
gfx.PutPixel( x, -3 + y,r,255,255 );
gfx.PutPixel( x, 3 + y,r,255,255 );
gfx.PutPixel( x, 4 + y,r,255,255 );
gfx.PutPixel( x, 5 + y,r,255,255 );
}

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: Moving cross hairs problem

Post by LuX » June 1st, 2012, 10:05 am

Might be there's something wrong in your code, but a lot of the cheaper keyboard today that use usb connection can't take more than 3 key presses at a time.

Might be there's something in your keyboard preventing it from taking all these key presses at once.
ʕ •ᴥ•ʔ

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Moving cross hairs problem

Post by chili » June 1st, 2012, 11:54 am

Yeah, it's most likely key ghosting.

http://en.wikipedia.org/wiki/Rollover_( ... d_ghosting
Chili

Post Reply