46 lines
1.2 KiB
Java
46 lines
1.2 KiB
Java
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
|
|
|
/**
|
|
* Write a description of class MyWorld here.
|
|
*
|
|
* @author (your name)
|
|
* @version (a version number or a date)
|
|
*/
|
|
public class MyWorld extends World
|
|
{
|
|
int timer = 200; //Zeit, bevor das erste Projektil auftaucht
|
|
//kann später noch beliebig angepasst werden
|
|
|
|
/**
|
|
* Constructor for objects of class MyWorld.
|
|
*
|
|
*/
|
|
public MyWorld()
|
|
{
|
|
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
|
|
super(400, 600, 1);
|
|
prepare();
|
|
}
|
|
/**
|
|
* Prepare the world for the start of the program.
|
|
* That is: create the initial objects and add them to the world.
|
|
*/
|
|
private void prepare()
|
|
{
|
|
Player player = new Player();
|
|
addObject(player,302,320);
|
|
}
|
|
|
|
public void act(){
|
|
if(timer > 0){
|
|
timer = timer - 1;
|
|
}
|
|
else{
|
|
Projectile projectile = new Projectile();
|
|
addObject(projectile,Greenfoot.getRandomNumber(300)+50,0);
|
|
timer = 200; //zeitlicher Abstand
|
|
}
|
|
//zwischen den x Werten 50 und 350 spawnen die Projektile (anpassbar)
|
|
}
|
|
}
|