so im creating a top down shooter as my first game, and i have everything working except for a boss & enemies. What I'm wondering how to do is move the enemies down on the screen in those fancy patterns. Also how would I make enemies shoot in the general direction of the player. I have several ideas on how to do this, but I want the most sure fire way to go about this.

so im creating a top down shooter as my first game, and i have everything working except for a boss & enemies. What I'm wondering how to do is move the enemies down on the screen in those fancy patterns. Also how would I make enemies shoot in the general direction of the player. I have several ideas on how to do this, but I want the most sure fire way to go about this.

@Zoto:I think me means like the top-down scrollers where all the enemies fly in patterns past you.IIRC Commando was also like this.

@OP:You basically already have your answer.Each wave will not only have the entities that move around, it would also have a 'waypoint' system upon which the entities move.The waypoins would basically be a chain of vectors. i.e. Start @x/y and move to x1/y1, then x2/y2. etc pp.

For the shooting you could just put in a radius around the entity and when the player is in that radius, let the entities shoot with a random chance.For 'shooting in the general direction' just add a random offset to the xp/yp.

@Zoto:I think me means like the top-down scrollers where all the enemies fly in patterns past you.IIRC Commando was also like this.

@OP:You basically already have your answer.Each wave will not only have the entities that move around, it would also have a 'waypoint' system upon which the entities move.The waypoins would basically be a chain of vectors. i.e. Start @x/y and move to x1/y1, then x2/y2. etc pp.

For the shooting you could just put in a radius around the entity and when the player is in that radius, let the entities shoot with a random chance.For 'shooting in the general direction' just add a random offset to the xp/yp.

I hope this is what you wanted to know.

alright so it was basically what I had in mind. before i get started on that tho i need to fix another problem i have. so i got started on shooting the laser, but I ran into some issues. every time i press space nothing happens. I've already created a counter of the number of times it goes thru & it seems to be working. idk whats wrong. if u dont mind I will post some of my code so u guys can review it. I feel like I'm doing all this inefficiently.

Just to be clear your expected behavior is for the laser to go from the top of the screen down but keep the same x position as the player as the player moves? If it is then it looks like your code should work like that as long as its being called, maybe add a few System.out.println calls to check.

It seems odd that you are drawing the lasers and ship and them immediately moving them to a different position.

There is some nice game loop code in the tutorials section. Using BufferedImages is a lot better than using ImageIcon. Load your images once and reuse them for all the lasers, there is no reason to store multiple identical images in memory.

Just to be clear your expected behavior is for the laser to go from the top of the screen down but keep the same x position as the player as the player moves? If it is then it looks like your code should work like that as long as its being called, maybe add a few System.out.println calls to check.

It seems odd that you are drawing the lasers and ship and them immediately moving them to a different position.

There is some nice game loop code in the tutorials section. Using BufferedImages is a lot better than using ImageIcon. Load your images once and reuse them for all the lasers, there is no reason to store multiple identical images in memory.

well i need to turn in this game on friday & since this is my first game I just want to get the very basics down. After I turn it in ill probably refine it. I'll make sure to checl those tutorials out . ok one other questio I got my bullets to work finnaly(i shoot them & once they go offscreen i remove them). What I want to do is force the player to press the shoot button to only get 1 shot. As of now if you press it 1 time it will shoot as long as you have the ur hand on space. thx in advance

Currently you are allowing a new shot to be fired ever update as long as the spacePressed is true, you will need to add an addition check to see if they can fire.I like to figure out the cool-down time and then set a timer to this cool-down after a shot is fired, then each update you decrement the time elapsed. Doing it this way your 'can fire' check is just seeing if the timer is less than 1.

This is just a simple timer, you probably use something similar in your Class Ani.

Currently you are allowing a new shot to be fired ever update as long as the spacePressed is true, you will need to add an addition check to see if they can fire.I like to figure out the cool-down time and then set a timer to this cool-down after a shot is fired, then each update you decrement the time elapsed. Doing it this way your 'can fire' check is just seeing if the timer is less than 1.

This is just a simple timer, you probably use something similar in your Class Ani.

Ah no the Ani class operates where you have to call update with a deltaTime and that's how it updates the images

well it kinda worked. That got it to be a continuous stream, but if u hold the space button it still keeps shooting. I need it to require you to let go in order to shoot again. Also I've recently created a basic boss. I've kinda got that working, but I need to do some collision detection stuff which I've been having a hard time comprehending. I dont want to use the bounding box method for the boss sprite since its so large & has random gaps. How would I get a mask of the sprite? I have a feeling I have to ignore the transparency some how, but Im still new to all of this so I dont know how. I read somethign about getting RBG's of the sprite then storing them in an array or something...idk lol.

I tried that & it works for like 5 secs then just stops working afterwards. Also I just recently noticed that I can't move diagonaly to my left & shoot at the same time. I have to do one or the other. Sorry to bombard you guys with questions. Its my first game so i gotz me lotz n lotz of questions

The move and shoot problem is easily solved by using booleans for each button. in keyPressed, you set the appropriate boolean to true if that key is down. In keyReleased, you set that boolean to false. Each call to update() you update your logic based on what is pressed and what is not.

Yeah I think the problem is that even if you set "spacePressed" to false, holding it down will still set it back to true in the keyPresed. You should have another boolean, "hasShot" that is set to true when you add the Laser to the ArrayList.Then you set it back to false in your keyReleased method.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org