Added boss sprites

master
Jamie Munro 2 years ago
parent d180df45e8
commit d96ce52696
  1. 2
      Asteroid0.pde
  2. 2
      Asteroid1.pde
  3. 2
      Asteroid2.pde
  4. 76
      Game.pde
  5. 4
      GunPlatform.pde
  6. 92
      GunPlatformProjectile.pde
  7. 92
      PlayerProjectile.pde
  8. 79
      Projectile.pde
  9. 6
      Saucer.pde
  10. 92
      SaucerProjectile.pde
  11. 6
      config.properties
  12. BIN
      res/sprites/boss0.png
  13. BIN
      res/sprites/boss1.png

@ -10,7 +10,7 @@ public class Asteroid0 implements Enemy {
public static final int INITIAL_HIT_POINTS = 1;
public static final int SCALE_FACTOR = 10;
public static final int CHANCE_OF_SPAWNING = 100;
public static final int MAX_SPEED = 2;
public static final int MAX_SPEED = 5;
private final PImage sprite;
private final int tintR;

@ -10,7 +10,7 @@ public class Asteroid1 extends Asteroid0 {
public static final int MINIMUM_DIFFICULTY = 1;
public static final int SCORE = 100;
public static final int CHANCE_OF_SPAWNING = 25;
public static final int MAX_SPEED = 2;
public static final int MAX_SPEED = 4;
public Asteroid1(int x, int y, PImage sprite, Level level) {
super(x, y, sprite, level);

@ -10,7 +10,7 @@ public class Asteroid2 extends Asteroid0 {
public static final int MINIMUM_DIFFICULTY = 2;
public static final int SCORE = 200;
public static final int CHANCE_OF_SPAWNING = 10;
public static final int MAX_SPEED = 1;
public static final int MAX_SPEED = 3;
public Asteroid2(int x, int y, PImage sprite, Level level) {
super(x, y, sprite, level);

@ -91,11 +91,11 @@ void setup() {
//}
port = new Serial(this, Serial.list()[conf.serialDevice], conf.baudRate);
}
catch (Exception e) {
catch (Exception e) {
println("ERROR: could not access serial port. If your sure the device is connected and you have set the correct serialDevice in config.properties, try running as root/administrator.");
e.printStackTrace();
exit();
}
}
port.bufferUntil(conf.lineEnding);
@ -130,10 +130,10 @@ void setup() {
thread("loadResources");
}
/**
* Called repeatedly, every 1/framerate seconds
*/
void draw(){
/**
* Called repeatedly, every 1/framerate seconds
*/
void draw() {
background(0);
if (loading) {
@ -165,8 +165,7 @@ void draw(){
//println(frameRate);
}
void stop()
{
void stop() {
//Close Minim audio classes
for (String song : music.keySet()) {
music.get(song).close();
@ -179,7 +178,6 @@ void stop()
//Stop Minim before exiting
minim.stop();
// The super.stop() makes sure that all the normal cleanup routines are done
super.stop();
}
@ -238,7 +236,7 @@ void game() {
long currentTime = millis();
long secondsElapsed = (currentTime - startTime) / 1000;
difficulty = 5;//(int) secondsElapsed / 60;
difficulty = (int) secondsElapsed / 60;
checkForRewards();
}
@ -423,7 +421,7 @@ void shoot() {
long currentTime = millis();
if (currentTime - lastShot >= conf.reloadTime) {
playSoundEffect("shoot");
playerProjectiles.add(new PlayerProjectile(player.getX(), player.getY(), player.getRotation(), spriteSet.get("projectile")[0]));
playerProjectiles.add(new Projectile(player.getX(), player.getY(), player.getRotation(), spriteSet.get("player")[10], 10, 1, 260));
lastShot = currentTime;
}
}
@ -463,7 +461,7 @@ void spawnEnemy(boolean debug) {
row = int(random(0, level.getRows()));
}
int r0 = 5;//int(random(0,conf.enemyTypes));
int r0 = int(random(0,conf.enemyTypes));
int r1 = int(random(1, 1001));
switch(r0) {
@ -515,29 +513,29 @@ void spawnEnemy(boolean debug) {
}
}
break;
case 4: {
if ((r1 < GunPlatform.CHANCE_OF_SPAWNING) && (difficulty >= GunPlatform.MINIMUM_DIFFICULTY)) {
enemies.add(new GunPlatform(col, row, spriteSet.get("gunPlatform")[0], spriteSet.get("gunPlatform")[1], player));
if (debug) {
print("GunPlatform spawned at: ");
print(col);
print(", ");
println(row);
}
}
}
case 4: {
if ((r1 < GunPlatform.CHANCE_OF_SPAWNING) && (difficulty >= GunPlatform.MINIMUM_DIFFICULTY)) {
enemies.add(new GunPlatform(col, row, spriteSet.get("gunPlatform")[0], spriteSet.get("gunPlatform")[1], player));
if (debug) {
print("GunPlatform spawned at: ");
print(col);
print(", ");
println(row);
}
}
}
break;
case 5: {
if ((r1 < Saucer.CHANCE_OF_SPAWNING) && (difficulty >= Saucer.MINIMUM_DIFFICULTY)) {
enemies.add(new Saucer(col, row, spriteSet.get("saucer")[0], spriteSet.get("saucer")[1], level, player));
if (debug) {
print("Saucer spawned at: ");
print(col);
print(", ");
println(row);
}
}
}
case 5: {
if ((r1 < Saucer.CHANCE_OF_SPAWNING) && (difficulty >= Saucer.MINIMUM_DIFFICULTY)) {
enemies.add(new Saucer(col, row, spriteSet.get("saucer")[0], spriteSet.get("saucer")[1], level, player));
if (debug) {
print("Saucer spawned at: ");
print(col);
print(", ");
println(row);
}
}
}
break;
}
}
@ -1079,7 +1077,6 @@ void loadResources() {
spriteSet.put("player", loadPlayerSprites());
spriteSet.put("bomb", loadBombSprites());
spriteSet.put("asteroid", loadAsteroidSprites());
spriteSet.put("projectile", loadProjectileSprites());
spriteSet.put("jellyfish", loadJellyfishSprites());
spriteSet.put("gunPlatform", loadGunPlatformSprites());
spriteSet.put("saucer", loadSaucerSprites());
@ -1149,6 +1146,7 @@ PImage[] loadPlayerSprites() {
loadImage(sketchPath() + System.getProperty("file.separator") + conf.spritePath + System.getProperty("file.separator") + "player7.png"),
loadImage(sketchPath() + System.getProperty("file.separator") + conf.spritePath + System.getProperty("file.separator") + "player8.png"),
loadImage(sketchPath() + System.getProperty("file.separator") + conf.spritePath + System.getProperty("file.separator") + "sheild.png"),
loadImage(sketchPath() + System.getProperty("file.separator") + conf.spritePath + System.getProperty("file.separator") + "playerProjectile.png"),
};
return sprites;
@ -1184,14 +1182,6 @@ PImage[] loadJellyfishSprites() {
return sprites;
}
PImage[] loadProjectileSprites() {
PImage[] sprites = {
loadImage(sketchPath() + System.getProperty("file.separator") + conf.spritePath + System.getProperty("file.separator") + "playerProjectile.png")
};
return sprites;
}
PImage[] loadGunPlatformSprites() {
PImage[] sprites = {
loadImage(sketchPath() + System.getProperty("file.separator") + conf.spritePath + System.getProperty("file.separator") + "gunPlatform.png"),

@ -6,7 +6,7 @@
public class GunPlatform implements Enemy {
public static final int MINIMUM_DIFFICULTY = 4;
public static final int SCORE = 600;
public static final int SCORE = 800;
public static final int INITIAL_HIT_POINTS = 1;
public static final int SCALE_FACTOR = 15;
public static final int CHANCE_OF_SPAWNING = 5;
@ -144,7 +144,7 @@ public class GunPlatform implements Enemy {
long currentTime = millis();
if (currentTime - this.lastShot > RELOAD_TIME) {
lastShot = millis();
this.projectile = new GunPlatformProjectile(this.x, this.y, this.rotation, this.projectileSprite);
this.projectile = new Projectile(this.x, this.y, this.rotation, this.projectileSprite, 3, 1, 300);
}
else {
this.projectile = null;

@ -1,92 +0,0 @@
/**
* Copyright 2022 Jamie Munro, All rights reserved
* CS5041 P1
* Game 1
*/
public class GunPlatformProjectile implements Projectile {
public final static int SPEED = 3;
public final static int DAMAGE = 1;
public final static int RANGE = 300;
private final int rotation;
private PImage sprite;
private int x;
private int y;
private int distanceTravelled;
public GunPlatformProjectile(int initialX, int initialY, int initialRotation, PImage sprite) {
this.x = initialX;
this.y = initialY;
this.rotation = initialRotation;
this.sprite = sprite;
this.distanceTravelled = 0;
}
//copy constructor
public GunPlatformProjectile(GunPlatformProjectile projectile) {
this.x = projectile.getX();
this.y = projectile.getY();
this.rotation = projectile.getRotation();
this.sprite = projectile.getSprite();
this.distanceTravelled = 0;
}
@Override
public int getX() {
return this.x;
}
@Override
public int getY() {
return this.y;
}
@Override
public int getRotation() {
return this.rotation;
}
@Override
public PImage getSprite() {
return this.sprite;
}
@Override
public int getSpeed() {
return SPEED;
}
@Override
public int getDamage() {
return DAMAGE;
}
@Override
public int getRange() {
return RANGE;
}
/*
* Update projectile position
* @return true if projectile should be destroyed
*/
@Override
public boolean update() {
distanceTravelled++;
this.x = this.getX() + Math.round(SPEED * sin(radians(this.getRotation())));
this.y = this.getY() + Math.round(SPEED * -cos(radians(this.getRotation())));
if (distanceTravelled >= RANGE) return true;
return Boolean.parseBoolean(level.getTile(this.x, this.y).getProperty("solid"));
}
@Override
public Projectile clone() {
return new GunPlatformProjectile(this);
}
}

@ -1,92 +0,0 @@
/**
* Copyright 2022 Jamie Munro, All rights reserved
* CS5041 P1
* Game 1
*/
public class PlayerProjectile implements Projectile {
public final static int SPEED = 10;
public final static int DAMAGE = 1;
public final static int RANGE = 260;
private final int rotation;
private PImage sprite;
private int x;
private int y;
private int distanceTravelled;
public PlayerProjectile(int initialX, int initialY, int initialRotation, PImage sprite) {
this.x = initialX;
this.y = initialY;
this.rotation = initialRotation;
this.sprite = sprite;
this.distanceTravelled = 0;
}
//copy constructor
public PlayerProjectile(PlayerProjectile projectile) {
this.x = projectile.getX();
this.y = projectile.getY();
this.rotation = projectile.getRotation();
this.sprite = projectile.getSprite();
this.distanceTravelled = 0;
}
@Override
public int getX() {
return this.x;
}
@Override
public int getY() {
return this.y;
}
@Override
public int getRotation() {
return this.rotation;
}
@Override
public PImage getSprite() {
return this.sprite;
}
@Override
public int getSpeed() {
return SPEED;
}
@Override
public int getDamage() {
return DAMAGE;
}
@Override
public int getRange() {
return RANGE;
}
/*
* Update projectile position
* @return true if projectile should be destroyed
*/
@Override
public boolean update() {
distanceTravelled++;
this.x = this.getX() + Math.round(SPEED * sin(radians(this.getRotation())));
this.y = this.getY() + Math.round(SPEED * -cos(radians(this.getRotation())));
if (distanceTravelled >= RANGE) return true;
return Boolean.parseBoolean(level.getTile(this.x, this.y).getProperty("solid"));
}
@Override
public Projectile clone() {
return new PlayerProjectile(this);
}
}

@ -4,15 +4,72 @@
* Game 1
*/
public interface Projectile {
public int getX();
public int getY();
public int getRotation();
public int getSpeed();
public int getDamage();
public int getRange();
public PImage getSprite();
public boolean update();
public Projectile clone();
public class Projectile {
private final int speed;
private final int damage;
private final int range;
private final int rotation;
private PImage sprite;
private int x;
private int y;
private int distanceTravelled;
public Projectile(int initialX, int initialY, int initialRotation, PImage sprite, int speed, int damage, int range) {
this.x = initialX;
this.y = initialY;
this.rotation = initialRotation;
this.sprite = sprite;
this.speed = speed;
this.damage = damage;
this.range = range;
this.distanceTravelled = 0;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getRotation() {
return this.rotation;
}
public PImage getSprite() {
return this.sprite;
}
public int getSpeed() {
return this.speed;
}
public int getDamage() {
return this.damage;
}
public int getRange() {
return this.range;
}
/*
* Update projectile position
* @return true if projectile should be destroyed
*/
public boolean update() {
distanceTravelled++;
this.x = this.getX() + Math.round(this.speed * sin(radians(this.getRotation())));
this.y = this.getY() + Math.round(this.speed * -cos(radians(this.getRotation())));
if (distanceTravelled >= this.range) return true;
return Boolean.parseBoolean(level.getTile(this.x, this.y).getProperty("solid"));
}
}

@ -6,10 +6,10 @@
public class Saucer implements Enemy {
public static final int MINIMUM_DIFFICULTY = 5;
public static final int SCORE = 800;
public static final int SCORE = 1600;
public static final int INITIAL_HIT_POINTS = 1;
public static final int SCALE_FACTOR = 15;
public static final int CHANCE_OF_SPAWNING = 30;
public static final int CHANCE_OF_SPAWNING = 3;
public static final int MAX_SPEED = 1;
public static final int ROTATION_SPEED = 5;
@ -162,7 +162,7 @@ public class Saucer implements Enemy {
long currentTime = millis();
if (currentTime - this.lastShot > RELOAD_TIME) {
lastShot = millis();
this.projectile = new SaucerProjectile(this.x, this.y, this.rotation, this.projectileSprite);
this.projectile = new Projectile(this.x, this.y, this.rotation, this.projectileSprite, 3, 1, 200);
}
else {
this.projectile = null;

@ -1,92 +0,0 @@
/**
* Copyright 2022 Jamie Munro, All rights reserved
* CS5041 P1
* Game 1
*/
public class SaucerProjectile implements Projectile {
public final static int SPEED = 3;
public final static int DAMAGE = 1;
public final static int RANGE = 200;
private final int rotation;
private PImage sprite;
private int x;
private int y;
private int distanceTravelled;
public SaucerProjectile(int initialX, int initialY, int initialRotation, PImage sprite) {
this.x = initialX;
this.y = initialY;
this.rotation = initialRotation;
this.sprite = sprite;
this.distanceTravelled = 0;
}
//copy constructor
public SaucerProjectile(SaucerProjectile projectile) {
this.x = projectile.getX();
this.y = projectile.getY();
this.rotation = projectile.getRotation();
this.sprite = projectile.getSprite();
this.distanceTravelled = 0;
}
@Override
public int getX() {
return this.x;
}
@Override
public int getY() {
return this.y;
}
@Override
public int getRotation() {
return this.rotation;
}
@Override
public PImage getSprite() {
return this.sprite;
}
@Override
public int getSpeed() {
return SPEED;
}
@Override
public int getDamage() {
return DAMAGE;
}
@Override
public int getRange() {
return RANGE;
}
/*
* Update projectile position
* @return true if projectile should be destroyed
*/
@Override
public boolean update() {
distanceTravelled++;
this.x = this.getX() + Math.round(SPEED * sin(radians(this.getRotation())));
this.y = this.getY() + Math.round(SPEED * -cos(radians(this.getRotation())));
if (distanceTravelled >= RANGE) return true;
return Boolean.parseBoolean(level.getTile(this.x, this.y).getProperty("solid"));
}
@Override
public Projectile clone() {
return new SaucerProjectile(this);
}
}

@ -42,10 +42,10 @@ viewportHeight=270
# LEVEL PARAMETERS #
###################################################################################################
#Level width in tiles
levelWidth=1000
levelWidth=5000
#Level Height in tiles
levelHeight=1000
levelHeight=5000
###################################################################################################
# RESOURCE FILEPATHS #
@ -197,7 +197,7 @@ enemyTypes=6
maxPlayerProjectiles=100
#minmium time in between shots (ms)
reloadTime=300
reloadTime=250
#time shielded for after a hit
sheildTime=5000

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Loading…
Cancel
Save