shooting laser problem
in
Programming Questions
•
5 months ago
I want to shoot a laser from my player, from the bottom to the top. I have the laser shooting upwards, but the problem is that if i hold down the mouse button the laser stays on, i want it to shoot to the top, and go away until you click again. If anyone could help me solve this problem i would appreciate it. This is for a game so it could be used to cheat in a way. This is the code i have
- class Shoot
- {
- boolean shoot = false;
- Shoot()
- {
- }
- void shoot()
- {
- if (mousePressed == true)
- {
- shoot = true;
- }
- if(shoot==true)
- {
- laserdetail();
- shoot = false;
- }
- }
- void mousePressed()
- {
- shoot = true;
- }
- void laserdetail()
- {
- stroke(0,255,0);
- strokeWeight(5);
- line(mouseX, 680, mouseX, 0);
- }
- }
1