Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  libgdx How to make multiple enemy arrays? >>Any Help<<  (Read 2195 times)
0 Members and 1 Guest are viewing this topic.
Offline shadowMoses

Senior Newbie

Exp: 4-6 months

« Posted 2014-06-12 22:55:15 »

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
Offline DarkCart

JGO Kernel

Medals: 121
Projects: 9
Exp: 50 years

It's all in the mind, y'know.

« Reply #1 - Posted 2014-06-13 01:06:41 »

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

The darkest of carts.
Offline shadowMoses

Senior Newbie

Exp: 4-6 months

« Reply #2 - Posted 2014-06-13 02:42:51 »

okay so how will i make an array of these birds?Huh
and the timer.
i only know how to do it in java using sleep() but not in libgdx.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
« Reply #3 - Posted 2014-06-13 05:16:19 »

shadowMoses, I saw another post...

Hello JGO,

How do I make an array?

Thanks in advance,

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.
Offline ForeseenParadox

Senior Newbie

Medals: 1
Exp: 1 year

« Reply #4 - Posted 2014-06-13 14:22:25 »

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.
Offline AppleSauce
« Reply #5 - Posted 2014-06-13 20:26:45 »

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

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.
Offline Opiop
« Reply #6 - Posted 2014-06-13 20:32:08 »

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.
Offline imagnity

Junior Devvie

Medals: 2
Projects: 1
Exp: 11 years

Coding = Life;

« Reply #7 - Posted 2014-06-17 10:58:05 »

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..

Pages: [1]
  ignore  |  Print  

EgonOlsen (42 views)
2018-06-10 19:43:48

EgonOlsen (22 views)
2018-06-10 19:43:44

EgonOlsen (43 views)
2018-06-10 19:43:20

DesertCoockie (197 views)
2018-05-13 18:23:11

nelsongames (124 views)
2018-04-24 18:15:36

nelsongames (123 views)
2018-04-24 18:14:32

ivj94 (863 views)
2018-03-24 14:47:39

ivj94 (124 views)
2018-03-24 14:46:31

ivj94 (768 views)
2018-03-24 14:43:53

Solater (140 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!