Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void keyPressed()
- {
- if(key == 'w')
- {
- if (down == true)
- {
- down = false;
- }
- up = true;
- }
- if(key == 'a')
- {
- if (right == true)
- {
- right = false;
- }
- left = true;
- }
- if(key == 'd')
- {
- if (left == true)
- {
- left = false;
- }
- right = true;
- }
- if(key == 's')
- {
- if (up == true)
- {
- up = false;
- }
- down = true;
- }
- if(key == ' ')
- {
- player.activatePulse();
- }
- }
- void keyReleased()
- {
- if(key == 'w')
- {
- up = false;
- }
- if(key == 'a')
- {
- left = false;
- }
- if(key == 'd')
- {
- right = false;
- }
- if(key == 's')
- {
- down = false;
- }
- }
- void movePlayer()
- {
- if(down == true && right == true)
- {
- player.xPosition += 3;
- player.yPosition += 3;
- }
- else if(down == true && left == true)
- {
- player.xPosition -= 3;
- player.yPosition += 3;
- }
- else if(up == true && right == true)
- {
- player.xPosition += 3;
- player.yPosition -= 3;
- }
- else if(up == true && left == true)
- {
- player.xPosition -= 3;
- player.yPosition -= 3;
- }
- else if(up == true)
- {
- player.yPosition -= 3;
- }
- else if(down == true)
- {
- player.yPosition += 3;
- }
- else if(right == true)
- {
- player.xPosition += 3;
- }
- else if(left == true)
- {
- player.xPosition -= 3;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement