|
-
November 23rd, 2016, 01:06 PM
#1
(OpenGL) Possible to achieve keyboard() functionality outside of keyboard()?
So, I have my keyboard function handling what happens during specific button presses, but I feel as though I can be more specific to which objects are effected by the button presses if I am somehow able to manipulate my objects in the same way, but from the checkKeyboard function. Essentially, this is what I am trying to emulate:
Code:
case 'e':
if (collided)
{
((Box*)gameObjects[1])->ChangeTexture();
treesTapped++;
points += 100;
break;
}
so I tried doing this in the checkKeyboard function:
Code:
else
{
collided = true;
if (b->alreadyCollided = false && keyDown['e']) //I believe that keyDown is just an bool array of size 255
{ //that gets ascii key presses, but I am using my professor's
treesTapped++; //project as a base for my final project, so I could be wrong.
points += 100; //I could post the entire class if that would help others help
b->ChangeTexture(); //me :)
b->alreadyCollided = true;
}
}
but it is worked less than I had hoped it would. Can someone maybe give me some guidance? Basically, I'm trying to make it so that whenever the player is colliding with the tree and they haven't collided with it before, the amount of trees tapped increments, the points accumulated is incremented by 100, the object's texture is changed, and the bool alreadyCollided is changed to true so that the player can't just get a large amount of points from one tree. This forum has already been so helpful in my journey through this project, and I am so grateful for everyone here. Thank you so much!!
Last edited by Aideux; November 23rd, 2016 at 01:09 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|