New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5 Shields #54
Merged
Merged
5 Shields #54
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7585846
started shield functionality
TorbsT 5eceba1
shields now functional me thinks
TorbsT 76710f1
merge master into shields
HeleneAmlie e700e3f
(#5) Minor changes
HeleneAmlie e6b2702
(#5) Minor changes 2.0
HeleneAmlie 9d611f8
(#5) Bug for moving and displaying shields
HeleneAmlie 64ac5d9
(#56) might fix bug
HeleneAmlie File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,48 @@ | ||
package group16.project.game.ecs.system | ||
|
||
class ShieldSystem { | ||
import com.badlogic.ashley.core.Entity | ||
import com.badlogic.ashley.core.Family | ||
import com.badlogic.ashley.systems.IteratingSystem | ||
import group16.project.game.ecs.component.* | ||
import group16.project.game.ecs.notNull | ||
import com.badlogic.gdx.graphics.g2d.Batch | ||
import group16.project.game.Configuration | ||
import group16.project.game.ecs.utils.ComponentMapper | ||
import javax.xml.crypto.dsig.Transform | ||
|
||
fun increase() { | ||
//if the ufo and shield are at the same spot, increase the shield strength | ||
// if | ||
// shield++; | ||
class ShieldSystem: IteratingSystem( | ||
Family.all( | ||
PositionComponent::class.java, | ||
BodyComponent::class.java, | ||
ShieldComponent::class.java, | ||
TransformComponent::class.java, | ||
).get()) { | ||
|
||
|
||
override fun processEntity(entity: Entity?, deltaTime: Float) { | ||
notNull( | ||
ComponentMapper.position[entity], | ||
ComponentMapper.shield[entity], | ||
ComponentMapper.body[entity], | ||
ComponentMapper.transform[entity], | ||
::render | ||
) | ||
} | ||
|
||
fun decrease() { | ||
//if the ufo is hit by a bullet, decrease the shield strength | ||
// if.. | ||
// shield--; | ||
private fun render(positionComponent: PositionComponent, shieldComponent: ShieldComponent, bodyComponent: BodyComponent, transformComponent: TransformComponent) { | ||
|
||
|
||
//println("yeah "+positionComponent.x) | ||
val padding = (Configuration.gameHeight - 4*100) / 2 | ||
val buttonHeight = 100 | ||
|
||
//println(positionComponent.y) | ||
if (shieldComponent.destroyed || shieldComponent.position < 0) { | ||
transformComponent.opacity = 0f | ||
} else { | ||
transformComponent.opacity = 1f | ||
} | ||
|
||
//println(positionComponent.y.toString() + " "+shieldComponent.position) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
InputHandler.playerShieldPosition
is a thing, you can just use it to draw the shield just like what we've have with the ufos.If this is however intentional that the shield is planned to still exist after being placed and not shot on that round, as well as that we can trigger/place multiple shields then ignore this :)
(if it is planned like so, then the firebase data needs to be reworked, as the data as of now only allows for 1 shield to be available at a time)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having a position value in ShieldComponent makes it easier to check position in ShieldSystem without having to check whether the ShieldComponent is left or right, so that's why we've implemented it that way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, if it is only used for that, then shieldComponent.player would suffice.
It is okay, a small fix / code cleanup in the future can be done. :)