Skip to content

Commit a102faf

Browse files
committed
Updated indentation project wide
Made the indentation form to be 4 tab characters instead of spaces.
1 parent 0b4dfea commit a102faf

33 files changed

+679
-724
lines changed

src/com/redomar/game/Game.java

Lines changed: 228 additions & 237 deletions
Large diffs are not rendered by default.

src/com/redomar/game/MouseHandler.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import java.awt.event.MouseMotionListener;
66

77
public class MouseHandler implements MouseListener, MouseMotionListener{
8-
8+
99
private static int mouseX = -1;
1010
private static int mouseY = -1;
1111
private static int mouseB = -1;
12-
12+
1313
public MouseHandler(Game game){
1414
game.addMouseListener(this);
1515
game.addMouseMotionListener(this);
@@ -38,9 +38,9 @@ public void mouseMoved(MouseEvent e) {
3838
}
3939

4040
public void mouseClicked(MouseEvent e) {
41-
41+
4242
}
43-
43+
4444
public void mousePressed(MouseEvent e) {
4545
mouseB = e.getButton();
4646
}
@@ -50,11 +50,11 @@ public void mouseReleased(MouseEvent e) {
5050
}
5151

5252
public void mouseEntered(MouseEvent e) {
53-
53+
5454
}
5555

5656
public void mouseExited(MouseEvent e) {
57-
57+
5858
}
59-
59+
6060
}

src/com/redomar/game/entities/Dummy.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
package com.redomar.game.entities;
22

3-
import java.util.List;
4-
53
import com.redomar.game.Game;
64
import com.redomar.game.entities.efx.Swim;
75
import com.redomar.game.gfx.Colours;
86
import com.redomar.game.gfx.Screen;
97
import com.redomar.game.level.LevelHandler;
108
import com.redomar.game.level.Node;
119

10+
import java.util.List;
11+
1212
public class Dummy extends Mob {
1313

14+
private static double speed = 0.75;
15+
private static int[] collisionBoders = {0, 7, 0, 7};
1416
private int colour, shirtCol, faceCol; // = Colours.get(-1, 111, 240, 310);
1517
private int tickCount = 0;
1618
private double xa = 0;
1719
private double ya = 0;
1820
private boolean[] swimType;
1921
private int[] swimColour;
20-
private static double speed = 0.75;
2122
private List<Node> path = null;
2223
private int time = 0;
23-
private static int[] collisionBoders = {0, 7, 0, 7};
24-
2524
private Swim swim;
2625

2726
public Dummy(LevelHandler level, String name, int x, int y, int shirtCol,
28-
int faceCol) {
27+
int faceCol) {
2928
super(level, name, x, y, speed, collisionBoders);
3029
this.faceCol = faceCol;
3130
this.shirtCol = shirtCol;
@@ -36,8 +35,8 @@ public void tick() {
3635

3736
//List<Player> players = level.getPlayers(this, 8);
3837
aStarMovementAI((int) getX(), (int) getY(), (int) Game.getPlayer().getX(), (int) Game
39-
.getPlayer().getY(), xa, ya, speed, this, path, time);
40-
38+
.getPlayer().getY(), xa, ya, speed, this, path, time);
39+
4140

4241
setSwim(new Swim(level, (int) getX(), (int) getY()));
4342
swimType = swim.swimming(isSwimming, isMagma, isMuddy);
@@ -78,7 +77,7 @@ public void render(Screen screen) {
7877

7978
if (isSwimming || isMagma || isMuddy) {
8079
swimColour = swim.waveCols(isSwimming, isMagma, isMuddy);
81-
80+
8281
int waterColour = 0;
8382
yOffset += 4;
8483

src/com/redomar/game/entities/Mob.java

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package com.redomar.game.entities;
22

3-
import java.util.ArrayList;
4-
import java.util.List;
5-
import java.util.Random;
6-
73
import com.redomar.game.entities.projectiles.Medium;
84
import com.redomar.game.entities.projectiles.Projectile;
95
import com.redomar.game.entities.projectiles.Small;
@@ -12,6 +8,10 @@
128
import com.redomar.game.level.tiles.Tile;
139
import com.redomar.game.lib.utils.Vector2i;
1410

11+
import java.util.ArrayList;
12+
import java.util.List;
13+
import java.util.Random;
14+
1515
public abstract class Mob extends Entity {
1616

1717
protected Random random = new Random();
@@ -32,7 +32,7 @@ public abstract class Mob extends Entity {
3232
* [3] Contains the <strong>yMax</strong>
3333
*/
3434
protected int[] collisionBoders = new int[4];
35-
35+
3636
protected List<Projectile> projectiles = new ArrayList<Projectile>();
3737

3838
public Mob(LevelHandler level, String name, int x, int y, double speed, int[] collisionBoders) {
@@ -52,13 +52,13 @@ public void move(double xa, double ya) {
5252
return;
5353
}
5454
numSteps++;
55-
55+
5656
//Moving Directions
5757
//0 = Facing UP
5858
//1 = Facing Down
5959
//2 = Facing Left
6060
//3 = Facing Right
61-
61+
6262
if (ya < 0) {
6363
movingDir = 0;
6464
}
@@ -85,7 +85,7 @@ public void move(double xa, double ya) {
8585
xa = 0;
8686
}
8787
}
88-
88+
8989
while (ya != 0){
9090
if (Math.abs(ya) > 1){
9191
if (!hasCollided(xa, abs(ya))) {
@@ -99,7 +99,7 @@ public void move(double xa, double ya) {
9999
ya = 0;
100100
}
101101
}
102-
102+
103103
}
104104

105105
public boolean hasCollided(double xa, double ya){
@@ -134,7 +134,7 @@ public boolean hasCollided(double xa, double ya){
134134

135135
return false;
136136
}
137-
137+
138138
public boolean hasCollidedAlt(int xa, int ya){
139139
boolean solid = false;
140140
for (int c = 0; c < 4; c++) {
@@ -148,7 +148,7 @@ public boolean hasCollidedAlt(int xa, int ya){
148148
}
149149
return solid;
150150
}
151-
151+
152152
private int abs(double i){
153153
if (i < 0) return -1;
154154
return 1;
@@ -165,15 +165,12 @@ protected boolean isSolid(int xa, int ya, int x, int y) {
165165
Tile newtTile = level.getTile(((int) this.getX() + x + xa) >> 3, ((int) this.getY()
166166
+ y + ya) >> 3);
167167

168-
if (!lastTile.equals(newtTile) && newtTile.isSolid()) {
169-
return true;
170-
}
168+
return !lastTile.equals(newtTile) && newtTile.isSolid();
171169

172-
return false;
173170
}
174-
171+
175172
protected void aStarMovementAI(int x, int y, int px, int py, double xa,
176-
double ya, double speed, Mob mob, List<Node> path, int time){
173+
double ya, double speed, Mob mob, List<Node> path, int time) {
177174
xa = 0;
178175
ya = 0;
179176
Vector2i start = new Vector2i(x >> 3, y >> 3);
@@ -192,7 +189,7 @@ protected void aStarMovementAI(int x, int y, int px, int py, double xa,
192189
}
193190

194191
protected void followMovementAI(int x, int y, int px, int py, double xa,
195-
double ya, double speed, Mob mob) {
192+
double ya, double speed, Mob mob) {
196193
ya = 0;
197194
xa = 0;
198195
if (px > x)
@@ -205,7 +202,7 @@ protected void followMovementAI(int x, int y, int px, int py, double xa,
205202
ya-=speed;
206203
moveMob(xa, ya, mob);
207204
}
208-
205+
209206
protected double[] randomMovementAI(double x, double y, double xa, double ya, int tick) {
210207
if (tick % (random.nextInt(50) + 30) == 0) {
211208
xa = random.nextInt(3) - 1;
@@ -233,7 +230,7 @@ protected void moveMob(double xa, double ya, Mob mob) {
233230
mob.isMoving = false;
234231
}
235232
}
236-
233+
237234
protected void shoot(double x, double y, double dir, double buttonId, boolean secondry){
238235
// dir = dir * (180 /Math.PI);
239236
// Printing print = new Printing();
@@ -253,21 +250,21 @@ public String getName() {
253250
return name;
254251
}
255252

253+
public int getNumSteps() {
254+
return numSteps;
255+
}
256+
256257
public void setNumSteps(int numSteps) {
257258
this.numSteps = numSteps;
258259
}
259260

260-
public int getNumSteps() {
261-
return numSteps;
261+
public boolean isMoving() {
262+
return this.isMoving;
262263
}
263264

264265
public void setMoving(boolean isMoving) {
265266
this.isMoving = isMoving;
266267
}
267-
268-
public boolean isMoving(){
269-
return this.isMoving;
270-
}
271268

272269
public void setMovingDir(int movingDir) {
273270
this.movingDir = movingDir;

src/com/redomar/game/entities/Player.java

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,21 @@
1616

1717
public class Player extends Mob {
1818

19-
private InputHandler input;
2019
private static Name customeName = new Name();
21-
private Swim swim;
22-
20+
public static String guestPlayerName = customeName.setName("Player ");
2321
private static double speed = 1;
24-
22+
private static int[] collisionBoders = {-2, 8, 0, 7};
23+
private InputHandler input;
24+
private Swim swim;
2525
private int colour, shirtCol, faceCol;
2626
private int tickCount = 0;
2727
private String userName;
2828
private boolean[] swimType;
2929
private int[] swimColour;
30-
private static int[] collisionBoders = {-2, 8, 0, 7};
3130
private int fireRate = 0;
3231

33-
public static String guestPlayerName = customeName.setName("Player ");
34-
3532
public Player(LevelHandler level, int x, int y, InputHandler input,
36-
String userName, int shirtCol, int faceCol) {
33+
String userName, int shirtCol, int faceCol) {
3734
super(level, "Player", x, y, speed, collisionBoders);
3835
this.input = input;
3936
this.userName = userName;
@@ -43,6 +40,14 @@ public Player(LevelHandler level, int x, int y, InputHandler input,
4340
fireRate = Small.FIRE_RATE;
4441
}
4542

43+
public static double getSpeed() {
44+
return speed;
45+
}
46+
47+
public static void setSpeed(double speed) {
48+
Player.speed = speed;
49+
}
50+
4651
public void tick() {
4752
double xa = 0;
4853
double ya = 0;
@@ -61,13 +66,13 @@ public void tick() {
6166
xa += speed;
6267
}
6368
}
64-
69+
6570
if(fireRate > 0) fireRate--;
66-
71+
6772
if (Game.getMouse().getButton() == 1 || Game.getMouse().getButton() == 3){
6873
if(fireRate <= 0){
6974
if(Game.getMouse().getButton()== 1){
70-
fireRate = Small.FIRE_RATE;
75+
fireRate = Small.FIRE_RATE;
7176
}else if(Game.getMouse().getButton() == 3){
7277
fireRate = Medium.FIRE_RATE;
7378
}
@@ -76,10 +81,10 @@ public void tick() {
7681
double dy = Game.getMouse().getY() - 320/2;
7782
double dir = Math.atan2(dy, dx);
7883
shoot(x, y, dir, Game.getMouse().getButton(), false);
79-
}
84+
}
8085
}
8186
}
82-
87+
8388
for (int i = 0; i < projectiles.size(); i++) {
8489
Projectile p = projectiles.get(i);
8590
if(p.isRemoved()){
@@ -121,7 +126,7 @@ public void render(Screen screen) {
121126
int walkingSpeed = 4;
122127
int flipTop = (numSteps >> walkingSpeed) & 1;
123128
int flipBottom = (numSteps >> walkingSpeed) & 1;
124-
129+
125130
Inventory.activate();
126131

127132
if (movingDir == 1) {
@@ -149,7 +154,7 @@ public void render(Screen screen) {
149154

150155
if(isSwimming || isMagma || isMuddy){
151156
swimColour = swim.waveCols(isSwimming, isMagma, isMuddy);
152-
157+
153158
int waterColour = 0;
154159
yOffset += 4;
155160

@@ -185,22 +190,21 @@ public void render(Screen screen) {
185190
(yOffset + modifier), ((xTile + 1) + (yTile + 1) * 32),
186191
colour, flipBottom, scale);
187192
colour = Colours.get(-1, 111, shirtCol, faceCol);
188-
;
189193
}
190194

191-
if (userName != null) {
195+
if (userName != null) {
192196
/*
193197
* Improved userName centering above player's sprite.
194198
* Using player's own x value cast to int with an adjusted formula
195199
* -posmicanomaly
196200
*/
197201
int fontCharSize = 8;
198-
Font.render(userName,
199-
screen,
202+
Font.render(userName,
203+
screen,
200204
(int)x - ((userName.length() /2) * fontCharSize),
201205
yOffset - 10,
202206
Colours.get(-1, -1, -1, 555), 1);
203-
207+
204208
}
205209
}
206210

@@ -231,12 +235,4 @@ public void setSwim(Swim swim) {
231235
this.swim = swim;
232236
}
233237

234-
public static double getSpeed() {
235-
return speed;
236-
}
237-
238-
public static void setSpeed(double speed) {
239-
Player.speed = speed;
240-
}
241-
242238
}

0 commit comments

Comments
 (0)