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

2015/6/9

How would I make a character like this in Greenfoot?

RubberFlubber RubberFlubber

2015/6/9

#
I'm currently working on a game that's similar to this one: https://www.youtube.com/watch?v=l8cYYPpRboo However, I don't know how I'd be able to create a main character like this (mouse aiming + rotating body). Any chance someone here could help?
lordhershey lordhershey

2015/6/9

#
First thing - it requires a boat-ton of pictures. Figuring out which image to display is the easy part. How much of the rotation do you want? The Leg portion isn't too hard to break down, they only have to point in the current direction and you just need the run/stand/jump sequences for those. You would make the character out of 2 pieces Mid body down with legs and head/upper body part that follows the mouse. Do you have images for them? Looks like it is a pretty cool game.
RubberFlubber RubberFlubber

2015/6/10

#
I don't, actually. Was just going to start programming today and was wondering how I'd do the character. Thanks for the help!
plant plant

2015/6/10

#
There is a "GIFImage" class Greenfoot has recently added. You can use that to make the "boat-ton of pictures" or you could create a counter and make it cycle through the images constantly. Example...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public void act(){
        gif();
    }
     
    private void gif(){
        int SIZE = 100;
        int COUNTER = 0;
        COUNTER++;
        GreenfootImage imageOne = new GreenfootImage (SIZE,SIZE);
        GreenfootImage imageTwo = new GreenfootImage (SIZE,SIZE);
        if (COUNTER==1){
            setImage (imageOne);
        } else if (COUNTER==2){
            setImage (imageTwo);
        } else {
            COUNTER = 0;
            setImage (imageOne);
        }
    }
plant plant

2015/6/10

#
You can import that "GIFImage" class under the import tab****
Super_Hippo Super_Hippo

2015/6/10

#
This 'gif' method really doesn't make sense. Look over it and try to see what I mean.
lordhershey lordhershey

2015/6/10

#
There are a few scenarios where some people have made multi part (multi actor) players, usually having an arm that follows the mouse, that might be sufficient and then once the working bits are there - the graphics can be updated later.
lordhershey lordhershey

2015/6/10

#
For making an action game I can understand the desire to start programming right this very second, but the truth is to even get a workable mediocre game requires at least a little planning. You could work out the walk and point routines and things like that pretty quickly. Many people have shared scrolling world/background scenarios so looking at those would be great. Some people have platform demos so a game like this would be a scrolling platformer type game. Good thing is you can take all of that code and just adapt it to you need since most post the source with the intention of letting you use it.
RubberFlubber RubberFlubber

2015/6/11

#
Thanks, everyone!
lordhershey lordhershey

2015/6/11

#
You like to see what you come up with.
RubberFlubber RubberFlubber

2015/6/12

#
I'll be spending the next bit making the sprites for my game. :)
Game/maniac Game/maniac

2015/6/12

#
gifs don't work when the scenario is uploaded to the greenfoot website, rather create the animation frames as separate images then use folders to organise the sprites and use this class:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import greenfoot.GreenfootImage;
 
public class Animator {
    private String folder;
    private String action;
    private int index = 0;
    private int frames;
     
    /**
     * This class requires you to put your animation frames in folders. The animation frames need to be named in
     * the following format: "action_index" where action is the sprites current action and index is the frames
     * index.
     *
     * @param folder
     * The name of the sprites folder
     *
     * @param action
     * The name of the animaton sequence
     *
     * @param frames
     * The number of frames in the animation sequence
     */
    public Animator(String folder, String action, int frames) {
        this.folder = folder;
        this.action = action;
        this.frames = frames;
    }
     
    public int getIndex() {
        return index;
    }
     
    public void setIndex(int index) {
        this.index = index;
    }
     
    public String getAction() {
        return action;
    }
     
    public void setAction(String action, int frames) {
        this.action = action;
        this.frames = frames;
    }
     
    public GreenfootImage getFrame() {
        GreenfootImage img = new GreenfootImage(folder + "/" + action + "_" + index);
        index++;
        index %= frames;
        return img;
    }
}
You need to login to post a reply.