Bewegung des 1. und 2. Spielers
This commit is contained in:
Binary file not shown.
@@ -4,4 +4,7 @@ comment0.text=\r\n\ Write\ a\ description\ of\ class\ MyWorld\ here.\r\n\ \r\n\
|
||||
comment1.params=
|
||||
comment1.target=MyWorld()
|
||||
comment1.text=\r\n\ Constructor\ for\ objects\ of\ class\ MyWorld.\r\n\ \r\n
|
||||
numComments=2
|
||||
comment2.params=
|
||||
comment2.target=void\ prepare()
|
||||
comment2.text=\r\n\ Prepare\ the\ world\ for\ the\ start\ of\ the\ program.\r\n\ That\ is\:\ create\ the\ initial\ objects\ and\ add\ them\ to\ the\ world.\r\n
|
||||
numComments=3
|
||||
|
||||
@@ -17,5 +17,18 @@ public class MyWorld extends World
|
||||
{
|
||||
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
|
||||
super(600, 400, 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()
|
||||
{
|
||||
player1 player1 = new player1();
|
||||
addObject(player1,125,153);
|
||||
player2 player2 = new player2();
|
||||
addObject(player2,429,152);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 585 B |
Binary file not shown.
@@ -1,25 +0,0 @@
|
||||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
|
||||
/**
|
||||
* Write a description of class player here.
|
||||
*
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
*/
|
||||
public class player extends Actor
|
||||
{
|
||||
/**
|
||||
* Act - do whatever the player wants to do. This method is called whenever
|
||||
* the 'Act' or 'Run' button gets pressed in the environment.
|
||||
*/
|
||||
public void act()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void bewegung(){
|
||||
if(Greenfoot.isKeyDown("d")){
|
||||
move(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,9 +1,13 @@
|
||||
#BlueJ class context
|
||||
comment0.target=player
|
||||
comment0.target=player1
|
||||
comment0.text=\r\n\ Write\ a\ description\ of\ class\ player\ 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\ player\ 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\ bewegung()
|
||||
numComments=3
|
||||
comment3.params=
|
||||
comment3.target=void\ springen()
|
||||
comment4.params=
|
||||
comment4.target=void\ gravitation()
|
||||
numComments=5
|
||||
@@ -0,0 +1,53 @@
|
||||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
|
||||
/**
|
||||
* Write a description of class player here.
|
||||
*
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
*/
|
||||
public class player1 extends Actor
|
||||
{
|
||||
/**
|
||||
* Act - do whatever the player wants to do. This method is called whenever
|
||||
* the 'Act' or 'Run' button gets pressed in the environment.
|
||||
*/
|
||||
public void act()
|
||||
{
|
||||
bewegung();
|
||||
gravitation();
|
||||
springen();
|
||||
}
|
||||
|
||||
public void bewegung(){
|
||||
if(Greenfoot.isKeyDown("d")){
|
||||
setRotation(0);
|
||||
move(3);
|
||||
}
|
||||
if(Greenfoot.isKeyDown("a")){
|
||||
setRotation(0);
|
||||
move(-3);
|
||||
}
|
||||
}
|
||||
|
||||
public void springen(){
|
||||
if(Greenfoot.isKeyDown("space") && this.getY() > 370 ){
|
||||
for(int i = 12; i > -12; i--){
|
||||
setRotation(270);
|
||||
move(i);
|
||||
setRotation(0);
|
||||
Greenfoot.delay(1);
|
||||
bewegung();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void gravitation(){
|
||||
if(this.getY() < 370){
|
||||
setRotation(90);
|
||||
move(4);
|
||||
setRotation(0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
#BlueJ class context
|
||||
comment0.target=player2
|
||||
comment0.text=\r\n\ Write\ a\ description\ of\ class\ player\ 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\ player\ 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\ bewegung()
|
||||
comment3.params=
|
||||
comment3.target=void\ springen()
|
||||
comment4.params=
|
||||
comment4.target=void\ gravitation()
|
||||
numComments=5
|
||||
@@ -0,0 +1,53 @@
|
||||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
|
||||
/**
|
||||
* Write a description of class player here.
|
||||
*
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
*/
|
||||
public class player2 extends Actor
|
||||
{
|
||||
/**
|
||||
* Act - do whatever the player wants to do. This method is called whenever
|
||||
* the 'Act' or 'Run' button gets pressed in the environment.
|
||||
*/
|
||||
public void act()
|
||||
{
|
||||
bewegung();
|
||||
gravitation();
|
||||
springen();
|
||||
}
|
||||
|
||||
public void bewegung(){
|
||||
if(Greenfoot.isKeyDown("right")){
|
||||
setRotation(0);
|
||||
move(3);
|
||||
}
|
||||
if(Greenfoot.isKeyDown("left")){
|
||||
setRotation(0);
|
||||
move(-3);
|
||||
}
|
||||
}
|
||||
|
||||
public void springen(){
|
||||
if(Greenfoot.isKeyDown("-") && this.getY() > 370 ){
|
||||
for(int i = 12; i > -12; i--){
|
||||
setRotation(270);
|
||||
move(i);
|
||||
setRotation(0);
|
||||
Greenfoot.delay(1);
|
||||
bewegung();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void gravitation(){
|
||||
if(this.getY() < 370){
|
||||
setRotation(90);
|
||||
move(4);
|
||||
setRotation(0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
#Greenfoot project file
|
||||
class.MyWorld.image=space.jpg
|
||||
class.MyWorld.image=crumpled-paper.jpg
|
||||
class.player1.image=man01.png
|
||||
class.player2.image=man01.png
|
||||
editor.fx.0.height=737
|
||||
editor.fx.0.width=814
|
||||
editor.fx.0.x=151
|
||||
editor.fx.0.y=86
|
||||
height=686
|
||||
package.numDependencies=0
|
||||
package.numTargets=3
|
||||
package.numTargets=4
|
||||
project.charset=UTF-8
|
||||
publish.hasSource=false
|
||||
publish.locked=true
|
||||
@@ -22,26 +24,33 @@ readme.x=10
|
||||
readme.y=10
|
||||
simulation.speed=48
|
||||
target1.height=70
|
||||
target1.name=startScreen
|
||||
target1.name=player1
|
||||
target1.showInterface=false
|
||||
target1.type=ClassTarget
|
||||
target1.width=120
|
||||
target1.x=0
|
||||
target1.y=0
|
||||
target2.height=70
|
||||
target2.name=MyWorld
|
||||
target2.name=player2
|
||||
target2.showInterface=false
|
||||
target2.type=ClassTarget
|
||||
target2.width=120
|
||||
target2.x=0
|
||||
target2.y=0
|
||||
target3.height=70
|
||||
target3.name=player
|
||||
target3.name=startScreen
|
||||
target3.showInterface=false
|
||||
target3.type=ClassTarget
|
||||
target3.width=120
|
||||
target3.x=0
|
||||
target3.y=0
|
||||
target4.height=70
|
||||
target4.name=MyWorld
|
||||
target4.showInterface=false
|
||||
target4.type=ClassTarget
|
||||
target4.width=120
|
||||
target4.x=0
|
||||
target4.y=0
|
||||
version=3.1.0
|
||||
width=1294
|
||||
world.lastInstantiated=MyWorld
|
||||
|
||||
Reference in New Issue
Block a user