Skip to content

Commit

Permalink
Fix infinite loop in patrol
Browse files Browse the repository at this point in the history
  • Loading branch information
nrebei2 committed Apr 16, 2023
1 parent 751bf31 commit 98e3168
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 43 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lunar-Haze
Game Control Lists:
Go to Level Editor L
(From Main Menu) Go to Level Editor L
Move Up W
Move Down S
Move Left A
Expand All @@ -13,10 +13,10 @@ Rules for the game:
Stealth Phase:
1. Move around to collect moonlight
2. You can not attack enemies in this phase
3. Try to be away from enemies to keep your health
3. Try to be hide from enemies to keep your health

End of Stealth Phase:
1. Choose the power you want to increase by using moonlight
1. Choose the power you want to increase by using the moonlight you collected in the previous phase

Battle Phase:
1. Kill all the enemies to win the game
Expand Down
3 changes: 3 additions & 0 deletions assets/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: infinityx.DesktopLauncher

41 changes: 10 additions & 31 deletions assets/jsons/newLevel.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"settings": {
"transition": 2,
"phaseLength": 2,
"battle-ambiance": [ 0.9613312482833862, 0.9674192667007446, 0.979626476764679, 1.0 ],
"battle-ambiance": [ 1.0, 1.0, 1.0, 1.0 ],
"enemy-spawner": {
"count": 5,
"add-tick": [ 500, 900 ],
"delay": 1000
}
},
"ambient": {
"color": [ 0.9613312482833862, 0.9674192667007446, 0.979626476764679, 1.0 ],
"color": [ 1.0, 1.0, 1.0, 1.0 ],
"gamma": true,
"diffuse": true,
"blur": 5,
Expand All @@ -21,11 +21,11 @@
"type": "grass",
"layout": [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 ],
[ 6, 6, 6, 6, 6, 5, 5, 5, 5, 5 ],
[ 6, 6, 6, 6, 6, 6, 5, 2, 2, 2 ],
[ 6, 6, 6, 6, 6, 6, 5, 5, 2, 2 ],
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
Expand All @@ -42,36 +42,15 @@
}
},
"scene": {
"player": [ 5, 4 ],
"player": [],
"enemies": [
{
"type": "villager",
"position": [ 1, 2 ],
"position": [ 2, 7 ],
"patrol": []
}
],
"objects": [
{
"type": "stone",
"scale": 1,
"position": [ 8, 3 ]
},
{
"type": "tree",
"scale": 1,
"position": [ 8, 1 ]
},
{
"type": "house",
"scale": 1,
"position": [ 8, 4 ]
},
{
"type": "house",
"scale": 1,
"position": [ 10, 1 ]
}
]
"objects": []
}
}
}
7 changes: 0 additions & 7 deletions assets/jsons/player.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
"height": 0.5
}
},
// "hitbox": {
// "bodytype": "dynamic",
// "width": 10,
// "height": 10,
// "offset": 1,
// "bullet": true
// },
"spotlight": {
"color": [0.65, 0.6, 0.77, 0.6],
"distance": 1,
Expand Down
4 changes: 4 additions & 0 deletions core/src/infinityx/lunarhaze/EnemyController.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ public void setInBattle(boolean inBattle) {
this.inBattle = inBattle;
}

public boolean isInBattle() {
return inBattle;
}

/**
* @return Random point in patrol area
*/
Expand Down
2 changes: 2 additions & 0 deletions core/src/infinityx/lunarhaze/entity/EnemySpawner.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.JsonValue;
import infinityx.lunarhaze.EnemyState;
import infinityx.lunarhaze.LevelContainer;

import java.util.ArrayList;
Expand Down Expand Up @@ -72,6 +73,7 @@ public void update(int tick) {
);
// This spawner is only used in battle phase
container.getEnemyControllers().get(newEnemy).setInBattle(true);
container.getEnemyControllers().get(newEnemy).getStateMachine().changeState(EnemyState.ALERT);
enemyAddTick = MathUtils.random(addMin, addMax);
this.count--;
}
Expand Down
1 change: 1 addition & 0 deletions core/src/infinityx/lunarhaze/entity/Werewolf.java
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ public void createAttackHitbox(World world) {
attackHitbox = new AttackHitbox(HITBOX_SIZE, this);

attackHitbox.activatePhysics(world);
attackHitbox.setSensor(true);
attackHitbox.setActive(false);
}

Expand Down
4 changes: 2 additions & 2 deletions gameplay 2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Lunar Haze

Instructions for players:

Move the players using the arrow keys. The main objective of this protoype is
Move the players using the arrow keys. The main objective of this prototype is
to collect all the lighted moonlight tiles on the map. To collect moonlight,
you must stand on the tile for two consecutive seconds. However, standing on
a moonlight tile will also reveal you to the enemy.
Expand All @@ -14,4 +14,4 @@ How the enemy works:

The enemy will walk in a set patrol path. Their current line of vision is a
line. Once you get into an enemy's sight, they will chase you until you are
out of a set chase distance.
out of a set chase distance.

0 comments on commit 98e3168

Please sign in to comment.