im trying to make a small game where you control a character with your mouse and shoot with left clicking while your opponent bounces from left to right and shots randomly at you. i'm having trouble figuring out how to code the bouncing and having the shot stay in a straight line when fired instead of moving with the mouseX.
i am a beginner with this program so please don't judge me and my stupidity :(
also my names are very stupid because i couldn't think of anything better, i apologies
gumgoose VS Dingus
Character gumgoose;
Enemy dingus;
Weapon fire;
Weapon2 arrow;
Wall lb;
Wall rb;
int speed = 1;
int shot = 500;
void setup()
{
size (450,600);
noCursor();
gumgoose = new Character( "gumgoose");
dingus = new Enemy ("dingus");
fire = new Weapon ("fire");
arrow = new Weapon2 ("arrow");
lb = new Wall (0,300, 3, height);
rb = new Wall (447,300,3,height);
}
void draw()
{
background (193, 165, 72);
gumgoose.moveMe (mouseX, 500);
dingus.moveMe (speed, 50);
//if( dingus.isHitting (rb) )
//{
//speed = speed*-1;
// }
fire.moveMe(mouseX, shot);
dingus.drawMe();
gumgoose.drawMe();
fire.drawMe();
arrow.drawMe();
lb.drawMe();
rb.drawMe();
}
Box
class Box
{
// THIS BOX ASSUMES rectMode( CORNER );
// Properties
int x;
int y;
int w;
int h;
color c = color( 0, 255, 0 );
// Constructors
Box( int xx, int yy, int ww, int hh )
{
this.x = xx;
this.y = yy;
this.w = ww;
this.h = hh;
}
// Methods
void drawMe()
{
rectMode(CENTER);
strokeWeight( 1 );
stroke( c );
noFill();
rect( x, y, w, h );
line( x+w/2, y+h/2, x-w/2, y-h/2 );
line( x-h/2, y+w/2, x+h/2, y-w/2 );
}
void moveTo( int newX, int newY )
{
x = newX;
y = newY;
}
boolean isOverlapping( Box otherBox )
{
if ( this.x > otherBox.x + otherBox.w ) return false;