Problems with Java particle trail collision for loop -



Problems with Java particle trail collision for loop -

so i'm creating simple game play white star attacking ghosts colliding them, if immortal ghost particle trail gets either shorter or resets (as seen in code) problem collision particle trails doesn't seem work properly, collides if ghost hits tail end of it, when should on tail head, , when nail tail end, though remove ghost list, seems run through calculations more once, example, see `score += 5' instead anywhere between 100 , 500 gets added.

(int = 0; < entityhandler.getenemies().size(); i++) { enemy e = entityhandler.getenemies().get(i); if (collideswith(e)) { if (e.gettype() == ghost_immortal) { traillife = 100; score -= 100; } else { score += 15; traillife -= 5; } entityhandler.removeenemy(e); } (int k = 0; k < trails.size(); k++) { particletrail pt = trails.get(i); if (pt.intersects(e.getbounds())) { if (e.gettype() == ghost_immortal) { traillife += 20; score -= 20; //instead takes away 500 if @ tail end, else doesnt } else score += 5; //instead adds 200-500 if @ tail end, else nil happens entityhandler.removeenemy(e); } } }

as how particle trail beingness created, in case has it:

@override public void tick() { if (alpha > speed) alpha -= speed; else dead = true; } @override public void render(graphics g) { graphics2d g2d = (graphics2d) g; g2d.setcomposite(util.maketransparent(alpha)); g.setcolor(color); drawshape(g); //renderer.fillstar(g, (int) x, (int) y, player_prong_radius, radius, player_prongs); //renderer.fillregularpolygon(g, (int) x, (int) y, radius, player_sides); g2d.setcomposite(util.maketransparent(alpha_visible)); }

and here transparent making method in 'util' class created:

public static alphacomposite maketransparent(float alpha) { int type = alphacomposite.src_over; homecoming alphacomposite.getinstance(type, alpha); }

here's image of application:

java loops collision particle trail

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -