diff --git a/src/project/Main.java b/src/project/Main.java index 2f99182..4358b8d 100644 --- a/src/project/Main.java +++ b/src/project/Main.java @@ -34,6 +34,9 @@ public class Main extends Applet { if (score > 80) { new NPC6(g, Px); } + if (score > 140) { + new NPC7(g, Px); // The "grandma NPC", very "slow", good luck + } } private static void playerLocomotion(Graphics g) { diff --git a/src/project/Sprites/NPC1.java b/src/project/Sprites/NPC1.java index 7c42f77..2e27775 100644 --- a/src/project/Sprites/NPC1.java +++ b/src/project/Sprites/NPC1.java @@ -17,7 +17,7 @@ public class NPC1 extends Applet { } public static void make(Graphics g, int Px) { - if (!(y >= 240 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection y += speed; // Moves NPC down according to its speed Expo.setColor(g, SpriteColors.NPC1Body); Expo.fillRectangle(g, x, y + 110, x + 35, y + 170); diff --git a/src/project/Sprites/NPC2.java b/src/project/Sprites/NPC2.java index 1178355..386960f 100644 --- a/src/project/Sprites/NPC2.java +++ b/src/project/Sprites/NPC2.java @@ -17,9 +17,9 @@ public class NPC2 extends Applet { } public static void make(Graphics g, int Px) { - if (!(y >= 240 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection y += speed; // Moves NPC down according to its speed - Expo.setColor(g, SpriteColors.NPC1Body); + Expo.setColor(g, SpriteColors.NPC2Body); Expo.fillRectangle(g, x, y + 110, x + 35, y + 170); Expo.setColor(g, SpriteColors.Tires); Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138); diff --git a/src/project/Sprites/NPC3.java b/src/project/Sprites/NPC3.java index 373f961..d653761 100644 --- a/src/project/Sprites/NPC3.java +++ b/src/project/Sprites/NPC3.java @@ -17,9 +17,9 @@ public class NPC3 extends Applet { } public static void make(Graphics g, int Px) { - if (!(y >= 240 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection y += speed; // Moves NPC down according to its speed - Expo.setColor(g, SpriteColors.NPC1Body); + Expo.setColor(g, SpriteColors.NPC3Body); Expo.fillRectangle(g, x, y + 110, x + 35, y + 170); Expo.setColor(g, SpriteColors.Tires); Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138); diff --git a/src/project/Sprites/NPC4.java b/src/project/Sprites/NPC4.java index 62b93c4..36cd5d3 100644 --- a/src/project/Sprites/NPC4.java +++ b/src/project/Sprites/NPC4.java @@ -17,9 +17,9 @@ public class NPC4 extends Applet { } public static void make(Graphics g, int Px) { - if (!(y >= 240 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection y += speed; // Moves NPC down according to its speed - Expo.setColor(g, SpriteColors.NPC1Body); + Expo.setColor(g, SpriteColors.NPC4Body); Expo.fillRectangle(g, x, y + 110, x + 35, y + 170); Expo.setColor(g, SpriteColors.Tires); Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138); diff --git a/src/project/Sprites/NPC5.java b/src/project/Sprites/NPC5.java index 81daf88..f5e75d8 100644 --- a/src/project/Sprites/NPC5.java +++ b/src/project/Sprites/NPC5.java @@ -17,9 +17,9 @@ public class NPC5 extends Applet { } public static void make(Graphics g, int Px) { - if (!(y >= 240 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection y += speed; // Moves NPC down according to its speed - Expo.setColor(g, SpriteColors.NPC1Body); + Expo.setColor(g, SpriteColors.NPC5Body); Expo.fillRectangle(g, x, y + 110, x + 35, y + 170); Expo.setColor(g, SpriteColors.Tires); Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138); diff --git a/src/project/Sprites/NPC6.java b/src/project/Sprites/NPC6.java index fb390ab..ac14514 100644 --- a/src/project/Sprites/NPC6.java +++ b/src/project/Sprites/NPC6.java @@ -17,9 +17,9 @@ public class NPC6 extends Applet { } public static void make(Graphics g, int Px) { - if (!(y >= 240 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection + if (!(y >= 250 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection y += speed; // Moves NPC down according to its speed - Expo.setColor(g, SpriteColors.NPC1Body); + Expo.setColor(g, SpriteColors.NPC6Body); Expo.fillRectangle(g, x, y + 110, x + 35, y + 170); Expo.setColor(g, SpriteColors.Tires); Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138); diff --git a/src/project/Sprites/NPC7.java b/src/project/Sprites/NPC7.java new file mode 100644 index 0000000..a36ee00 --- /dev/null +++ b/src/project/Sprites/NPC7.java @@ -0,0 +1,39 @@ +package project.Sprites; + +import project.Draw; +import project.Expo; + +import java.applet.Applet; +import java.awt.*; + +public class NPC7 extends Applet { + public static boolean collision = false; + private static int x = Expo.random(100, 400); // Where NPC starts on road + private static int y = -15; // Default starting position for NPC. Negative because NPC is draw from bottom left to top right. + private static int speed = Expo.random(60, 100); // Value to move NPC down + + public NPC7(Graphics g, int Px) { + make(g, Px); + } + + public static void make(Graphics g, int Px) { + if (!(y >= 240 && y <= 350 && x >= Px - 40 && x <= Px + 43)) { // Collision detection + y += speed; // Moves NPC down according to its speed + Expo.setColor(g, SpriteColors.NPC7Body); + Expo.fillRectangle(g, x, y + 110, x + 35, y + 170); + Expo.setColor(g, SpriteColors.Tires); + Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138); + Expo.fillRectangle(g, x + 5, y + 145, x - 5, y + 165); + Expo.fillRectangle(g, x + 30, y + 118, x + 40, y + 138); + Expo.fillRectangle(g, x + 30, y + 145, x + 40, y + 165); + } else { + Draw.end(g); // Draws end screen + collision = true; // Used by Main.java to detect if game is collision + } + if (y > 350) { // Used to "respawn" NPC once its y reaches a certain point. Does this by resetting all variables. + x = Expo.random(100, 400); + y = 25; + speed = Expo.random(60, 100); + } + } +} \ No newline at end of file diff --git a/src/project/Sprites/SpriteColors.java b/src/project/Sprites/SpriteColors.java index 7b4feab..42a9e46 100644 --- a/src/project/Sprites/SpriteColors.java +++ b/src/project/Sprites/SpriteColors.java @@ -6,4 +6,10 @@ public class SpriteColors { static final Color playerBody = new Color(247, 17, 17); static final Color Tires = new Color(0, 0, 0); static final Color NPC1Body = new Color(0, 247, 0); + static final Color NPC2Body = new Color(51, 129, 247); + static final Color NPC3Body = new Color(247, 235, 27); + static final Color NPC4Body = new Color(247, 40, 246); + static final Color NPC5Body = new Color(0, 230, 247); + static final Color NPC6Body = new Color(162, 162, 162); + static final Color NPC7Body = new Color(50, 50, 50); } \ No newline at end of file