Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
escapecorona
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Malek
escapecorona
Commits
9aaa5c70
Commit
9aaa5c70
authored
4 years ago
by
Sarah
Browse files
Options
Downloads
Patches
Plain Diff
Funktion des Spitters und Erzeugen von Spit-Objekten
parent
64fb2dca
Branches
Branches containing commit
Tags
v1.6.2
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Interactables.java
+17
-2
17 additions, 2 deletions
Interactables.java
Spit.java
+9
-2
9 additions, 2 deletions
Spit.java
Spitter.java
+9
-2
9 additions, 2 deletions
Spitter.java
with
35 additions
and
6 deletions
Interactables.java
+
17
−
2
View file @
9aaa5c70
import
greenfoot.*
;
public
class
Interactables
extends
Actor
{
public
void
disappear
()
{
public
void
disappear
()
{
if
(
isAtEdge
())
{
getWorld
().
removeObject
(
this
);
}
...
...
@@ -11,4 +12,18 @@ public class Interactables extends Actor
Actor
actor
=
getOneObjectAtOffset
(
0
,
0
,
clss
);
return
actor
!=
null
;
}
public
void
moveRight
()
{
setLocation
(
getX
()
+
3
,
getY
());
}
public
void
moveLeft
()
{
setLocation
(
getX
()
-
3
,
getY
());
}
public
void
move
(
int
speed
)
{
double
angle
=
Math
.
toRadians
(
getRotation
()-
90
);
int
x
=
(
int
)
Math
.
round
(
getX
()
+
Math
.
cos
(
angle
)
*
speed
);
int
y
=
(
int
)
Math
.
round
(
getY
()
+
Math
.
sin
(
angle
)
*
speed
);
setLocation
(
x
,
y
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Spit.java
+
9
−
2
View file @
9aaa5c70
...
...
@@ -12,9 +12,16 @@ public class Spit extends Spitter
* Act - do whatever the Spit wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public
Spit
()
{
//turn(90);
turn
(
Greenfoot
.
getRandomNumber
(
180
-
20
)+
20
);
}
public
void
act
()
{
//moveLeft();
//turn(Greenfoot.getRandomNumber(180));
move
(-
5
);
disappear
();
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Spitter.java
+
9
−
2
View file @
9aaa5c70
...
...
@@ -15,6 +15,13 @@ public class Spitter extends Enemy
public
void
act
()
{
disappear
();
cough
();
}
private
void
cough
()
{
if
(
Greenfoot
.
getRandomNumber
(
100
)<
5
)
{
getWorld
().
addObject
(
new
Spit
(),(
getX
()-
10
),(
getY
()-
40
));
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment