Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Mechanics / Re: Removing Projectiles on: 2013-03-24 23:43:48
That causes the game to crash the when the projectile is added rather than when it is removed. :/

Edit: I switched using straight up Arrays and Longor's method and now it works! Using an Array also drastically increased performance, now my tick timer is all messed up. Thanks to everyone who helped!
2  Game Development / Game Mechanics / Re: Removing Projectiles on: 2013-03-24 23:28:16
Originally the remove was being called from inside the projectiles instance, but then I changed it using the flag method suggest by Agro. That didn't work either. The two instances in which the projectile is removed from the screen is when it leaves the viewing screen and when it hits the player or the AI (depending on who originally shot it). The collision detection is in the loop that I showed in the original post. I'm using
1  
projectiles.remove(a);
to remove the projectile.
3  Game Development / Game Mechanics / Re: Removing Projectiles on: 2013-03-24 23:03:45
The concurrent modification exception still happens.  Undecided
4  Game Development / Game Mechanics / Removing Projectiles on: 2013-03-24 18:43:49
I'm making a game kind of like Super Smash Bros. One of the attacks available to the player is a projectile fireball. All the fireball animation and collision is working perfectly, but whenever the code goes to remove a projectile from the screen, I get the following exception:
1  
2  
3  
4  
5  
6  
Exception in thread "main" java.util.ConcurrentModificationException
        at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
        at java.util.AbstractList$Itr.next(AbstractList.java:343)
        at Main.run(Main.java:213)
        at Main.<init>(Main.java:67)
        at Main.main(Main.java:307)

I'm using the following code for looping and removing:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
 
//looping, this is inside the class that draws everything
for(Attack a: projectiles)
{
      a.update(bg);
}
//removing this is inside the projectile class
public void removeFromWorld()
{
    Main.projectiles.remove(this);
}


Currently I'm using an ArrayList to hold all the projectile data. Would it help if I used a different type of array or made a flag in the projectile class that indicated that the projectile should no longer be updated/drawn?

Thanks for the help!
5  Game Development / Newbie & Debugging Questions / Re: Graphics on: 2012-02-22 17:17:41
To elaborate, I want to draw images into a JFrame or JPanel.
6  Game Development / Newbie & Debugging Questions / Graphics on: 2012-02-21 18:53:24
Hello!
I have everything about my game down except graphics. So I would like to know an effective way to implement them.
I don't want you use anything fancy like lwjgl so please just natural to Java.

Thanks,
Red_dino
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (67 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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