Startscreen erstellt

This commit is contained in:
2026-09-15 19:10:55 +02:00
parent a53a0a22c6
commit c4505df6ed
8 changed files with 197 additions and 7 deletions
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
#BlueJ class context
comment0.target=Pfeil
comment0.text=\r\n\ Write\ a\ description\ of\ class\ Pfeil\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
comment1.target=void\ act()
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ Pfeil\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
comment2.params=
comment2.target=void\ Pfeil()
numComments=3
+22
View File
@@ -0,0 +1,22 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Pfeil here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Pfeil extends Actor
{
/**
* Act - do whatever the Pfeil wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
public void Pfeil(){
}
}
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
#BlueJ class context
comment0.target=StartWorld
comment0.text=\r\n\ Write\ a\ description\ of\ class\ StartWorld\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
comment1.target=StartWorld()
comment10.params=
comment10.target=void\ act()
comment2.params=
comment2.target=void\ pfeilA()
comment3.params=
comment3.target=void\ pfeilB()
comment4.params=
comment4.target=void\ pfeilC()
comment5.params=
comment5.target=void\ pfeil1()
comment6.params=
comment6.target=void\ pfeil2()
comment7.params=
comment7.target=void\ pfeil3()
comment8.params=
comment8.target=void\ SpielerWahl1()
comment9.params=
comment9.target=void\ SpielerWahl2()
numComments=11
+108
View File
@@ -0,0 +1,108 @@
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 StartWorld extends World
{
/**
* Constructor for objects of class StartWorld.
*
*/
public int aktuellerSpieler1;
public int aktuellerSpieler2;
public Pfeil cursor1;
public Pfeil cursor2;
public StartWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
showText("Spiel Name" , 300, 20);
showText("select a character", 300, 70);
showText("press enter to start", 300, 340);
showText("player 1 :", 100,100);
showText("player 2 :", 500,100);
showText("1 character 1", 500,150);
showText("2 character 2", 500,200);
showText("3 character 3", 500,250);
showText("a character 1", 100,150);
showText("b character 2", 100,200);
showText("c character 3", 100,250);
cursor1 = new Pfeil();
cursor1.setImage("cursor.png");
addObject(cursor1, 50, 160);
cursor2 = new Pfeil();
cursor2.setImage("cursor.png");
addObject(cursor2 , 450, 160);
}
public void pfeilA(){
if(Greenfoot.isKeyDown("a")){
aktuellerSpieler1 = 1;
cursor1.setLocation(50,160);
}
}
public void pfeilB(){
if(Greenfoot.isKeyDown("b")){
aktuellerSpieler1 = 2;
cursor1.setLocation(50,210);
}
}
public void pfeilC(){
if(Greenfoot.isKeyDown("c")){
aktuellerSpieler1 = 3;
cursor1.setLocation(50,260);
}
}
public void pfeil1(){
if(Greenfoot.isKeyDown("1")){
aktuellerSpieler2 = 1;
cursor2.setLocation(450,160);
}
}
public void pfeil2(){
if(Greenfoot.isKeyDown("2")){
aktuellerSpieler2 = 2;
cursor2.setLocation(450,210);
}
}
public void pfeil3(){
if(Greenfoot.isKeyDown("3")){
aktuellerSpieler2 = 3;
cursor2.setLocation(450,260);
}
}
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());
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

+34 -7
View File
@@ -1,14 +1,27 @@
#Greenfoot project file
class.MyWorld.image=crumpled-paper.jpg
class.Pfeil.image=cursor.png
class.player1.image=man01.png
class.player2.image=man01.png
dependency1.from=StartWorld
dependency1.to=Pfeil
dependency1.type=UsesDependency
dependency2.from=StartWorld
dependency2.to=MyWorld
dependency2.type=UsesDependency
dependency3.from=MyWorld
dependency3.to=player1
dependency3.type=UsesDependency
dependency4.from=MyWorld
dependency4.to=player2
dependency4.type=UsesDependency
editor.fx.0.height=737
editor.fx.0.width=814
editor.fx.0.x=151
editor.fx.0.y=86
editor.fx.0.x=194
editor.fx.0.y=77
height=686
package.numDependencies=0
package.numTargets=4
package.numDependencies=4
package.numTargets=6
project.charset=UTF-8
publish.hasSource=false
publish.locked=true
@@ -38,21 +51,35 @@ target2.width=120
target2.x=0
target2.y=0
target3.height=70
target3.name=startScreen
target3.name=Pfeil
target3.showInterface=false
target3.type=ClassTarget
target3.width=120
target3.x=0
target3.y=0
target4.height=70
target4.name=MyWorld
target4.name=StartWorld
target4.showInterface=false
target4.type=ClassTarget
target4.width=120
target4.x=0
target4.y=0
target5.height=70
target5.name=startScreen
target5.showInterface=false
target5.type=ClassTarget
target5.width=120
target5.x=0
target5.y=0
target6.height=70
target6.name=MyWorld
target6.showInterface=false
target6.type=ClassTarget
target6.width=120
target6.x=0
target6.y=0
version=3.1.0
width=1294
world.lastInstantiated=MyWorld
world.lastInstantiated=StartWorld
xPosition=0
yPosition=0