Hi,
I am working on a project in which Mario must collect coins.
He can die from goombas and can shoot fireballs.
BUT I got a problem...
I want to add a Boss (Bowser) after a time to the game!!!
HOW can I make this?
This is my code for the World:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * The bloodstream is the setting for our White Blood Cell scenario. * It's a place where blood cells, bacteria and viruses float around. * * @author Brennan Eppinger * @version 10/30/2017 */ public class Bloodstream extends World { private int score; private int time; private static final String bgImageName = "background.png"; private static final double scrollSpeed = 2.5; private static final int picWidth = (new GreenfootImage(bgImageName)).getWidth(); private GreenfootImage bgImage, bgBase; private int scrollPosition = 0; GreenfootSound bgMusic = new GreenfootSound("ground-music.mp3"); /** * Constructor: Set up the staring objects. */ public Bloodstream() { super(780, 360, 1); prepare(); score = 0; time = 7000; showScore(); showTime(); setBackground(bgImageName); bgImage = new GreenfootImage(getBackground()); bgBase = new GreenfootImage(picWidth, getHeight()); bgBase.drawImage(bgImage, 0, 0); } public void started() { bgMusic.playLoop(); } public void stopped() { bgMusic.pause(); } public void act() { if (Greenfoot.getRandomNumber(100) < 1) { addObject(new Coin(), 779, Greenfoot.getRandomNumber(360)); } if (Greenfoot.getRandomNumber(1000) < 6) { addObject(new Virus(), 779, Greenfoot.getRandomNumber(360)); } started(); countTime (); scrollPosition -= scrollSpeed; while(scrollSpeed > 0 && scrollPosition < -picWidth) scrollPosition += picWidth; while(scrollSpeed < 0 && scrollPosition > 0) scrollPosition -= picWidth; paint(scrollPosition); } private void paint(int position) { GreenfootImage bg = getBackground(); bg.drawImage(bgBase, position, 0); bg.drawImage(bgImage, position + picWidth, 0); } public void addScore(int points) { score = score + points; showScore(); if (score < 0) { Greenfoot.playSound("game-over.wav"); Greenfoot.stop(); } } private void showScore() { showText("Score: " + score, 80, 25); score = score + 20; } private void countTime() { time--; showTime(); if (time == 0) { showEndMessage(); Greenfoot.stop(); } showText("Zeit: " + time, 700, 25); } private void showTime() { showText("Zeit: " + time, 700, 25); } private void showEndMessage() { Greenfoot.playSound("win.mp3"); showText("Die Zeit ist um!", 390, 150); showText("Dein Score: " + score + " points", 390, 170); } private void prepare() { Mario mario = new Mario(); addObject(mario, 97, 179); } }