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

2019/7/2

Jumping

1
2
3
¿ques♫ ¿ques♫

2019/7/17

#
Ok thanks, finally got it. Regarding my second last reply, do you have any suggestions or places you can reference me to as far as learning to code Java with a different IDE such as IntelliJ? I want to make this exact same game in IntelliJ, but the only knowledge with Java I have involves Greenfoot. Also, do you have a sprites demo or suggestions on how to implement sprites in Greenfoot? Thanks.
danpost danpost

2019/7/17

#
¿ques♫ wrote...
Regarding my second last reply, do you have any suggestions or places you can reference me to as far as learning to code Java with a different IDE such as IntelliJ? I want to make this exact same game in IntelliJ, but the only knowledge with Java I have involves Greenfoot
Greenfoot provides the world window and the basic codes for working with actors in a world (among other things). This includes the framing of states through time which is the "running" of your scenarios. You would need to create any and all codes needed that will be absent without greenfoot (unless provided through the other IDE (I do not think IntellJ provides any of that).
do you have a sprites demo or suggestions on how to implement sprites in Greenfoot?
I do not have any demos for using sprites. As far as suggestions, "implement(ing) sprites" is too broad of a thing to make any on. You will have to go with specific instances of implementation and build your knowledge on it one step at a time (unless you have specific questions about implementing them).
¿ques♫ ¿ques♫

2019/7/21

#
Hi Danpost, was wondering, how can I edit your Scroller class or the MyWorld class to disable backwards scrolling? I want Mario to still be able to move towards the left edge of the screen, but for backwards scrolling to be disabled (doing this so that any objects that pass the left edge can be removed to reduce lag).
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.io.*;
import java.util.*;
/**
 * Write a description of class MyWorld here.
 * 
 * @author Matthew Benson, Daniel Olinyk 
 * @version 1.0
 */
public class MyWorld extends World
{
    GreenfootSound backgroundMusic = new GreenfootSound("world1.mp3");           //variable that stores theme music
    private int delay;                  //timer responsible for spawning clouds

    public static final int WIDE = 1200;
    public static final int HIGH = 800;

    Scroller scroller;
    Actor scrollActor;

    /**
     * This method is responsible for the setting up and the initialization of objects and variables
     */
    public MyWorld()
    {    
        super(WIDE, HIGH, 1, false);                 //create unbounded world (can spawn objects outside edges)

        GreenfootImage bg = new GreenfootImage("bg1a.jpg");              //image is 10,000 pixels wide, memory error occurs too often
        int bgWide = bg.getWidth();
        int bgHigh = bg.getHeight();
        scroller = new Scroller(this, bg, bgWide, bgHigh);
        scrollActor = new Mario();
        addObject(scrollActor, 50, 600);
        scroll();

        Pipe pipe = new Pipe();
        addObject(pipe, 1000, 635);

        spawn();
    }

    /**
     * Custom method created to spawn cloud objects in MyWorld
     */
    public void spawn() {
        for (int i = 0; i < 30; i++) {
            Cloud cloud = new Cloud(0);
            addObject(cloud, 0, 0);
        }
    }

    private void scroll() {
        int dsx = scrollActor.getX()-WIDE/2;
        int dsy = scrollActor.getY()-HIGH/2;
        scroller.scroll(dsx, dsy);
    }

    /**
     * Greenfoot cycles through the act method at a speed of approximately 60 frames per second.
     * Custom methods and code that need to be constantly checked should be placed here.
     */
    public void act() {
        if (scrollActor != null) scroll();
        backgroundMusic.playLoop();                     //play music repeatedly         
    }
}
danpost danpost

2019/7/21

#
¿ques♫ wrote...
Hi Danpost, was wondering, how can I edit your Scroller class or the MyWorld class to disable backwards scrolling? I want Mario to still be able to move towards the left edge of the screen, but for backwards scrolling to be disabled (doing this so that any objects that pass the left edge can be removed to reduce lag). << Code Omitted >>
The Scroller class should never need modification. My tutorial shows how to allow scrollActor roaming before scrolling using specific code in the scroll method in your MyWorrld class. It should be a simple matter to prevent backward scrolling (just by removing one line of code; or, by changing what it does).
You need to login to post a reply.
1
2
3