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

2017/1/18

my game

jacquelinereilly jacquelinereilly

2017/1/18

#
i have been working on a game. I need to figure out how to get the character to collect things, they are little formula bottles, so the character moves and jumps to collect them. i can't figure out how to place the bottles. and how would the program count them? like keep track, but display the counter also. thank you
danpost danpost

2017/1/18

#
jacquelinereilly wrote...
display the counter
My Value Display Tutorial should be able to give you some guidance.
jacquelinereilly jacquelinereilly

2017/1/19

#
I can't see the tutorial or download it?
danpost danpost

2017/1/19

#
Well, placing the bottles is something you really need to figure out (just do not place them where your character cannot get to them). As far as the count display, you need two fields and at least one method. The fields: (1) an int field for the count; and (2) a reference field for the Actor object used to display the count. The count field should probably be in the class of the character. The display reference field can be in either the same class or in your World subclass. The method is to adjust the score and update the display. This should be in the same class as the reference field.
jacquelinereilly jacquelinereilly

2017/1/19

#
Oh yes, I got the bottles. haha I forgot about that part. It was the code I meant. Okay thanks!! I think I got it
jacquelinereilly jacquelinereilly

2017/1/19

#
I know how to get a character to move using the arrow keys. how do i do it using a,w,d keys?
public void checkKey ()
    {
        if (Greenfoot.isKeyW ("right")) 
        {
            //direction =1;
            setLocation (getX()+speed, getY());
        }
        if (Greenfoot.isKeyDown ("left"))
        {
            //direction =-1l
            setLocation (getX() - speed, getY());
        }
        if (Greenfoot.isKeyDown("up") && jumping == false)
        {
            jump ();
        }
}
I know the .isKeyW is wrong, I don't know what to change it to get the character to move when the a,wd, keys are pressed
danpost danpost

2017/1/19

#
jacquelinereilly wrote...
I know how to get a character to move using the arrow keys. how do i do it using a,w,d keys? < Code Omitted >
Just replace "right", "left" and "up" with "d", "a" and "w", respectively. Change "isKeyW' back to what it was before you tried something different.
jacquelinereilly jacquelinereilly

2017/1/19

#
thank you!! easier than I thought, thanks so much
You need to login to post a reply.