NPC change at 140 clicks
Signed-off-by: officereso <qrs01@snowtx.com>
This commit is contained in:
parent
04cccbdef1
commit
3703cd34c0
@ -34,6 +34,9 @@ public class Main extends Applet {
|
|||||||
if (score > 80) {
|
if (score > 80) {
|
||||||
new NPC6(g, Px);
|
new NPC6(g, Px);
|
||||||
}
|
}
|
||||||
|
if (score > 140) {
|
||||||
|
new NPC7(g, Px); // The "grandma NPC", very "slow", good luck
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void playerLocomotion(Graphics g) {
|
private static void playerLocomotion(Graphics g) {
|
||||||
|
@ -17,7 +17,7 @@ public class NPC1 extends Applet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void make(Graphics g, int Px) {
|
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
|
y += speed; // Moves NPC down according to its speed
|
||||||
Expo.setColor(g, SpriteColors.NPC1Body);
|
Expo.setColor(g, SpriteColors.NPC1Body);
|
||||||
Expo.fillRectangle(g, x, y + 110, x + 35, y + 170);
|
Expo.fillRectangle(g, x, y + 110, x + 35, y + 170);
|
||||||
|
@ -17,9 +17,9 @@ public class NPC2 extends Applet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void make(Graphics g, int Px) {
|
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
|
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.fillRectangle(g, x, y + 110, x + 35, y + 170);
|
||||||
Expo.setColor(g, SpriteColors.Tires);
|
Expo.setColor(g, SpriteColors.Tires);
|
||||||
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
||||||
|
@ -17,9 +17,9 @@ public class NPC3 extends Applet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void make(Graphics g, int Px) {
|
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
|
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.fillRectangle(g, x, y + 110, x + 35, y + 170);
|
||||||
Expo.setColor(g, SpriteColors.Tires);
|
Expo.setColor(g, SpriteColors.Tires);
|
||||||
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
||||||
|
@ -17,9 +17,9 @@ public class NPC4 extends Applet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void make(Graphics g, int Px) {
|
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
|
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.fillRectangle(g, x, y + 110, x + 35, y + 170);
|
||||||
Expo.setColor(g, SpriteColors.Tires);
|
Expo.setColor(g, SpriteColors.Tires);
|
||||||
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
||||||
|
@ -17,9 +17,9 @@ public class NPC5 extends Applet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void make(Graphics g, int Px) {
|
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
|
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.fillRectangle(g, x, y + 110, x + 35, y + 170);
|
||||||
Expo.setColor(g, SpriteColors.Tires);
|
Expo.setColor(g, SpriteColors.Tires);
|
||||||
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
||||||
|
@ -17,9 +17,9 @@ public class NPC6 extends Applet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void make(Graphics g, int Px) {
|
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
|
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.fillRectangle(g, x, y + 110, x + 35, y + 170);
|
||||||
Expo.setColor(g, SpriteColors.Tires);
|
Expo.setColor(g, SpriteColors.Tires);
|
||||||
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
Expo.fillRectangle(g, x + 5, y + 118, x - 5, y + 138);
|
||||||
|
39
src/project/Sprites/NPC7.java
Normal file
39
src/project/Sprites/NPC7.java
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,4 +6,10 @@ public class SpriteColors {
|
|||||||
static final Color playerBody = new Color(247, 17, 17);
|
static final Color playerBody = new Color(247, 17, 17);
|
||||||
static final Color Tires = new Color(0, 0, 0);
|
static final Color Tires = new Color(0, 0, 0);
|
||||||
static final Color NPC1Body = new Color(0, 247, 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);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user