Skip to content
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

Update from Main (Reversing so changes are made to SCP-49) #74

Closed
wants to merge 120 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
45e1175
Created SCP-57
LittleTealeaf Nov 16, 2021
4ce9348
Started adding steps to Test Case SCP-57
LittleTealeaf Nov 16, 2021
ae9a60e
Created Test Case SCP-56
LittleTealeaf Nov 16, 2021
b1547e6
Fix Typo in Test Case SCP-56
LittleTealeaf Nov 16, 2021
bfdbdeb
Added list of functionalities tested in Test Case SCP-57
LittleTealeaf Nov 16, 2021
8650d88
Finalized current Test Case SCP-57
LittleTealeaf Nov 16, 2021
5e52c54
Deprecated Player.java to Player_Old.java
LittleTealeaf Nov 16, 2021
2a1c453
Started working on new Player.java
LittleTealeaf Nov 16, 2021
0146d07
Continued work on rebuilding Player.java
LittleTealeaf Nov 16, 2021
f15d7c4
Optimized Stopwatch.java
LittleTealeaf Nov 17, 2021
8ccbdfc
Continued work on Player.java
LittleTealeaf Nov 17, 2021
9925e55
Deprecated Cat.java, created copy to modify.
LittleTealeaf Nov 17, 2021
5c44785
Added KeyLocker.isActionUnlocked method
LittleTealeaf Nov 17, 2021
e92b3df
Proceeded to the testing phase of changes
LittleTealeaf Nov 17, 2021
4163078
The Kitty now Jumps
LittleTealeaf Nov 17, 2021
da32f55
Kitty Moves!
LittleTealeaf Nov 17, 2021
024afd9
Cat Jumping is buggy, attempting to find fix
LittleTealeaf Nov 17, 2021
f6f89c8
Implement Collision Types to Entities
LittleTealeaf Nov 17, 2021
d862542
Added Death Animation (Much faster now too)
LittleTealeaf Nov 17, 2021
5df6be7
Death Animation now maintains previous velocity
LittleTealeaf Nov 17, 2021
3177508
Cat can now complete levels
LittleTealeaf Nov 17, 2021
d96365c
Added parameter for applying gravity with max velocity
LittleTealeaf Nov 17, 2021
266e6e5
Migrated Boss-Death detection to BossBattle.java
LittleTealeaf Nov 17, 2021
0076c3d
Add tests to Test Case SCP-57
LittleTealeaf Nov 17, 2021
cedef5b
Smoothed out player velocity in death animations
LittleTealeaf Nov 17, 2021
e8b031e
Code Cleanup / Bug Fixing
LittleTealeaf Nov 17, 2021
78d1c6c
Optimizing Call-Stack
LittleTealeaf Nov 17, 2021
1d44f46
Removed Deprecated Classes
LittleTealeaf Nov 17, 2021
0281c81
renamed velocityX to absVelocityX
LittleTealeaf Nov 17, 2021
0523ffa
Removed Unnecessary Case
LittleTealeaf Nov 17, 2021
a28cc4a
Removed Bounds method
LittleTealeaf Nov 17, 2021
bda4989
Optimized map-edge collision and animation
LittleTealeaf Nov 17, 2021
e5897d2
Removed Wrapper Method
LittleTealeaf Nov 17, 2021
710b241
Added Author
LittleTealeaf Nov 17, 2021
a5af7ee
Added additional comments
LittleTealeaf Nov 17, 2021
d5ddd07
Restructured how Test Case SCP-56 is executed
LittleTealeaf Nov 17, 2021
8820dab
Added Pass/Fail to individual tests
LittleTealeaf Nov 17, 2021
147a0d7
Modified headings of tests table to better format once data was inputted
LittleTealeaf Nov 17, 2021
abab678
Updated Test Case SCP-56
LittleTealeaf Nov 17, 2021
216203b
Added debug that displays the time (in ms) between frames
LittleTealeaf Nov 17, 2021
50e1664
Player can now crouch
LittleTealeaf Nov 17, 2021
10f17bc
Added Measurement for Cat Sprinting
LittleTealeaf Nov 17, 2021
b6fecf2
Added code to detect highest refresh rate
LittleTealeaf Nov 17, 2021
d09e934
Removed code meant for different branch
LittleTealeaf Nov 17, 2021
2d86890
Removed code meant for different branch
LittleTealeaf Nov 17, 2021
ad37857
Added code to fetch the highest refresh rate
LittleTealeaf Nov 17, 2021
4a4503b
Created GameTick.java, which uses Threads to send updates rather than…
LittleTealeaf Nov 17, 2021
2cd8654
Assigned runnable variable
LittleTealeaf Nov 17, 2021
633f62f
Game indeed runs different on different computers
LittleTealeaf Nov 19, 2021
8174efc
It was at this moment, he knew
LittleTealeaf Nov 19, 2021
3af25e5
Added Scaler to GameThread.java
LittleTealeaf Nov 19, 2021
10f8706
Merge pull request #55 from LittleTealeaf/SCP-57
LittleTealeaf Nov 19, 2021
2677d4d
Player moves?
LittleTealeaf Nov 19, 2021
266ce4b
Player finishing the level now correctly works
LittleTealeaf Nov 19, 2021
731623c
Player successfully moves at the same speed on different computers
LittleTealeaf Nov 19, 2021
24a8008
Changed to Single Thread
LittleTealeaf Nov 19, 2021
b6e281e
Game breaks when tick delay is set to 5
LittleTealeaf Nov 19, 2021
fb2c48d
Deprecated RenderThread for now
LittleTealeaf Nov 19, 2021
69bd9d9
Changed Tick Delay to 1
LittleTealeaf Nov 19, 2021
5f2989d
Located code responsible for causing animation errors
LittleTealeaf Nov 19, 2021
54d9431
I've decided I may rewrite a few classes
LittleTealeaf Nov 19, 2021
b603a4f
Added list of ideas needed for task
LittleTealeaf Nov 19, 2021
c605f87
Removed Thread Variable
LittleTealeaf Nov 19, 2021
2aab7bd
Commenting / Parsing out Collision Detection
LittleTealeaf Nov 19, 2021
fe090ee
Created Vector.java to hold vectors
LittleTealeaf Nov 19, 2021
6a605c5
Implemented Vectors, started work on Collision Handling
LittleTealeaf Nov 20, 2021
b175ff8
Collision Handling will be handled in GameObject.java
LittleTealeaf Nov 21, 2021
f3b4af3
New Collisions actually detect if a collision occurred.
LittleTealeaf Nov 21, 2021
b14be3c
Added EnhancedMapTiles to the collision check
LittleTealeaf Nov 21, 2021
487e039
Collisions work... not!
LittleTealeaf Nov 21, 2021
1e668ba
Player now skips first 2 move updates
LittleTealeaf Nov 22, 2021
95cd0a5
Re-built Game Thread
LittleTealeaf Nov 22, 2021
05f7b56
Cat hits the ground! Kindof
LittleTealeaf Nov 22, 2021
a59c96e
Back to the drawing board
LittleTealeaf Nov 22, 2021
1b6c450
Vector Physics should work
LittleTealeaf Nov 22, 2021
3031dc2
Added method in Map to get mapTiles
LittleTealeaf Nov 22, 2021
a9da456
Add in inAir calculations
LittleTealeaf Nov 22, 2021
d4f6c8d
Deprecated RectangleOld.java, created new Rectangle.java
LittleTealeaf Nov 23, 2021
58e78eb
Converted use to new Rectangle.java
LittleTealeaf Nov 23, 2021
5ba8964
Switched back to iterative algorithm
LittleTealeaf Nov 23, 2021
cf55e97
So collision detection works...
LittleTealeaf Nov 23, 2021
cc9d180
Cleaning up Entity Bounds
LittleTealeaf Nov 23, 2021
68867f5
Fixed scaled bounds originating at (0,0)
LittleTealeaf Nov 23, 2021
6f8b741
Revert back / implement fix for task
LittleTealeaf Nov 23, 2021
9fa3832
Clean-up
LittleTealeaf Nov 23, 2021
9980858
Additional Cleanup
LittleTealeaf Nov 23, 2021
9c16ac7
Merge pull request #56 from LittleTealeaf/main
LittleTealeaf Nov 23, 2021
6309e47
Drafting up features for Test Case SCP-52
LittleTealeaf Nov 23, 2021
b6c638d
Merge pull request #57 from LittleTealeaf/SCP-56
LittleTealeaf Nov 23, 2021
76460b6
Drafted Test Case SCP-52
LittleTealeaf Nov 24, 2021
16e6b3b
Added Timer to top right of screen
LittleTealeaf Nov 24, 2021
8d80799
Formatted Timer to remove un-needed 0s at the front
LittleTealeaf Nov 24, 2021
7b55a4f
Reduced Next-Level wait time
LittleTealeaf Nov 24, 2021
b566230
Added name field for each map
LittleTealeaf Nov 27, 2021
1776743
Started work on GameScoreScreen.java
LittleTealeaf Nov 27, 2021
ff4f506
Created Test Case SCP-49
NicholasTourony Nov 29, 2021
c998bb8
Created the Difficulty Selection Menu
NicholasTourony Nov 29, 2021
1ad7a1f
Merge pull request #60 from LittleTealeaf/main
LittleTealeaf Nov 29, 2021
f5dc589
Moved Rendering to happen immediately after any update
LittleTealeaf Nov 29, 2021
48b82b8
Added Laptop Measurements to Test Case SCP-56
LittleTealeaf Nov 29, 2021
7d11412
Added Prerequisite for Test Case SCP-56
LittleTealeaf Nov 29, 2021
4617d3a
Added Prerequisite for Test Case SCP-57
LittleTealeaf Nov 29, 2021
464526b
Merge pull request #62 from LittleTealeaf/SCP-56
LittleTealeaf Nov 29, 2021
45d7887
Game Timer now stops only when the player completes the last map
LittleTealeaf Nov 29, 2021
225cf88
Continued work on GameScoreScreen.java
LittleTealeaf Nov 29, 2021
8125462
Set Default Value for SpriteFont.java
LittleTealeaf Nov 29, 2021
763f20e
Game no longer renders while behind on ticks
LittleTealeaf Nov 29, 2021
300740b
Merge pull request #63 from LittleTealeaf/SCP-56
LittleTealeaf Nov 29, 2021
0402c1a
Fixed rendering of time above a certain point
LittleTealeaf Nov 29, 2021
ba3f2cc
Merge remote-tracking branch 'origin/SCP-52' into SCP-52
LittleTealeaf Nov 29, 2021
fd0ccaa
Time now renders "1" minute instead of "01" minutes
LittleTealeaf Nov 29, 2021
bc59bb9
Added a difficulty holder that sets player health based on difficulty
NicholasTourony Nov 29, 2021
7b7911e
Fixed the starting difficulty
NicholasTourony Nov 29, 2021
8a90985
Hardcore mode restarts the user on the first level
NicholasTourony Nov 29, 2021
278abca
Merge branch 'SCP-52' into SCP-49
LittleTealeaf Nov 29, 2021
6e98819
Enemy movement and projectile speed increases with difficulty
NicholasTourony Nov 30, 2021
aa288f4
Selecting a difficulty returns the user to the main menu
NicholasTourony Nov 30, 2021
af81349
Updated Test Case SCP-49
NicholasTourony Nov 30, 2021
45a38b7
Updated Test Case SCP-49
NicholasTourony Nov 30, 2021
df55f59
Merge branch 'main' into SCP-49
LittleTealeaf Nov 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Team A2/Test Cases/Test Case SCP-49.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
### Test Case Information
| TEST CASE ID | SCP-49 |
| :--- | :--- |
| Owner of Test | Nicholas Tourony |
| Test Name | Difficulty Test |
| Date of Last Revision | 11/28/2021 |
| Test Objective | Ensure that the difficulty settings change the amount of health the cat has and changes the movement speed of the enemies and their projectiles. |

### Procedure

|Step | Action | Expected Result | Pass/Fail |
|:---:| :--- | :---- | :---: |
|1| Run the game| The game successfully opens |P|
|2| Select the difficulty menu. | The difficulty menu opens. | [RESULT] |
|3| Select normal difficulty | The game lets you select normal difficulty and automatically puts you back to the main menu. | [RESULT] |
|4| Start the game. | The cat is loaded into the first level with 3 health and the enemies and projectiles move at their slowest speed. | [RESULT] |
|5| Take projectile damage until the character dies | The cat can take 3 projectile hits before dying. | [RESULT] |
|6| Respawn and run into an enemy. | The cat instantly dies. | [RESULT] |
|7| Select hard difficulty and start the game | The cat is loaded into the first level with 2 health and the enemies move faster. | [RESULT] |
|8| Take projectile damage until the character dies | The cat can take 2 projectile hits before dying. | [RESULT] |
|9| Respawn and run into an enemy. | The cat instantly dies. | [RESULT] |
|10| Select hardcore difficulty and start the game. | The cat is loaded into the first level with 1 health and the enemies move even faster. | [RESULT] |
|11| Take damage. | The cat dies. | [RESULT] |
|12| Press escape. | The player is returned to the main menu. | [RESULT] |
|13| Load into level 6, die to any enemy, and press space. | The player is restarted at the tutorial level. | [RESULT] |

### Test Completion
- **Tester**: [TESTER NAME]
- **Date of Test**: DATE OF TEST
- **Test Result**: TEST RESULT
35 changes: 35 additions & 0 deletions Team A2/Test Cases/Test Case SCP-52.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
### Test Case Information
| TEST CASE ID | SCP-52 |
| :--- | :--- |
| Owner of Test | Thomas Kwashnak |
| Test Name | Test Speed-Running Enhancements |
| Date of Last Revision | 11/23/2021 |
| Test Objective | Testing Additions and Functionality Changes of Speed-Running Enhancements |

#### Tested Enhancements
- Stopwatch
- Top-Right of screen when playing
- Entering from main menu resets timer
- Stores time took to complete each level, displays current level's time, as well as total time for all previous times
- Some way to display the user's final result (breakdown of levels) after beating final boss
- Deaths are in some way detrimental to a user's level time (either make death animation slower, or make death screen longer)
- Pausing the game pauses the time
- Level Completed Screens display quicker (shorter time)

### Procedure

|Step | Action | Expected Result | Pass/Fail |
|:---:| :--- | :---- | :---: |
|1|Run the game|The game loads up. There is no timer on the main menu.||
|2|Click Play|The tutorial level is loaded. On the top right is one timer that times the amount of elapsed time since the player started.||
|3|Navigate and die in the tutorial level|The dead screen has a count-down displayed.||
|4|While the death screen's countdown is counting down, try to hit space to respawn|The player is not able to respawn until the countdown timer is over||
|5|Navigate through the level and die once again. Once the death screen is loaded, hit escape to go back to the main menu|The main menu is loaded and the timer no longer displays||
|6|Hit "Play" again to go back into the main menu|The tutorial level is loaded, and the timer is reset back to 0||
|7|Complete the tutorial level|The level completed screen is shown, but only for a brief second before the next level is loaded. On the top right is now two timers, one that displays the total time, and another that displays the elapsed time for the current level||
|8|Hit `P/Escape` to pause the game|While the game is paused, timers are also paused||

### Test Completion
- **Tester**: [TESTER NAME]
- **Date of Test**: DATE OF TEST
- **Test Result**: TEST RESULT
46 changes: 46 additions & 0 deletions Team A2/Test Cases/Test Case SCP-56.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
### Test Case Information
| TEST CASE ID | SCP-56 |
| :--- | :--- |
| Owner of Test | Thomas Kwashnak |
| Test Name | Test Game Speed |
| Date of Last Revision | 11/16/2021 |
| Test Objective | Ensure that the game runs consistently through multiple distributions |
| Test Notes| Due to the nature of this test case, multiple runs of the test must be conducted on various machines of different make and models. Measurements will be taken using a recording software, and should not be expected to be perfect|
|Software Requirement|**Screen recording software:** Needs to be able to record the screen such that the tester can go back and accurately measure the time between events. *Suggested:* OBS|
|Prerequisites|Test Case SCP-57 must be completed prior to this merge|


### Procedure

|Step | Action | Expected Result | Measurement Field |
|:---:| :--- | :---- | :----:|
|1|Run the game|The game successfully opens||
|2|Begin recording|A screen recorder is started that records the game||
|3|Click *Play Game*|The tutorial level is successfully opened||
|4|Walk to the left-most edge of the level|The cat is at the left most bound of the tutorial level||
|5|Hold `D/Right Arrow` until the cat is blocked from moving by the tree|The cat moves from the edge of the map into the tree|**Measurement 1:** The time it takes starting when the cat begins moving to when the cat finishes moving|
|6|Hold `Shift`, then hold `A/Left Arrow` until the cat stops moving at the left edge of the map|The player sprints to the left-most edge of the map|**Measurement 2:** The time it takes for the cat to move starting when the cat begins moving to when the cat is stopped by the map edge|
|7|Hold `Space/W/Up Arrow` until the cat reaches the ground again|The cat jumps and lands back on the ground|**Measurement 3:** The time it takes starting when the cat begins jumping to when the cat hits the ground again|
|8|Hold `e` until the player shoots a reasonable amount of fireballs|The cat shoots multiple fireballs|**Measurement 4:** The time between two consecutive fireballs spawning (multiple attempts can be averaged if needed)|\
|9|Complete the tutorial level|When the tutorial level is completed, the `level complete` is shown, and after a few seconds the player is loaded into the next level|**Measurement 5:** The time that the `level complete` screen is shown

### Test Execution
Instances of tests are listed in table below (template provided). Measurements listed in instructions above are listed below for test completer to evaluate.

**Overall Test Completion** indicates whether all steps were completed and no errors / inability to follow instructions occurred.


|Date|Name|Device Information | Measure 1|Measure 2|Measure 3|Measure 5|Measure 4|Pass/Fail|
|:---:|:---|:---|:---:|:---:|:---:|:---:|:---:|:---:|
|[DATE]|[TESTER_NAME]|[CONFIG]|[MEASURE 1]|[MEASURE 2]|[MEASURE 3]|[MEASURE 4]|[MEASURE 5]|[PASS/FAIL]|
|11/29/2021 10:41 AM|Thomas Kwashnak|Kubuntu 21.10 Laptop, Intel i7 CPU, NVIDIA MX330 GPU|\~ 2 seconds|\~1 second|\~1 second|\~1-2 seconds|~3 seconds|Pass. Game runs at expected speed|

[comment]: <> (Add test rows to end here ^^)

### Completion Criteria
- There are no outliers on all measurements

### Test Completion
- **Tester**: [TEST REVIEWER NAME]
- **Date of Test**: [TEST COMPLETION DATE]
- **Test Result**: [TEST RESULT]
56 changes: 56 additions & 0 deletions Team A2/Test Cases/Test Case SCP-57.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
### Test Case Information
| TEST CASE ID | SCP-57 |
| :--- | :--- |
| Owner of Test | Thomas Kwashnak |
| Test Name | Test Player Functionality |
| Date of Last Revision | 11/16/2021 |
| Test Objective | Ensure that all current functionalities of the player is implemented in new Player class and still functional |

Functionality of `Player.java` tested:
- Movement, and movement animations
- Jumping, including gravity and hitting floor
- Animation while jumping
- Collision with enemies
- Shooting, including animations while standing still and moving
- Collision with map boundaries and map walls
- Ability to complete all levels with physics

### Procedure

|Step | Action | Expected Result | Pass/Fail |
|:---:| :--- | :---- | :---: |
|0a| **Evaluated on Each Step:** | Player Animation changes as expected |`N/A`|
|1| Run the game| The game successfully opens ||
|2| Click "*Play*" |The tutorial level is entered, game does not crash. 3 hearts are displayed on the top of the screen.||
|3| Hold `A/Left Arrow` |The player moves to the left. The player does not fall off the map and is instead stopped at the edge||
|4| Hold `D/Right Arrow`|The player moves to the right. The player is stopped once they hit the tree||
|5| Hold both `A/Left Arrow` and `D/Right Arrow`|The player stands still||
|6| Tap `Space/W/Up Arrow` | The player short-jumps. The player then falls back down after the button is let go and lands on the ground||
|7|Hold `Space/W/Up Arrow` | The player high-jumps. The player falls back down after a certain height and and falls back down to the ground||
|8|Hold `Shift` and repeat steps 3-5|The player moves in the same ways as stated above, but faster||
|9|Hold `ctrl`|The player crouches||
|10|Tap `A/Left Arrow`, then hit `Space/W/Up Arrow` quickly followed by `D/Right Arrow`|The player faces left, then switches to facing right while in the air||
|11|Tap `D/Right Arrow`, then hit `Space/W/Up Arrow` quickly followed by `A/Left Arrow`|The player faces right, then switches to facing left while in the air||
|12|Tap `A/Left Arrow`, then tap `e` (*Attack Button*)|The player faces to the left, and attacks, sending a projectile to the left||
|13|Hold `A/Left Arrow`, then tap `e` |The player moves to the left, and attacks while moving||
|14|Tap `Space/W/Up Arrow`, then tap `e` while in the air|The player jumps while facing left, and then shoots a projectile while in the air||
|15|Tap `D/Right Arrow`, then tap `e` |The player faces to the right, and attacks, sending a projectile to the right||
|16|Hold `D/Right Arrow`, then tap `e` |The player moves to the right, and attacks while moving||
|17|Tap `Space/W/Up Arrow`, then tap `e` while in the air|The player jumps while facing right, and then shoots a projectile while in the air||
|18|Hold `e`|The player shoots once, then cannot shoot for a specified duration of time||
|19|Navigate and run into enemy|The player's health is set to 0 and the player dies. Death animation is played and player falls down to the ground||
|20|Restart the game|The level is loaded again, and the player's health is back to full||
|21|Navigate and run into a projectile from an enemy|The player's health is now 2 (reduced by 1)||
|22|Navigate and attempt to run off the right-most edge of the map (*without hitting the gold level-complete box*)|The player is stopped and cannot run off of the map||
|23|Hit the complete-level gold box|The level is completed and the player walks off to the right of the screen||
|24|Hit Escape, go back to main menu|The main menu is displayed||
|25|Hit "Play Game"|The first level is loaded||
|26|Play all levels of the game|Each level is completable||




### Test Completion
- **Tester**: [TESTER NAME]
- **Date of Test**: DATE OF TEST
- **Test Result**: TEST RESULT
30 changes: 20 additions & 10 deletions src/Enemies/BugEnemy.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package Enemies;

import Builders.FrameBuilder;
import Engine.GamePanel;
import Engine.ImageLoader;
import GameObject.Frame;
import GameObject.ImageEffect;
import GameObject.SpriteSheet;
import Level.Enemy;
import Level.Player;
import Utils.AirGroundState;
import Utils.Direction;
import Utils.Point;

Expand All @@ -19,10 +19,14 @@
public class BugEnemy extends Enemy {

private float gravity = .5f;
private float movementSpeed = .5f;

// different speeds depending on the difficulty
private static final float NORMAL_SPEED = 0.5f, HARD_SPEED = 0.7f, HARDCORE_SPEED = 0.9f;
float movementSpeed = NORMAL_SPEED;

private Direction startFacingDirection;
private Direction facingDirection;
private AirGroundState airGroundState;
private boolean isInAir;

public BugEnemy(Point location, Direction facingDirection) {
super(location.x, location.y, new SpriteSheet(ImageLoader.load("BugEnemy.png"), 24, 15), "WALK_LEFT");
Expand All @@ -39,19 +43,29 @@ public void initialize() {
} else if (facingDirection == Direction.LEFT) {
currentAnimationName = "WALK_LEFT";
}
airGroundState = AirGroundState.GROUND;
isInAir = false;
}

@Override
public void update(Player player) {
float moveAmountX = 0;
float moveAmountY = 0;

// set the movement speed of the enemy depending on what difficulty it selected
if (GamePanel.getDifficultyHolder().getDifficulty() == 2)
{
movementSpeed = HARD_SPEED;
}
else if (GamePanel.getDifficultyHolder().getDifficulty() == 1)
{
movementSpeed = HARDCORE_SPEED;
}

// add gravity (if in air, this will cause bug to fall)
moveAmountY += gravity;

// if on ground, walk forward based on facing direction
if (airGroundState == AirGroundState.GROUND) {
if (!isInAir) {
if (facingDirection == Direction.RIGHT) {
moveAmountX += movementSpeed;
} else {
Expand Down Expand Up @@ -86,11 +100,7 @@ public void onEndCollisionCheckY(boolean hasCollided, Direction direction) {
// if bug is colliding with the ground, change its air ground state to GROUND
// if it is not colliding with the ground, it means that it's currently in the air, so its air ground state is changed to AIR
if (direction == Direction.DOWN) {
if (hasCollided) {
airGroundState = AirGroundState.GROUND;
} else {
airGroundState = AirGroundState.AIR;
}
isInAir = !hasCollided;
}
}

Expand Down
32 changes: 23 additions & 9 deletions src/Enemies/CyborgEnemy.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package Enemies;

import Builders.FrameBuilder;
import Engine.GamePanel;
import Engine.ImageLoader;
import GameObject.Frame;
import GameObject.ImageEffect;
import GameObject.SpriteSheet;
import Level.Enemy;
import Level.Player;
import Projectiles.LazerBeam;
import Utils.AirGroundState;
import Utils.Direction;
import Utils.Point;
import Utils.Stopwatch;

import java.util.HashMap;
import java.util.Timer;

// This class is for the cyborg
// It walks back and forth between two set points (startLocation and endLocation)
Expand All @@ -29,10 +28,14 @@ public class CyborgEnemy extends Enemy {
// Whether or not the game is waiting for LazerBeams to launch
private boolean wait = false;

protected float movementSpeed = 0.5f;
// different speeds depending on the difficulty
private static final float NORMAL_SPEED = 0.5f, HARD_SPEED = 0.7f, HARDCORE_SPEED = 0.9f;
float movementSpeed = NORMAL_SPEED;
private static final float NORMAL_LAZER_SPEED = 1.5f, HARD_LAZER_SPEED = 1.7f, HARDCORE_LAZER_SPEED = 1.9f;

private Direction startFacingDirection;
protected Direction facingDirection;
protected AirGroundState airGroundState;
protected boolean isInAir;

// timer is used to determine when a lazer is to be shot out
protected Stopwatch shootTimer = new Stopwatch();
Expand Down Expand Up @@ -62,7 +65,7 @@ public void initialize() {
} else if (facingDirection == Direction.LEFT) {
currentAnimationName = "WALK_LEFT";
}
airGroundState = AirGroundState.GROUND;
isInAir = false;

// every 2 seconds, the lazer will be shot out
shootTimer.setWaitTime(2000);
Expand All @@ -72,7 +75,20 @@ public void initialize() {
public void update(Player player) {
float startBound = startLocation.x;
float endBound = endLocation.x;
float lazerMovementSpeed = NORMAL_LAZER_SPEED;

// set the movement speed of the enemy and lazer attack depending on what difficulty it selected
if (GamePanel.getDifficultyHolder().getDifficulty() == 2)
{
movementSpeed = HARD_SPEED;
lazerMovementSpeed = HARD_LAZER_SPEED;
}
else if (GamePanel.getDifficultyHolder().getDifficulty() == 1)
{
movementSpeed = HARDCORE_SPEED;
lazerMovementSpeed = HARDCORE_LAZER_SPEED;
}

// if shoot timer is up and cyborg is not currently shooting, set its state to SHOOT
if (shootTimer.isTimeUp() && cyborgState != cyborgState.SHOOT) {
cyborgState = cyborgState.SHOOT;
Expand Down Expand Up @@ -114,16 +130,14 @@ public void update(Player player) {
// define where LazerBeam will spawn on map (x location) relative to cyborg enemy's location
// and define its movement speed
int LazerBeamX;
float movementSpeed;
LazerBeamX = Math.round(getX());
movementSpeed = 1.5f;

// define where LazerBeam will spawn on the map (y location) relative to cyborg enemy's location
int LazerBeamY = Math.round(getY() + 15);

// create LazerBeam enemy
LazerBeam LazerBeam = new LazerBeam(new Point(LazerBeamX + 20, LazerBeamY), movementSpeed, 1000);
LazerBeam LazerBeam2 = new LazerBeam(new Point(LazerBeamX - 10, LazerBeamY), -movementSpeed, 1000);
LazerBeam LazerBeam = new LazerBeam(new Point(LazerBeamX + 20, LazerBeamY), lazerMovementSpeed, 1000);
LazerBeam LazerBeam2 = new LazerBeam(new Point(LazerBeamX - 10, LazerBeamY), -lazerMovementSpeed, 1000);

// add LazerBeam enemy to the map for it to offically spawn in the level
map.addProjectile(LazerBeam);
Expand Down
Loading