I've taken your code and made some modifications.
Hope it can help you out on your game!
P.S.: Since I don't have your images, I used a square & circle instead.
Just comment those lines out and uncomment the
image() one.
final static List
<KirbyShot> bullets =
new
ArrayList();
PImage spaceR, spaceU;
boolean isBeingPressed;
final
static
byte shipSize = 60, bulletSpd = 5;
final
static
color shipColor1 = #00FF00, shipColor2 = #FF0000;
void
setup() {
size(1280, 800);
frameRate(50);
noSmooth();
imageMode(
CENTER);
rectMode(
CENTER);
ellipseMode(
CENTER);
spaceR =
loadImage(
"kirby_Right.png");
spaceU =
loadImage(
"Kirby_up.png");
}
void
draw() {
background(0);
//image(isBeingPressed ? spaceU : spaceR, mouseX, mouseY);
fill(isBeingPressed ? shipColor2 : shipColor1);
if (isBeingPressed)
ellipse(
mouseX,
mouseY, shipSize, shipSize);
else
rect(
mouseX,
mouseY, shipSize, shipSize);
fill(KirbyShot.c);
for (
int b = bullets.
size(); b !=0; )
if ( bullets.
get(--b).display() ) bullets.remove(b);
}
void
mousePressed() {
isBeingPressed =
true;
bullets.
add(
new KirbyShot(
mouseX,
mouseY, bulletSpd) );
}
void
mouseReleased() {
isBeingPressed =
false;
}
class KirbyShot {
int y;
final
int x, s;
final
static
byte w = 7, h = 50;
final
static
color c = #1CA6B1;
// (28, 166, 177)
KirbyShot(
int xx,
int yy,
int spd) {
x = xx;
y = yy - h;
s = spd;
}
boolean display() {
rect(x, y, w, h);
return (y -= s) < -h;
}
}