I have a bug that makes NO sense to me.. help!!

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
junkbunny
Posts: 7
Joined: April 13th, 2013, 4:01 pm

I have a bug that makes NO sense to me.. help!!

Post by junkbunny » April 16th, 2013, 3:21 pm

i was messing around with c++ and rebuilding from memory stuff i learned in early TUTs and i have come across a bug that makes zero sense to me. I made the little face, that goes around the screen and when you push spacebar he speeds up. Now here is the part that makes no sense. moving him around the screen with the arrow keys works fine, and when i hit the spacebar he speeds up and works fine unless im going up and to the left. when i go up and to the left and speed up it doesn't move any faster and i get a beeping sound. if anyone can tell me wtf is going on here i will give them 1 million dollars.
Attachments
New folder (2).rar
(6.11 MiB) Downloaded 191 times

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I have a bug that makes NO sense to me.. help!!

Post by albinopapa » April 16th, 2013, 3:38 pm

In Game.cpp file.

Code: Select all

void Game::ComposeFrame()

{
	int speed;
	speed = 2;
	
	kbd.SpaceIsPressed(true);

	if(kbd.UpIsPressed())
	{
		y = y - speed;
	}
	if(kbd.DownIsPressed())
	{
		y = y + speed;
	}
	if(kbd.RightIsPressed())
	{
		x = x + speed;
	}
	if(kbd.LeftIsPressed())
	{
		x = x - speed;
	}
	
	if( x < 1 )
	{
		x = 1; 
	}
	if( x > 780 )
	{
		x = 780;
	}
	if( y < 1 )
	{
		y = 1;
	}
	if(y > 580 )
	{
		y = 580;
	}
	Game::Position(x ,y );


}
I think the kbd.SpaceIsPressed(true); part should be

Code: Select all

if(kbd.SpaceIsPressed())
{
   speed += 5;
}
not sure how pressing the spacebar speeds up the face in your code the speed variable isn't increased at all in your code. After changing to the above code it works for me.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

junkbunny
Posts: 7
Joined: April 13th, 2013, 4:01 pm

Re: I have a bug that makes NO sense to me.. help!!

Post by junkbunny » April 17th, 2013, 4:59 pm

oh ya haha oops. i uploaded the wrong one. the one with the spacebar speeding up the face was a different one. and it wasn't a bug in the program i wrote its something else. at first i thought i fucked something up, but it happens with every program i write. if i press up, left, and spacebar all at the same time the spacebar doesn't do anyting and it makes a beep beep beep sound... totally weird.

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I have a bug that makes NO sense to me.. help!!

Post by albinopapa » April 17th, 2013, 9:38 pm

Not sure, but I have had that happen on some computers where the third button regardless of which it was would not register. The beeps also sometimes happen when the message queue is full. Try it when your computer is restarting just press a button a bunch of times while it is showing the BIOS screen after awhile it beeps at you until it has cleared the message queue.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Musi
Posts: 106
Joined: November 25th, 2012, 1:06 am

Re: I have a bug that makes NO sense to me.. help!!

Post by Musi » April 18th, 2013, 5:54 pm

This may be caused by Keyboard Ghosting
Musi

There are 10 types of people that understand binary.
Those that do, and those that don't.

Post Reply