This site requires JavaScript, please enable it in your browser!
Greenfoot back
NathanH
NathanH wrote ...

2011/12/9

Galaga Help

NathanH NathanH

2011/12/9

#
I've started a Galaga project in my Computer Science class and I need some help. I've got the ship, world and everything else done, what I need though is my 3 separate aliens. My teacher suggested I make one alien class and make 3 separate loops with 3 separate images to make the 3 different aliens. I've worked on it for a week now and everywhere I've come to ended up failing. If anyone had a good suggestion for me or a good place to start that'd be amazing. All I need is the 3 aliens.
NathanH NathanH

2011/12/9

#
This is our current code for our Alien class right now (with what the teacher had suggested). It compiles correctly but we just can't get the String to work. import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Alien here. * * @author (your name) * @version (a version number or a date) */ public class Alien extends Actor { private int health; private String aliens; private String image2; private String image3; // public Alien(String img1) { //health = h; //setImage(image); // aliens = img1; } /** * Act - do whatever the Alien wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { } public int getHealth() { return health; } public void hit(int damage) { health = health - damage; if(health <= 0) getWorld().removeObject(this); } }
davmac davmac

2011/12/10

#
What do you mean by "can't get the String to work"? You've got a constructor which takes a String parameter, but you have it commented out. Why?
NathanH NathanH

2011/12/12

#
Whenever we compile it, it gives us an error and were not to sure why. It just crashes and to top it off we can't even get it to appear in our actual game which we have added. I'm not to sure why it's not working. We have it commented out for now so it will at least compile.
davmac davmac

2011/12/12

#
Whenever we compile it, it gives us an error and were not to sure why
Well, what is the error message, and what line of the source code does it appear on? The message is an important clue to figure out what is happening!
NathanH NathanH

2011/12/12

#
Well actually we just got it to work we just using a wrong variable, now we are getting a crash screen talking about the Java space is out of memory or something along those lines. We also can not get our bullet to cause damage even though we have an alien health and a bullet damage amount defined and working. It had worked fine until we added the string.
davmac davmac

2011/12/12

#
Well actually we just got it
Ok, well done.
now we are getting a crash screen talking about the Java space is out of memory or something along those lines
Without seeing pretty much the whole scenario I'm not going to be able to help you with that one. If you like, you can upload the scenario here to greenfoot.org, and I will take a look when I get a chance.
NathanH NathanH

2011/12/12

#
Yeah we could do that I'll post a link when we get it.
NathanH NathanH

2011/12/12

#
Actually I just realized I don't know how to do that, any help?
davmac davmac

2011/12/13

#
Click the "share" button in the Greenfoot window.
NathanH NathanH

2011/12/13

#
Mine is telling me that it can't connect to its host. It might be because I'm on a school computer. We have everything fixed now and we're back on track. We've got all of our aliens working and everything else. We're currently trying to get the aliens to shoot back at us now. Thanks for all of your help though and be willing to help.
You need to login to post a reply.