Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added Multiplayer
-add by changing the numberOfPlayers Variable in Game.java to 2, -if it is 2 it will spawn another player Changed the controls to allow for player 2 to have room -player1 shoot is controlled by 'L' -player 2 uses wasd and space to shoot
- Loading branch information
Showing
3 changed files
with
129 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package main; | ||
import java.awt.Graphics; | ||
import java.awt.Rectangle; | ||
|
||
import entity.EntityTypeA; | ||
|
||
public class Player2 extends GameObject implements EntityTypeA{ | ||
|
||
private double velX = 0; | ||
private double velY = 0; | ||
|
||
|
||
private Skins skin; | ||
private Game game; | ||
|
||
public Player2(double x, double y, Skins skin, Game game){ | ||
super(x,y); | ||
this.skin = skin; | ||
this.game = game; | ||
} | ||
|
||
public void tick(){ | ||
x += velX; | ||
y += velY; | ||
|
||
if (x <= 0 ){ | ||
x = 0; | ||
} | ||
if (x >= 736){ | ||
x = 736; | ||
} | ||
if (y <= 0){ | ||
y = 0; | ||
} | ||
if (y >= 536){ | ||
y = 536; | ||
} | ||
if(GamePhysics.Collision(this, game.eb)){ | ||
System.out.println("LOSE"); | ||
} | ||
} | ||
|
||
public void render(Graphics g){ | ||
g.drawImage(skin.player2, (int)x, (int)y, null); | ||
} | ||
public double getX(){ | ||
return x; | ||
} | ||
public double getY(){ | ||
return y; | ||
} | ||
public void setX(double x){ | ||
this.x = x; | ||
} | ||
public void setY(double y){ | ||
this.y = y; | ||
|
||
} | ||
public void setVelX(double velX){ | ||
this.velX = velX; | ||
} | ||
public void setVelY(double velY){ | ||
this.velY = velY; | ||
} | ||
public Rectangle getBounds(){ | ||
return new Rectangle((int)x, (int) y, 64, 64); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters