Results 1 to 6 of 6
Thread: Space Invaders help!
- 03-04-2010, 03:31 PM #1
Member
- Join Date
- Mar 2010
- Posts
- 3
- Rep Power
- 0
Space Invaders help!
Hi
I am trying to enhance a version of space invaders for an assignment and i have managed to align the 'aliens' in a row, but i cant work out how to get multiple rows underneath the first row (x).
I have tried x+1 and various others but i am stuck, can anyone help please?
Thanks in advance :D
x
- 03-04-2010, 03:47 PM #2
it might help to see some of the relevant bits of code, inside code tags,
i'm pretty new but can i ask are you using two nested for loops to set them out
sonny:p I still have my "L" plates on...... directions and explanations are far more help than blaring your Horn! :p Watching:CS106a on YouTube \Reading The Art & Science of Java by Eric S Roberts
- 03-04-2010, 04:02 PM #3
Member
- Join Date
- Mar 2010
- Posts
- 3
- Rep Power
- 0
Hi thanks for the help :D
ill post the code i have that aligns the first horizontal row of 6 of the aliens.
public void initWorld() {
actors = new ArrayList();
for (int i = 0; i < 6; i++){ // amount of vertical space invaders
Monster m = new Monster(this);
m.setX( (int)(Stage.HEIGHT) );
m.setX( i*70 ); //width gap between space invaders
m.setVx( (int)(15-10) );
actors.add(m);
i need to do another 5 rows of aliens underneath this but im not sure how to shift the rows down by 1 each time, if that makes sense?
xx
- 03-04-2010, 04:14 PM #4
like I said im still new to this but i think you nedd to do something like this
}Java Code:public void initWorld() { actors = new ArrayList(); for (int k =0: k <5; k++) { // sets out 5 rows for (int i = 0; i < 6; i++){ // amount of vertical space invaders Monster m = new Monster(this); m.setX( (int)(Stage.HEIGHT) ); m.setX( i*70 ); //width gap between space invaders m.setVx( (int)(15-10) ); actors.add(m);
}
you may need to use the K index somewhere to set out the height in the vertical.
hope this helps:p I still have my "L" plates on...... directions and explanations are far more help than blaring your Horn! :p Watching:CS106a on YouTube \Reading The Art & Science of Java by Eric S Roberts
- 03-04-2010, 04:21 PM #5
Member
- Join Date
- Mar 2010
- Posts
- 3
- Rep Power
- 0
i tried to put the 'k' in like you said but it hasnt made the extra rows i need. would i have to put the k index in one of the other classes too? or define it somewhere else?
- 03-04-2010, 04:38 PM #6
not sure really, has it set out the rows on top of each other? so it loooks like one row.
you have used the index i
presumably this sets a distance across from left to rightJava Code:m.setX( i*70 ); //width gap between space invaders
you will have to use the k index to set out the vertical distances
does this bit have something to do with the vertical spacing
Java Code:m.setVx( (int)(15-10)
:p I still have my "L" plates on...... directions and explanations are far more help than blaring your Horn! :p Watching:CS106a on YouTube \Reading The Art & Science of Java by Eric S Roberts
Similar Threads
-
add a space after 10 lines?
By ukemasta in forum New To JavaReplies: 10Last Post: 01-20-2010, 12:12 PM -
SWT Canvas drawing realtive to image space not canvas space.
By bobbie in forum SWT / JFaceReplies: 0Last Post: 07-05-2009, 12:31 PM -
Blank space
By sandy1028 in forum New To JavaReplies: 1Last Post: 04-21-2009, 10:00 AM -
space between images !!
By nhawlman in forum New To JavaReplies: 1Last Post: 01-09-2009, 11:17 PM -
Space Exploration dev 6
By JavaBean in forum Java SoftwareReplies: 0Last Post: 03-25-2008, 04:48 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks