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

Comments for Archerman

Return to Archerman

SamSkinnerSamSkinner

2009/11/18

Thanks so much, kensh. I got it. :)
A new version of this scenario was uploaded on Thu Nov 19 00:02:43 UTC 2009
A new version of this scenario was uploaded on Thu Nov 19 01:40:08 UTC 2009
SamSkinnerSamSkinner

2009/11/19

Can anyone help me with not allowing the the figure to move through the crates?
A new version of this scenario was uploaded on Thu Nov 19 03:30:07 UTC 2009
kenshinakhkenshinakh

2009/11/19

You can try using getOneIntersectingObject(Crate.class); and then you have to check if the crate's getX() is > than figure's getX() (meaning the crate is to the right).
SamSkinnerSamSkinner

2009/11/19

Yeah, but what code do I use to not let my character move the direction towards the box but move all other ways?
kenshinakhkenshinakh

2009/11/19

Hm. You can tell the character if it is not clear in front (you can call a separate boolean method that does the check here), and if it is not clear, do not move.
ZergZerg

2009/11/19

Sound effects are always a plus!
SamSkinnerSamSkinner

2009/11/19

But if I say 'do not move' then I can't move AWAY from the box either. Zerg, I will add some eventually. First I want to work out all the glitches and get up to about level 3 at it's previous stage. :)
kenshinakhkenshinakh

2009/11/19

To be able to move away, the boolean should only return true when going right, and there is a box. If there is a box to the right, but left is pressed, moving is possible. (Something along the line like that>).
A new version of this scenario was uploaded on Thu Nov 19 23:54:19 UTC 2009
A new version of this scenario was uploaded on Thu Nov 19 23:56:03 UTC 2009
SamSkinnerSamSkinner

2009/11/20

I got the crate thing. :) Great. Thanks.
A new version of this scenario was uploaded on Sat Nov 21 04:44:07 UTC 2009
kenshinakhkenshinakh

2009/11/21

so far so good :-), There's a tiny bug when you jump onto a crate. It sometimes have the person stick half way in the crate.
TigrexTigrex

2009/11/21

Ha, I like this one! my favourite one! Left an "I like it"
TigrexTigrex

2009/11/21

Where do you get yout images from?? do you use a proggramm to create them by yourself? If so, which programm??
MTKMTK

2009/11/21

I seriously recommend the GIMP.
SamSkinnerSamSkinner

2009/11/21

@ kensh, really? I haven't noticed that happen to me. I'll look into it though. :) @ Tigrex, Thanks!! :D I am drawing all the pictures myself in Photoshop. @ MTK, what do you mean?
MTKMTK

2009/11/21

I mean the GNU Image Manipulation Program (and Inkscape). It's Free/Open Source and served me much better than Paint Shop Pro or Photoshop.
SamSkinnerSamSkinner

2009/11/21

Really? Hm, I'll look into it. Thanks. :)
TheJHTheJH

2009/11/21

I found two bugs: When you fire when you reached the highest position you can jump at from your location, you fall down, but stop a little bit above the ground. And you can jump into these boxes from the side.
SamSkinnerSamSkinner

2009/11/21

I don't get the stopping just above the ground thing. I'm not sure how to fix that, but it's not that big a deal. Also, I don't know how to fix the other either. Thanks though. :)
MTKMTK

2009/11/21

To keep the character from sinking into the ground, I would run a while loop on every act that checks if the character is sunken and if so, raises the character 1 pixel. You can do similarly in all 4 directions. Be sure to use a while loop, not an if statement: with the while loop, the character will just fall and land perfectly right away, with the if he will slowly rise out of the floor frame by frame instead. I haven't tried this, but I guess you can loop-increment the position 1 by 1 too, this might keep the character from flying right through the floor when falling fast: while((int) y > getY() && !hitFloor) { setLocation(getX(), getY()+1); } while((int) y < getY() && !hitHead) { setLocation(getX(), getY()-1); } Instead of setLocation(getX(), (int) y);
SamSkinnerSamSkinner

2009/11/21

But what is the hitFloor and hitHead code?
A new version of this scenario was uploaded on Sat Nov 21 20:47:35 UTC 2009
MTKMTK

2009/11/21

hitFloor checks if the bottom-center pixel of the character's image is intersecting ground.
MTKMTK

2009/11/21

I see that that in the third level when you shoot the guy on a crate arrows are still spawned.
SamSkinnerSamSkinner

2009/11/21

Yeah, MTK. I can't think of a way to fix this. The arrow is a class called Arrowleft and the archer is a class called Archer1. Can you think of anything?
MTKMTK

2009/11/21

Make it so that Archer1 creates Arrowleft's.
A new version of this scenario was uploaded on Sat Nov 21 21:50:55 UTC 2009
SamSkinnerSamSkinner

2009/11/21

I tried that just now using the same counter method I used for the Figure firing, but for some reason the Archer shot, then shot again, then shot again a bit sooner until it eventually became a constant stream. :\
ZergZerg

2009/11/21

What you should do is instead of having the arrow reset when it reaches the end, have it remove itself. Then you can have the Archer1 create a new Arrowleft.
ZergZerg

2009/11/21

The code for having the arrow remove itself would be something like getWorld().removeObject(this); The benefit to doing it this way is you don't have to add both an arrow and an archer in the level constructor. You just add the archer, and have the archer add the arrows! Then you can do things like having archers move, or having archers spawn at different locations!
SamSkinnerSamSkinner

2009/11/21

But can you help me with coding the Archer to add the arrows himself please? :) Right now the arrows have lot's of variables: public Arrowleft(int b, int l, int s, int t, int y){ left=l; speed=s; beginning=b; turn=t; starty=y; } So I have to do all this to add one: addObject(new Arrowleft(580,150,6,0,185),580,185); How can I make the archer control all that?
MTKMTK

2009/11/21

This would probably be better: public Arrow(double angle) { } public void addedToWorld(World world) { x = getX(); y = getY(); } public void move() { //call on every act x += Math.sin(Math.toRadians(angle)); y += Math.cos(Math.toRadians(angle)); } To create a left-pointing arrow: getWorld().addObject(new Arrow(270), 580, 185);
MTKMTK

2009/11/21

I meant: public Arrow(double angle) { this.angle = angle; }
MTKMTK

2009/11/21

Oh, and angle is degrees clockwise from down.
MTKMTK

2009/11/21

Also, it it very confusing for me that one hand controls half the motion, and the other hand controls half the motion and firing. It seems that one hand should move and the other should fire (perhaps up tu jump, space to fire)?
ZergZerg

2009/11/21

so long as the arrow is removing itself at the end instead of resetting, you only need the direction and and a life time for the arrow. You can use MTK's code for the direction, and then add to the constructor public Arrow(double angle, int life){ this.life = life; this.angle = angle; } Then in the act method, have a timer variable increment each act and when it is the same as life, then remove the arrow.
MTKMTK

2009/11/21

Why do you need a life time?
ZergZerg

2009/11/21

You need a lifetime if you want the arrow to stop eventually! Otherwise you can just wait until it hits the edge of the world and remove it then. If there is no time at which it is removed, then you wind up with too many arrows :P
MTKMTK

2009/11/22

Isn't it supposed to stop only if it hits the edge or another object?
plcsplcs

2009/11/23

Minor error in level 3. The archer on top of the box can be killed but arrows still keep firing!
A new version of this scenario was uploaded on Wed Dec 09 20:27:59 UTC 2009
A new version of this scenario was uploaded on Mon Dec 14 01:37:44 UTC 2009
A new version of this scenario was uploaded on Thu Mar 04 22:43:46 UTC 2010
A new version of this scenario was uploaded on Sun Mar 28 19:54:44 UTC 2010
Yes a good game.