Hi everyone!
I posted here a few days ago and was promptly advised on how to solve my problem, which was creating bullets for a 'shoot-em-up' style game that i'm attempting to make. (thank you phi.lho!)
I have since had to learn a different method for storing, displaying and removing the individual bullets on a condition. (due to the fact that the other method didn't work on processing.js for reasons i can't remember)
I've hit another series of problems that I sincerely can not see how to solve...
As you would see by running the code, the bullets conditionally disappear properly, but only are affected by one of the enemies (i'm assuming it's either the first or last created), and only that same enemy can be 'damaged' and 'destroyed'. Also, the enemy is only affected damage-wise by the first bullet created onscreen... EDIT: This version doesn't do any of those things... looks like I messed up the code before I posted it. =(
(another thing that bugs me is the wonky and buggy controls which i'm sure you'll notice, but that's not extremely high priority and i would probably be able to fix it on my own. any advice about it is extremely welcome, though!)
Again thanks SO much to whoever takes the time to read this and help, honestly. =)
Player ship;
float plXpos;
float plYpos;
float shipXSpd;
float shipYSpd;
ArrayList bullets;
int bNum;
ArrayList enemies;
int eNum;
int stream1x() {return int(plXpos);}
//int stream2x() {return int(plXpos + 10);}
int streamy() {return int(plYpos - 25);}
int randclr() {return int(random(100,255));}
int randx() {return int(random(20,580));}
int randhund() {return int(random(0,100));}
int frameCounter;
boolean bShooting;
boolean bulletHit;
boolean enemyHit;
boolean enemyDie;
int score;
void setup() {
frameRate(60);
size(600,800);
ship = new Player(300,700);
bullets = new ArrayList();
enemies = new ArrayList();
}
void draw() {
background(20);
noCursor();
fill(255);
text("Score: "+score, 0, 10);
ship.movement();
ship.display();
for (int eNum = enemies.size()-1; eNum >= 0; eNum--) {
Enemy enemy = (Enemy) enemies.get(eNum);
enemy.move();
enemy.display();
enemy.eDeathChk();
if (enemy.offscreen() || enemyDie == true) {
enemies.remove(eNum);
}
if (enemyDie == true) {
score = score + 100;
}
}
for (int h = enemies.size(); h < 2; h++) {
enemies.add(new Enemy(randx(), 0, 15, 30));
break;
}
for (int bNum = bullets.size()-1; bNum >= 0; bNum--) {
Hey guys! I'm really new to Processing and I have a possibly very stupid question to ask.
I don't have any prior programming experience. The most coding experience I have in any language is HTML/CSS and JavaScript. (processing.js was what caught my eye)
Anyway, enough about my life's story, lol.
I read through all the tutorials in the Learning section and realized I could probably make a game with Processing.
I decided to try to make a really simple top-view shoot-em-up, kinda like the arcade game 1942.
I haven't even bothered to try coding collisions or independent enemy movements, for now I just want to get the very basics working.
And I am almost literally being driven up the wall by the basics.
I can't for the life of me figure out how to shoot a proper bullet on a mouseclick.
If any of you could be so kind as to look at my code and maybe give me a nudge in the right direction, I would appreciate your help endlessly.
It's probably really messy and illogical, even though I tried my hardest to use logic and combine what I learned from the tutorials.
Again, thanks so much to whoever has the time/is willing to help me.
Player ship; Projectile bullet[]; int enemySize = 10;