Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Netbeans IDE / Javascript Introduction This assignment is meant to introdu

ID: 3790324 • Letter: U

Question

Using Netbeans IDE / Javascript

Introduction This assignment is meant to introduce you to the design and development of a simple Java class for use in a visual application. In this assignment you are to implement a class called Pod that represents part of a very simple "video game", for which I have provided the visual application. Game Structure and User Interface Class This is a simple game in which the player (marked moves around a 2D map (currently 15x9 to collect "pods" (marked The game provides buttons ("N", "S "E", and "W") that moves the player one square in the direction north, south, east, or west respectively. The pods themselves are always in motion, moving is a diagonal direction (either NE, NW, SE, or SW). When one reaches the edge of the board, it bounces" off of the wall, changing its direction. When the player reaches the current location of a pod, then that pod is considered "caught" and will no longer be displayed. Here are a few screenshots to give you an idea of how the game works

Explanation / Answer

// The explanantion does'nt talk about diagonal end points for bouncing , it may be included , the code handles it

class Pod {
int x;
int y;
String direction;
int width;
int height ;
Boolean caught=false; // To set the status of Pod ( intially not caught so set ot false)
public Pod(int x,int y, String direction ,int width ,int height){
this.x = x ;
this.y = y ;
this.direction = direction ;
this.width = width ;
this.height = height ;
}
public void move()
{
if(direction.equals("NE")&&y<height-1&&x<width-1) // Four no bouncing cases
{
y++;
x++;
}
else if(direction.equals("SE")&&y>0&&x<width-1)
{
y--;
x++;
}
else if(direction.equals("SW")&&y>0&&x>0)
{
y--;
x--;
}
else if(direction.equals("NW")&&y<height-1&&x>0)
{
y++;
x--;
}
else if(direction.equals("NE")&&y<height-1&&x==width-1) // Four bouncing cases for right and left wall , x axis
{
y++;
x--;
direction = "NW";
}
else if(direction.equals("SE")&&y>0&&x==width-1)
{
y--;
x--;
direction = "SW";
}
else if(direction.equals("SW")&&y>0&&x==0)
{
y--;
x++;
direction = "SE";
}
else if(direction.equals("NW")&&y<height-1&&x==0)
{
y++;
x++;
direction = "NE";
}
else if(direction.equals("NE")&&y==height-1&&x<width-1)  // Four bouncing cases for up and down walls , y axis
{
y--;
x++;
direction = "SE";
}
else if(direction.equals("SE")&&y==0&&x<width-1)
{
y++;
x++;
direction = "NE";
}
else if(direction.equals("SW")&&y==0&&x>0)
{
y++;
x--;
direction = "NW";
}
else if(direction.equals("NW")&&y==height-1&&x>0)
{
y--;
x--;
direction = "SW";
}
else if(direction.equals("NE")&&y==height-1&&x==width-1) // From here onwards for diagonal bouncing
{
y--;
x--;
direction = "SW";
}
else if(direction.equals("SE")&&y==0&&x==width-1)
{
y++;
x--;
direction = "NW";
}
else if(direction.equals("SW")&&y==0&&x==0)
{
y++;
x++;
direction = "NE";
}
else if(direction.equals("NW")&&y==height-1&&x==0)
{
y--;
x++;
direction = "SE";
}
}
public void playerAt(int x,int y)
{
if(this.x==x&&this.y==y)
caught = true ; // Pod is caught is set to true
}
public Boolean isCaught() // To check whether Pod is already Caught
{
return caught ;
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote