libgdx How to make multiple enemy arrays? >>Any Help<<

Hey everyone,
I have been given an idea from a friend.
This is what i want to do.

6 birds flying across from left to right of the screen like a one in front of the other and each a little lower than the other.
like ducks flying.
How can i make that as an array and make it repeat every 1 minute (60 seconds) or even a delay?
Any help will be good.

Thank you
shadowMoses

Well, for the delay, you can use Timer. From what you described that’s all I can really tell you.

okay so how will i make an array of these birds???
and the timer.
i only know how to do it in java using sleep() but not in libgdx.

shadowMoses, I saw another post…

[quote]Hello JGO,

How do I make an array?

Thanks in advance,
ShadowMoses
[/quote]
Not sure if srs or…

Anyway, if you are serious, you need to take a step back and the basics of programming, which will include Arrays. This is pretty much what bilznatch said though.

Before getting into game development, I would recommend at least a basic understanding of object oriented programming concepts. There’s nothing wrong with venturing around, but you should at least know the fundamentals or else you’ll probably end up copying and pasting a lot of code.

When dealing with things as dynamic as entities in games, I would actually use something like an ArrayList.

I agree with DarkCat; every minute you can draw the 6 birds. I would just create a method to render the birds, then do whatever game logic you choose. Having an array wouldn’t really be necessary.

Having an array would make the code easier to maintain and organize. Whenever you have a collection of similar objects that need to all be accessed at the same time an array should (IMO) be used.

Don’t get it wrong but you should start from learning a programming language.

  1. Create a Bird object that has initial velocity, width, and height. That has an update method to update its position in each frame when it’s on screen.

  2. In your game world, create an array of x number of bird instances where x is the total birds you want with perhaps random velocities on x axis so they don’t fly with the same ‘speed’.

  3. Setup a timer which can be as easy as having a variable that stores current time and in game update, check if the difference between the saved time and current time say 5 seconds and no bird is on screen, then time to spawn. Spawn the birds.

  4. Also on game update, check if all birds are off screen, start from step 2 again… etc…