Skip to content

Commit

Permalink
hotfile-v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jnnsrctr committed Aug 9, 2022
1 parent cb885a9 commit 8e60917
Show file tree
Hide file tree
Showing 19 changed files with 503 additions and 295 deletions.
Binary file modified Archer.class
Binary file not shown.
10 changes: 7 additions & 3 deletions Archer.ctxt
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#BlueJ class context
comment0.target=Archer
comment0.text=\r\n\ Beschreiben\ Sie\ hier\ die\ Klasse\ Archer.\r\n\ \r\n\ @author\ (Ihr\ Name)\ \r\n\ @version\ v1.2\ (02.06.2022\ 15\:35)\r\n
comment0.text=\r\n\ Class\ Archer\ creates\ and\ draws\ the\ archers\ on\ the\ Canvas.\r\n\ This\ class\ is\ able\ to\ move\ the\ archers\ from\ right\ to\ left\ /\ left\ to\ right.\r\n\r\n\ \r\n\ @author\ \ Johannes\ Richter\r\n\ \ \ \ \ \ \ \ \ \ Simon\ Cirdei\r\n\ \ \ \ \ \ \ \ \ \ Christoph\ Schramm\r\n\ \ \ \ \ \ \ \ \ \ \r\n\ @version\ v1.3\ (02.06.2022\ 16\:45)\r\n
comment1.params=inputplayer\ archercolor\ usedcanvas
comment1.target=Archer(int,\ java.awt.Color,\ Canvas)
comment1.text=\r\n\ Constructor\ for\ instances\ of\ Archer\r\n\r\n\ @param\ inputplayer\ \ \ \ current\ player\r\n\ @param\ archercolor\ \ \ color\ of\ the\ archer\r\n\ @param\ usedcanvas\ \ canvas\ where\ to\ plot\ the\ arrow\r\n
comment2.params=
comment2.target=void\ draw()
comment2.text=\r\n\ Es\ wird\ ein\ Archer\ an\ der\ von\ CanvasBG\ vorgegebenen\ Stelle\ und\ Farbe\r\n\ gezeichnet\r\n\ \r\n
comment2.text=\r\n\ The\ archer\ will\ be\ painted\ at\ the\ pre-set-position\ on\ the\ Canvas\r\n
comment3.params=
comment3.target=void\ eraseArcher()
comment3.target=void\ erase()
comment3.text=\r\n\ The\ archer\ will\ be\ erased\r\n
comment4.params=
comment4.target=void\ stepRight()
comment4.text=\r\n\ The\ archer\ moves\ to\ the\ right\r\n
comment5.params=
comment5.target=void\ stepLeft()
comment5.text=\r\n\ The\ archer\ moves\ to\ the\ right\r\n
comment6.params=
comment6.target=int\ giveXposition()
comment6.text=\r\n\ Supply\ other\ classes\ with\ the\ current\ X\ position\ of\ the\ Archer\r\n
Expand Down
69 changes: 43 additions & 26 deletions Archer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,43 @@
import java.lang.*;

/**
* Beschreiben Sie hier die Klasse Archer.
* Class Archer creates and draws the archers on the Canvas.
* This class is able to move the archers from right to left / left to right.
*
*
* @author (Ihr Name)
* @version v1.2 (02.06.2022 15:35)
* @author Johannes Richter
* Simon Cirdei
* Christoph Schramm
*
* @version v1.3 (02.06.2022 16:45)
*/
public class Archer extends Game
{
private Color color; // color of the arrow
private Canvas screenbg; // canvas where to plot the arrow
private int xPosition, yPosition; //position at the start
private Color color; // color of the archer
private Canvas screenbg; // canvas where to plot the archer
private int xPosition, yPosition; //_position at the start
private int playerno; // number of the player


/**
* Constructor for instances of Archer
*
* @param inputplayer current player
* @param archercolor color of the archer
* @param usedcanvas canvas where to plot the arrow
*/
public Archer(int inputplayer, Color archercolor, Canvas usedcanvas)
{
playerno = inputplayer;
xPosition = super.archerXpos + (playerno-1)*33;
yPosition = super.archerYpos;
playerno = inputplayer;
xPosition = super.archerXpos + (playerno-1)*33; //x-position Archer: access from super-class
yPosition = super.archerYpos; //y-position Archer: access from super-class
color = archercolor;
screenbg = usedcanvas;
}

/**
* Es wird ein Archer an der von CanvasBG vorgegebenen Stelle und Farbe
* gezeichnet
*
* The archer will be painted at the pre-set-position on the Canvas
*/

public void draw()
{
screenbg.setForegroundColor(color);
Expand All @@ -39,33 +49,37 @@ public void draw()
// the body top to bottom
screenbg.drawLine(xPosition+15,yPosition+13,xPosition+15,yPosition+53);
// the arms
screenbg.drawLine(xPosition, yPosition+8,xPosition+15, yPosition+23); //left arm
screenbg.drawLine(xPosition+15,yPosition+23,xPosition+30,yPosition+8); //right arm
screenbg.drawLine(xPosition, yPosition+8,xPosition+15, yPosition+23); //left arm
screenbg.drawLine(xPosition+15,yPosition+23,xPosition+30,yPosition+8); //right arm
// the legs
screenbg.drawLine(xPosition,yPosition+68,xPosition+15,yPosition+53); //left leg
screenbg.drawLine(xPosition,yPosition+68,xPosition+15,yPosition+53); //left leg
screenbg.drawLine(xPosition+15,yPosition+53,xPosition+30,yPosition+68); //right leg
}

public void eraseArcher()
/**
* The archer will be erased
*/
public void erase()
{
screenbg.eraseCircle(xPosition+8,yPosition,14);
screenbg.setForegroundColor(super.bgColor); //da keine Methode, um die Linien zu entfernen existiert, weiß machen
// the head
screenbg.fillCircle(xPosition+8,yPosition,14);
screenbg.setForegroundColor(super.bgColor); //no erase-function: redraw with canvas-backgorund-color
// the body top to bottom
screenbg.drawLine(xPosition+15,yPosition+13,xPosition+15,yPosition+53);
// the arms
screenbg.drawLine(xPosition, yPosition+8,xPosition+15, yPosition+23); //left arm
screenbg.drawLine(xPosition+15,yPosition+23,xPosition+30,yPosition+8); //right arm
screenbg.drawLine(xPosition, yPosition+8,xPosition+15, yPosition+23); //left arm
screenbg.drawLine(xPosition+15,yPosition+23,xPosition+30,yPosition+8); //right arm
// the legs
screenbg.drawLine(xPosition,yPosition+68,xPosition+15,yPosition+53); //left leg
screenbg.drawLine(xPosition,yPosition+68,xPosition+15,yPosition+53); //left leg
screenbg.drawLine(xPosition+15,yPosition+53,xPosition+30,yPosition+68); //right leg
}

/**
* The archer moves to the right
*/
public void stepRight()
{
// Erase at current position
eraseArcher();
erase();

// Calculate new position and decide which direction to walk
xPosition += 1;
Expand All @@ -74,10 +88,13 @@ public void stepRight()
draw();
}

/**
* The archer moves to the right
*/
public void stepLeft()
{
// Erase at current position
eraseArcher();
erase();

// Calculate new position and decide which direction to walk
xPosition -= 1;
Expand All @@ -93,4 +110,4 @@ public int giveXposition()
{
return xPosition;
}
}
}
Binary file modified Arrow.class
Binary file not shown.
4 changes: 2 additions & 2 deletions Arrow.ctxt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#BlueJ class context
comment0.target=Arrow
comment0.text=\r\n\ Arrow\r\n\ \r\n\r\n\ \r\n\ @author\ CS,\ SVC,\ JR\ \r\n\ @version\ v1.2\ (02.06.2022\ 15\:35)\r\n
comment0.text=\r\n\ Class\ Arrow\ calculates\ the\ trajectory\ of\ the\ "arrow".\ \r\n\ This\ class\ is\ able\ to\ draw\ and\ erase\ the\ arrow.\r\n\r\n\ \r\n\ @author\ \ Johannes\ Richter\r\n\ \ \ \ \ \ \ \ \ \ Simon\ Cirdei\r\n\ \ \ \ \ \ \ \ \ \ Christoph\ Schramm\r\n\ \ \ \ \ \ \ \ \ \ \r\n\ @version\ v1.3\ (02.06.2022\ 16\:45)\r\n
comment1.params=inputcolor\ usedcanvas
comment1.target=Arrow(java.awt.Color,\ Canvas)
comment1.text=\r\n\ Constructor\ for\ instances\ of\ Arrow\r\n\r\n\ @param\ xPos\ \ \ \ \ \ \ \ x-coordinate\ of\ the\ arrow\r\n\ @param\ yPos\ \ \ \ \ \ \ \ y-coordinate\ of\ the\ arrow\r\n\ @param\ ballcolor\ \ \ color\ of\ the\ arrow\r\n\ @param\ usedcanvas\ \ canvas\ where\ to\ plot\ the\ arrow\r\n
comment1.text=\r\n\ Constructor\ for\ instances\ of\ Arrow\r\n\r\n\ @param\ inputcolor\ \ color\ of\ the\ arrow\r\n\ @param\ usedcanvas\ \ canvas\ where\ to\ plot\ the\ arrow\r\n
comment2.params=
comment2.target=void\ draw()
comment2.text=\r\n\ Draw\ the\ arrow\ on\ the\ current\ position\ on\ the\ canvas\r\n
Expand Down
33 changes: 17 additions & 16 deletions Arrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,39 @@
import java.util.Random;

/**
* Arrow
*
* Class Arrow calculates the trajectory of the "arrow".
* This class is able to draw and erase the arrow.
*
*
* @author CS, SVC, JR
* @version v1.2 (02.06.2022 15:35)
* @author Johannes Richter
* Simon Cirdei
* Christoph Schramm
*
* @version v1.3 (02.06.2022 16:45)
*/

public class Arrow extends Game
{
private Color localcolor, colpl1, colpl2; // local variant of color of the arrow
private Canvas screenbg; // canvas where to plot the arrow
private int xPosition, yPosition; // position at the start
private int localcurplay;
Random r1 = new Random(); // random number between 0 and 1
Random r2 = new Random(); // random number between 0 and 1
private Color localcolor, colpl1, colpl2; // local variant of color of the arrow
private Canvas screenbg; // canvas where to plot the arrow
private int xPosition, yPosition; // position at the start
private int localcurplay; // count which players turn it is
Random r1 = new Random(); // random number between 0 and 1
Random r2 = new Random(); // random number between 0 and 1
private double speed = super.speedMin + (super.speedMax-super.speedMin) * r1.nextDouble(); // may be 18-30
private double angle = super.angleMin + (super.angleMax-super.angleMin) * r2.nextDouble(); // may be 10-60
private double time = 0;
private double time = 0; // time setting

/**
* Constructor for instances of Arrow
*
* @param xPos x-coordinate of the arrow
* @param yPos y-coordinate of the arrow
* @param ballcolor color of the arrow
* @param inputcolor color of the arrow
* @param usedcanvas canvas where to plot the arrow
*/
public Arrow(Color inputcolor, Canvas usedcanvas)
{
xPosition = super.arrowXpos;
yPosition = super.arrowYpos;
xPosition = super.arrowXpos; //x-Position of the Arrow: access from super-class
yPosition = super.arrowYpos; //y-Position of the Arrow: access from super-class
screenbg = usedcanvas;
localcolor = inputcolor;
}
Expand Down
Binary file modified CanvasBG.class
Binary file not shown.
58 changes: 39 additions & 19 deletions CanvasBG.ctxt
Original file line number Diff line number Diff line change
@@ -1,26 +1,46 @@
#BlueJ class context
comment0.target=CanvasBG
comment0.text=\r\n\ Startet\ Canvas\r\n\ {@code\ Canvas}\r\n\ \r\n\ @author\ CS,\ SVC,\ JR\ \r\n\ @version\ v1.2\ (02.06.2022\ 15\:35)\r\n
comment0.text=\r\n\ The\ class\ CanvasBG\ is\ one\ of\ the\ most\ important\ classes\ for\ the\ game\ 2Darts.\r\n\ The\ class\ is\ able\ to\ draw\:\ \r\n\ \ \ \ \ \ \ \ \ \ -\ the\ target\ of\ the\ dartboard\ \r\n\ \ \ \ \ \ \ \ \ \ -\ the\ two\ archers\r\n\ \ \ \ \ \ \ \ \ \ -\ the\ score\ of\ both\ players\r\n\ \ \ \ \ \ \ \ \ \ \r\n\ CanvasBG\ also\ moves\ the\ arrow\ trough\ the\ dashboard.\ Loops\ calculates\ the\ positions\ and\ points.\r\n\ The\ change\ of\ the\ players\ is\ also\ implemented\ here.\ \r\n\ \r\n\ @author\ \ \ \ \ \ Johannes\ Richter\r\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ Simon\ Cirdei\r\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ Christoph\ Schramm\r\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \r\n\ @version\ \ \ \ \ v1.3\ (02.06.2022\ 16\:45)\r\n
comment1.params=inputa\ starttarget
comment1.target=CanvasBG(short,\ int)
comment1.text=\r\n\ Constructor\ for\ instances\ of\ the\ CanvasBG\ (dashboard)\r\n\r\n\ @param\ inputa\ \ \ \ \ \ \ \ input\ from\ user\ for\ target\ size\r\n\ @param\ startarget\ \ \ \ input\ from\ user\ for\ beginning\ of\ target\r\n
comment10.params=
comment10.target=void\ printArcher()
comment10.text=\r\n\ Draw\ the\ two\ Archers\r\n
comment11.params=currentplno
comment11.target=void\ swapArcher(int)
comment11.text=\r\n\ The\ method\ is\ able\ to\ switch\ the\ players.\ \r\n\ First\ the\ position\ of\ the\ archers\ will\ be\ moved.\r\n\ Methods\ from\ Archer\ are\ used.\r\n
comment12.params=
comment12.target=void\ clearField()
comment12.text=\r\n\ Method\ is\ able\ to\ clear\ the\ arrow\ from\ the\ field\r\n
comment13.params=inputscore1\ inputscore2
comment13.target=void\ printScore(int,\ int)
comment13.text=\r\n\ Draw\ the\ two\ Scores\r\n
comment14.params=state
comment14.target=void\ visible(boolean)
comment14.text=\r\n\ Show\ the\ canvas\r\n
comment2.params=
comment2.target=int\ shootArrow()
comment2.text=\r\n\ Shoot\ an\ arrow\r\n
comment3.params=
comment3.target=void\ printBG()
comment3.text=\r\n\ Draw\ the\ background\r\n
comment4.params=
comment4.target=void\ printArcher()
comment4.text=\r\n\ Draw\ the\ two\ Archers\r\n
comment5.params=currentplno
comment5.target=void\ swapArcher(int)
comment2.text=\r\n\ The\ method\ is\ able\ to\ shoot\ an\ arrow\ on\ the\ dashboard\ with\ correct\ color\r\n
comment3.params=thisArrow
comment3.target=void\ fly(Arrow)
comment3.text=\r\n\ The\ method\ is\ able\ to\ let\ the\ arrow\ fly.\r\n\ A\ loop\ checks\ the\ position\ at\ all\ times.\ \r\n\ Within\ certain\ limits\ the\ loop\ finishes.\r\n
comment4.params=thisArrow
comment4.target=void\ eval(Arrow)
comment4.text=\r\n\ The\ method\ returns\ the\ final\ position\ of\ the\ arrow.\r\n\ If\ the\ position\ is\ in\ the\ defined\ area\ of\ the\ bullseye,\ \r\n\ the\ position\ blinks\ and\ the\ points\ will\ be\ set.\r\n\ \r\n\ Same\ function\ for\ the\ different\ areas.\r\n
comment5.params=
comment5.target=void\ printWall()
comment5.text=\r\n\ The\ method\ draw\ the\ background\ of\ the\ dartboard\ with\ brown.\r\n
comment6.params=
comment6.target=void\ clearField()
comment6.text=\r\n\ Clear\ all\ arrows\r\n
comment7.params=inputscore1\ inputscore2
comment7.target=void\ printScore(int,\ int)
comment7.text=\r\n\ Draw\ the\ two\ Scores\r\n
comment8.params=state
comment8.target=void\ visible(boolean)
comment8.text=\r\n\ Show\ the\ canvas\r\n
numComments=9
comment6.target=void\ printTarget()
comment6.text=\r\n\ Draw\ the\ target\r\n
comment7.params=
comment7.target=void\ printBlack()
comment7.text=\r\n\ Draw\ black\r\n
comment8.params=
comment8.target=void\ printGreen()
comment8.text=\r\n\ Draw\ green\r\n
comment9.params=
comment9.target=void\ printRed()
comment9.text=\r\n\ Draw\ red\r\n
numComments=15
Loading

0 comments on commit 8e60917

Please sign in to comment.