134 lines
3.7 KiB
Java
134 lines
3.7 KiB
Java
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
|
|
|
/**
|
|
* Write a description of class StartWorld here.
|
|
*
|
|
* @author (your name)
|
|
* @version (a version number or a date)
|
|
*/
|
|
public class MenuWorld extends World
|
|
{
|
|
|
|
/**
|
|
* Constructor for objects of class StartWorld.
|
|
*
|
|
*/
|
|
public int aktuellerSpieler1;
|
|
public int aktuellerSpieler2;
|
|
public Pfeil cursor1;
|
|
public Pfeil cursor2;
|
|
long timer;
|
|
long x;
|
|
Picture p4;
|
|
|
|
public MenuWorld()
|
|
{
|
|
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
|
|
super(600, 400, 1);
|
|
showText("Anime Fighters" , 300, 50);
|
|
showText("select", 300, 103);
|
|
//showText("press enter to start", 300, 340);
|
|
showText("player 1 :", 130,100);
|
|
showText("player 2 :", 470,100);
|
|
|
|
showText("1 Ren ", 470,170);
|
|
showText("2 Tetsu ", 470,233);
|
|
showText("3 Hinata ", 470,296);
|
|
|
|
showText("a Ren ", 180,170);
|
|
showText("b Tetsu ", 180,233);
|
|
showText("c Hinata ", 180,296);
|
|
|
|
cursor1 = new Pfeil();
|
|
cursor1.setImage("IMG_7887.png");
|
|
GreenfootImage image = cursor1.getImage();
|
|
image.scale(220,70);
|
|
cursor1.setImage(image);
|
|
cursor1.getImage().mirrorHorizontally();
|
|
|
|
cursor2 = new Pfeil();
|
|
cursor2.setImage("IMG_7886.png");
|
|
GreenfootImage image2 = cursor2.getImage();
|
|
image2.scale(220,70);
|
|
cursor2.setImage(image2);
|
|
|
|
setBackground(new GreenfootImage("MenuScreen.png"));
|
|
setPaintOrder(Pfeil.class);
|
|
}
|
|
|
|
public void pfeilA(){
|
|
if(Greenfoot.isKeyDown("a")){
|
|
aktuellerSpieler1 = 1;
|
|
addObject(cursor1, 200, 100);
|
|
cursor1.setLocation(150,170);
|
|
}
|
|
}
|
|
public void pfeilB(){
|
|
if(Greenfoot.isKeyDown("b")){
|
|
aktuellerSpieler1 = 2;
|
|
addObject(cursor1, 200, 100);
|
|
cursor1.setLocation(150,232);
|
|
}
|
|
}
|
|
public void pfeilC(){
|
|
if(Greenfoot.isKeyDown("c")){
|
|
aktuellerSpieler1 = 3;
|
|
addObject(cursor1, 200, 100);
|
|
cursor1.setLocation(150,298);
|
|
}
|
|
}
|
|
|
|
public void pfeil1(){
|
|
if(Greenfoot.isKeyDown("1")){
|
|
aktuellerSpieler2 = 1;
|
|
addObject(cursor2, 200, 100);
|
|
cursor2.setLocation(446,170);
|
|
}
|
|
}
|
|
public void pfeil2(){
|
|
if(Greenfoot.isKeyDown("2")){
|
|
aktuellerSpieler2 = 2;
|
|
addObject(cursor2, 200, 0);
|
|
cursor2.setLocation(446,232);
|
|
}
|
|
}
|
|
public void pfeil3(){
|
|
if(Greenfoot.isKeyDown("3")){
|
|
aktuellerSpieler2 = 3;
|
|
addObject(cursor2, 200, 100);
|
|
cursor2.setLocation(446,298);
|
|
}
|
|
}
|
|
|
|
public void SpielerWahl1(){
|
|
pfeilA();
|
|
pfeilB();
|
|
pfeilC();
|
|
}
|
|
|
|
public void SpielerWahl2(){
|
|
pfeil1();
|
|
pfeil2();
|
|
pfeil3();
|
|
}
|
|
|
|
public void act(){
|
|
SpielerWahl1();
|
|
SpielerWahl2();
|
|
if (Greenfoot.isKeyDown("enter")){
|
|
if(aktuellerSpieler1 > 0 && aktuellerSpieler2 > 0){
|
|
Greenfoot.setWorld(new MyWorld(aktuellerSpieler1, aktuellerSpieler2));
|
|
}
|
|
}
|
|
if(System.currentTimeMillis() >= timer && aktuellerSpieler1 > 0 && aktuellerSpieler2 > 0){
|
|
p4 = new Picture(4);
|
|
addObject(p4,300,370);
|
|
x = System.currentTimeMillis() + 500;
|
|
timer = System.currentTimeMillis() + 1000;
|
|
}
|
|
if(System.currentTimeMillis() >= x){
|
|
removeObject(p4);
|
|
}
|
|
}
|
|
}
|