Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
javaProj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Oscar Wiberg
javaProj
Commits
e793bee2
Commit
e793bee2
authored
5 months ago
by
Oscar Wiberg
Browse files
Options
Downloads
Patches
Plain Diff
bomb tracear
parent
34c9b4f4
No related branches found
No related tags found
1 merge request
!2
Newmode
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/states/FlyingEnemy.java
+3
-3
3 additions, 3 deletions
src/states/FlyingEnemy.java
src/states/PlayState.java
+1
-1
1 addition, 1 deletion
src/states/PlayState.java
src/states/Player.java
+14
-4
14 additions, 4 deletions
src/states/Player.java
with
18 additions
and
8 deletions
src/states/FlyingEnemy.java
+
3
−
3
View file @
e793bee2
...
...
@@ -32,8 +32,8 @@ public class FlyingEnemy extends Object{
}
public
Bomb
dropBomb
()
{
//om man vill kan man skicka med players x pos på dirren, blir lite svårare då ba
public
Bomb
dropBomb
(
Player
p
)
{
if
(!
bombDropped
&&
this
.
getX
()
>=
bombDropX
-
50
&&
this
.
getX
()
<=
bombDropX
+
50
)
{
Bomb
bomb
=
new
Bomb
(
Constants
.
bombImg
,
bombDropX
,
50
,
Constants
.
bombHeight
,
Constants
.
bombWidth
);
// Drop the bomb at bombDropX
...
...
@@ -42,7 +42,7 @@ public class FlyingEnemy extends Object{
bombDropped
=
true
;
// Mark that the bomb has been dropped
// Optionally, reset bombDropX to a new random location after dropping the bomb
bombDropX
=
dropNextBomb
X
();
bombDropX
=
p
.
getPlayer
X
();
return
bomb
;
}
...
...
This diff is collapsed.
Click to expand it.
src/states/PlayState.java
+
1
−
1
View file @
e793bee2
...
...
@@ -389,7 +389,7 @@ public class PlayState extends GameState {
flyingEnemy
.
setX
(
flyingEnemy
.
getX
()
-
movingSpeed
);
Bomb
droppedBomb
=
flyingEnemy
.
dropBomb
();
Bomb
droppedBomb
=
flyingEnemy
.
dropBomb
(
player
);
if
(
droppedBomb
!=
null
)
{
bomb
=
droppedBomb
;
...
...
This diff is collapsed.
Click to expand it.
src/states/Player.java
+
14
−
4
View file @
e793bee2
...
...
@@ -118,12 +118,12 @@ public class Player {
}
public
void
setPlayerX
(
double
playerX
)
{
...
...
@@ -139,7 +139,12 @@ public class Player {
public
void
moveLeft
(
int
movingSpeed
)
{
playerX
-=
movingSpeed
;
if
(
playerX
>
0
)
{
playerX
-=
movingSpeed
;
}
}
...
...
@@ -147,7 +152,12 @@ public class Player {
public
void
moveRight
(
int
movingSpeed
)
{
playerX
+=
movingSpeed
;
if
(
playerX
<
Constants
.
screenWidth
-
Constants
.
playerWidth
)
{
playerX
+=
movingSpeed
;
}
}
...
...
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