Skip to content

Commit 084ed22

Browse files
committed
Mucha
1 parent 8d91289 commit 084ed22

11 files changed

+167
-0
lines changed

Mucha.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=void\ act()
4+
numComments=1

Mucha.java

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import greenfoot.*;
2+
3+
public class Mucha extends Actor
4+
{
5+
6+
public void act()
7+
{
8+
int x = getX();
9+
int y = getY();
10+
11+
int movementSpeed = 5;
12+
13+
if(Greenfoot.isKeyDown("up")){
14+
setLocation(x, y - movementSpeed);
15+
}else if(Greenfoot.isKeyDown("down")){
16+
setLocation(x, y + movementSpeed);
17+
}else if(Greenfoot.isKeyDown("left")){
18+
setLocation(x - movementSpeed, y);
19+
}else if(Greenfoot.isKeyDown("right")){
20+
setLocation(x + movementSpeed, y);
21+
}
22+
}
23+
}

Pajak.ctxt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=void\ act()
4+
comment1.params=
5+
comment1.target=void\ ruszSie()
6+
numComments=2

Pajak.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import greenfoot.*;
2+
3+
public class Pajak extends Actor
4+
{
5+
6+
public void act()
7+
{
8+
ruszSie();
9+
10+
if(this.isTouching(Mucha.class))
11+
getWorld().removeObject(this);
12+
13+
move(3);
14+
}
15+
16+
public void ruszSie(){
17+
int czyRuch = Greenfoot.getRandomNumber(100);
18+
19+
if(czyRuch<4){
20+
int jakiKierunek = Greenfoot.getRandomNumber(360);
21+
setRotation(jakiKierunek);
22+
move(1);
23+
}
24+
}
25+
}

README.TXT

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
------------------------------------------------------------------------
2+
This is the project README file. Here, you should describe your project.
3+
Tell the reader (someone who does not know anything about this project)
4+
all he/she needs to know. The comments should usually include at least:
5+
------------------------------------------------------------------------
6+
7+
PROJECT TITLE:
8+
PURPOSE OF PROJECT:
9+
VERSION or DATE:
10+
HOW TO START THIS PROJECT:
11+
AUTHORS:
12+
USER INSTRUCTIONS:

Sciana.ctxt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#BlueJ class context
2+
comment0.params=
3+
comment0.target=Sciana()
4+
numComments=1

Sciana.java

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import greenfoot.*;
2+
3+
public class Sciana extends World
4+
{
5+
int x = Greenfoot.getRandomNumber(800);
6+
int y = Greenfoot.getRandomNumber(600);
7+
int iloscPajaczkow = Greenfoot.getRandomNumber(6)+3;
8+
9+
public Sciana()
10+
{
11+
super(800, 600, 1);
12+
13+
Mucha muszka = new Mucha();
14+
15+
addObject(muszka, x, y);
16+
for(int listaPajakow=0; listaPajakow<iloscPajaczkow; listaPajakow++)
17+
{
18+
int pajakLokX = Greenfoot.getRandomNumber(800);
19+
int pajakLokY = Greenfoot.getRandomNumber(600);
20+
Pajak pajaczek = new Pajak();
21+
addObject(pajaczek,pajakLokX, pajakLokY);
22+
}
23+
24+
25+
26+
27+
}
28+
}

images/brick.jpg

3.81 KB
Loading

images/fly.png

1.97 KB
Loading

images/spider.png

2.29 KB
Loading

project.greenfoot

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#Greenfoot properties
2+
#Sat Sep 26 14:40:09 CEST 2015
3+
target3.editor.y=25
4+
target3.editor.x=-1
5+
target2.name=Mucha
6+
target2.naviview.expanded=false
7+
class.Pajak.superclass=greenfoot.Actor
8+
target2.editor.height=700
9+
dependency1.from=Sciana
10+
target2.showInterface=false
11+
target1.editor.width=1026
12+
dependency3.from=Pajak
13+
target3.y=70
14+
target3.x=70
15+
target1.type=ClassTarget
16+
target3.type=ClassTarget
17+
target2.y=10
18+
package.numTargets=3
19+
class.Pajak.image=spider.png
20+
target2.x=160
21+
dependency3.to=Mucha
22+
target1.height=50
23+
dependency2.type=UsesDependency
24+
target1.y=10
25+
target2.height=50
26+
target1.x=70
27+
target1.naviview.expanded=false
28+
dependency1.to=Mucha
29+
target1.editor.height=743
30+
target3.height=50
31+
target1.showInterface=false
32+
target3.typeParameters=
33+
target1.name=Sciana
34+
target2.typeParameters=
35+
target3.name=Pajak
36+
target3.editor.width=1026
37+
target1.typeParameters=
38+
mainWindow.width=1024
39+
target1.editor.y=25
40+
target1.editor.x=-1
41+
dependency2.from=Sciana
42+
target3.naviview.expanded=true
43+
target2.width=80
44+
mainWindow.height=743
45+
target1.width=80
46+
mainWindow.y=25
47+
class.Sciana.superclass=greenfoot.World
48+
mainWindow.x=0
49+
target3.width=80
50+
class.Mucha.image=fly.png
51+
target3.editor.height=743
52+
target2.type=ClassTarget
53+
target3.showInterface=false
54+
world.lastInstantiated=Sciana
55+
dependency1.type=UsesDependency
56+
target2.editor.y=45
57+
target2.editor.x=40
58+
version=2.7.1
59+
dependency3.type=UsesDependency
60+
package.numDependencies=3
61+
class.Mucha.superclass=greenfoot.Actor
62+
project.charset=UTF-8
63+
class.Sciana.image=brick.jpg
64+
target2.editor.width=900
65+
dependency2.to=Pajak

0 commit comments

Comments
 (0)