Results 1 to 3 of 3
Thread: Java Game troubles continue
- 01-10-2011, 09:17 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 57
- Rep Power
- 0
Java Game troubles continue
I'm getting confused about how to move a rifle that an enemy would drop on screen so that it obeys the same motions as other objects on screen when you begin to move far enough that the background shifts. If anyone could please help it would be appreciated.
Java Code:public void move(ArrayList alien) // THIS METHOD IS WHERE THE BUG IS { second = alien; x=x+movex; if (v == 2) { v = 0; y=y-movey; if (movey > -25) { movey = movey-1; } } if(x<100) { x=100; grass1.shiftX(); grass2.shiftX(); grass3.shiftX(); for(int p=0; p<second.size(); p++) { Brit enemy2 = (Brit) second.get(p); enemy2.move2(); fourth = enemy2.getSmoothbore(); // Here's the bug. I want to get all rifles //From the enemy class, but the issue is that enemy2 or rifles contained by // enemy2 are not sent to Inner to be painted, so moving them in this way // Does nothing, but I can't think of code to fix this. for(int y=0; y<fourth.size(); y++) { Smoothbore smooth1 = (Smoothbore) fourth.get(y); smooth1.shiftX(); } } } if(x>375) { x=375; grass1.changeX(); grass2.changeX(); grass3.changeX(); for(int o=0; o<second.size(); o++) { Brit enemy2 = (Brit) second.get(o); enemy2.move(); fourth = enemy2.getSmoothbore(); //Same issue here as above for(int u=0; u<fourth.size(); u++) { Smoothbore smooth1 = (Smoothbore) fourth.get(u); smooth1.changeX(); } } } if(y<1) { y=1; } if(y>371) { y=371; } if(y>390) { y=390; } v = v + 1; }
- 01-10-2011, 09:36 PM #2
I think you're going to find yourself needing to resign the structure of part of the application. If multiple objects need to share some bit of arbitrary information (like position at runtime), then perhaps you need to associate both objects with some kind of monitor that allows object to object communication. Best of luck!
- 01-16-2011, 08:55 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 57
- Rep Power
- 0
Similar Threads
-
i'm new to java and having troubles making an ascii animation
By n_cruz21 in forum New To JavaReplies: 6Last Post: 02-13-2012, 09:57 PM -
Java Game troubles
By Fortu in forum New To JavaReplies: 1Last Post: 01-16-2011, 08:53 PM -
Continue or not?
By kliane in forum New To JavaReplies: 3Last Post: 01-19-2010, 02:42 PM -
Troubles,convert C/C++ Code to Java
By cristianll in forum New To JavaReplies: 1Last Post: 11-15-2009, 02:30 AM -
How to use Continue
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:46 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks