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

2014/1/10

I need help on a platform game

gonzo gonzo

2014/1/10

#
i've spent a lot of time on this website and youtube, and google, in order to find help on making a floor for my platform game. This game has a rather taller character and i need the feet of the character to be colliding with a floor made above the bottom boundary of the game. its far from complete, i just would like to know how or where i can start with making this floor and how i can make it interact with my character.
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

public class jjleft extends Actor
{
    private int wX;
    private int wY;
    
    public jjleft()
    {
    }
    
    public void act() 
    {
        move();
        fall();
    }
    
    public void move()
    {
        GreenfootImage jjright = new GreenfootImage("jedijesus(right).jpg");
        GreenfootImage jjleft = new GreenfootImage("jedijesus(left).jpg");
        GreenfootImage jjleftdown = new GreenfootImage("jesus left sword down.jpg");
        GreenfootImage jjrightdown = new GreenfootImage("jesus right sword down.jpg");
        
       setLocation(getX() + wX, getY() + wY);
        if (Greenfoot.isKeyDown("right")){
           move(3);
           setImage("jedijesus(right).jpg");
           if (Greenfoot.isKeyDown("down")){
               setImage("jesus right sword down.jpg");
           }
        } 
        if (Greenfoot.isKeyDown("left")){
            move(-3);
            setImage("jedijesus(left).jpg");
            if (Greenfoot.isKeyDown("down")){
                
                setImage("jesus left sword down.jpg");
            }
        }
        
        
    }
    public void fall()
    {
        if (
        {
            
        }
    }

    public void checkCollision() 
    {   
        if (getX() == 0 || getX() == getWorld().getWidth()-1){
            wX = -wX;
        }
        if (getY() == 0) {
            wY = -wY;
        }
    }
}
Upupzealot Upupzealot

2014/1/15

#
You can try to search on this website. There are so many screnios(with their codes) simulating platfroming here. I made two of them. http://www.greenfoot.org/scenarios/6658 http://www.greenfoot.org/scenarios/6658 But I think my code is a little difficult to read for you new learners. Just search and try others. BTW, I love Taric also. X-D
danpost danpost

2014/1/15

#
For the floor to interact with your character easily, it should be of an Actor subclass. The Actor class has multiple collision detection methods that can be utilized to control the position of your character. The is also a multitude number of ways to create the image of the floor that you will set as the image of that actor.
You need to login to post a reply.