Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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 571 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
shadowMoses
Offline DarkCart

JGO Knight


Medals: 15
Projects: 6
Exp: 1 year


Power of the mind over flesh


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

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

Senior Member


Medals: 7
Exp: 1 year



« Reply #3 - Posted 2014-06-13 05:16:19 »

shadowMoses, I saw another post...

Quote
Hello JGO,

How do I make an array?

Thanks in advance,
ShadowMoses

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 opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« 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 Member


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  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (43 views)
2014-09-23 14:38:19

radar3301 (25 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (37 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
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!