-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRocketShell.java
112 lines (102 loc) · 3.83 KB
/
RocketShell.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/**
* <p><b>File name: </b> RocketShell.java
* @version 1.0
* @since 06.09.2018
* <p><b>Last modification date: </b> 07.09.2018
* @author Alexandru F. Dascalu
* <p><b>Copyright (C)</b> 2018 Alexandru F. Dascalu
*
* <p>RocketShell.java is part of Panzer Batallion.
* Panzer Batallion is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* <p>This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* <p>You should have received a copy of the GNU General Public License v3
* along with this program. If not, see <a href="https://www.gnu.org/licenses/">https://www.gnu.org/licenses/</a> .
*
* <p>A summary of the license can be found here:
* <a href="https://choosealicense.com/licenses/gpl-3.0/">https://choosealicense.com/licenses/gpl-3.0/</a> .
*
* <p><b>Purpose: </b>
* <p> This class models a tank rockets shell for a Greenfoot recreation of the
* Wii Tanks game for the Nintendo Wii. It moves faster than the normal
* shells, does not bounce when hitting a wall or the boundary of the world and
* destroys tanks and other shells that it hits. It also makes landmines that
* it intersects explode, but that is handled in the LandMine class.
*
* <p><b>Version History</b>
* <p> -1.0 - Created the class.
*/
public class RocketShell extends Shell
{
/**The speed with which all shells move. The value is {@value}.*/
private static final int SHELL_SPEED=6;
/**The number of times the shell is allowed to bounce off a wall.The value
* is {@value}.*/
public static final int TIMES_ALLOWED_TO_BOUNCE=0;
/**The length of the shell in pixels. Used in calculations for bouncing, so
* it has to be precise. The value is {@value}.*/
private static final int LENGTH = 37;
/**The with of the shell in pixels. Used in calculations for bouncing, so
* it has to be precise. The value is {@value}.*/
private static final int WIDTH = 15;
/**
* Makes a new rocket shell at the given coordinates and with the rotation
* given.
* @param rotation The rotation of the new shell, the same as the rotation
* of the turret that fired it when it was fired.
* @param parent The tank whose turret fired this shell.
* @param x The x coordinate where the new shell will be put.
* @param y The y coordinate where the new shell will be put.
*/
public RocketShell(int rotation, Tank parent, int x, int y)
{
//just call the superclass constructor
super(rotation, parent, x ,y);
}
/**
* The speed of this shell, meaning the distance in cells that the shell moves
* each time the move(int) method is called.
* @return the speed of this type of shells, defined by a static constant.
*/
@Override
public int getSpeed()
{
return SHELL_SPEED;
}
/**
* Gets the number of times the shell is allowed to bounce off a wall. We
* have this method despite the fact it returns a public constant so that
* we can override for different types of shells.
* @return the number of times the shell is allowed to bounce off a wall.
*/
@Override
public int getBounceLimit()
{
return TIMES_ALLOWED_TO_BOUNCE;
}
/**
* Gets the length of this shell.
* @return the length of this shell, in pixels.
*/
@Override
public int getLength()
{
return LENGTH;
}
/**
* Gets the width of this shell.
* @return the width of this shell, in pixels.
*/
@Override
public int getWidth()
{
return WIDTH;
}
}