Compare commits

..

No commits in common. "v0.8.0" and "v0.7.0" have entirely different histories.

5 changed files with 267 additions and 191 deletions

View File

@ -6,41 +6,6 @@ lignée du jeu amont (0.2.2 en 2017, abandonné).
## [Non publié]
## [0.7.0] — 2026-11-15
Le test coop à 2 clients réels révèle un bug réseau majeur de 2017 (jamais
testé à 2 par les équipes d'origine) : le thread réseau instaniait les
prefabs depuis un thread sans contexte OpenGL — crash natif. Fix + test coop
desktop×2 contre le matchmaker self-hosté.
### Ajouté
- **COMPAGNON Kubrow** (feedback utilisateur : « Kubrow/sentinel AI » de la
roadmap Trello — le `DamageType.KUBROW` prévu par les équipes d'origine
existait déjà) : suit le joueur (course/idle), téléportation s'il se perd,
attaque au contact de l'ennemi le plus proche (dégâts 1, cooldown 1 s) ;
spawn en Défense à côté du joueur
- **Override de niveau au démarrage élargi** : `LS_LEVEL=<nom>` fonctionne
sans `LS_MP_HOST` (outil de test/dev : `LS_LEVEL=defense gradlew run`)
- **File d'instanciation réseau sur le thread de jeu**
(`Network.handlePendingInstantiations`) : le TCPReader 2017 instaniait les
prefabs réseau depuis son thread (pas de contexte OpenGL → crash natif
`glGenTextures` dès le premier prefab texturé) — bug jamais rencontré car
le multi n'a jamais été testé à 2
- **Test coop 2 clients desktop réels** contre le matchmaker self-hosté
local : les 2 clients dans la MÊME partie (game id=0, serveur), l'hôte
instancie et envoie **36 objets réseau** (lockers + player_other) au client
### Corrigé
- **Chemin des assets Kubrow périmé** : la classe dormante 2017 pointait vers
`images/kubrows/` (dossier fusionné en `data/` par la tâche Trello
"Merge directories") — bug latent jamais visible car la classe n'était
jamais instanciée
- `Kubrow.die()` : mort propre (tag enemy_dead, destruction différée) sans
compter dans les kills de mission
### Modifié
- `SpriteNotFoundInAtlasError` rendue package-private (catchable par GuiText)
## [0.6.0] — 2026-11-15
Le multijoueur 2017 revit : le serveur matchmaker d'origine (Node/UDP)

16
TODO.md
View File

@ -190,16 +190,10 @@ reste du portage Android.
natif glGenTextures) → file d'instanciation traitée sur le thread de
jeu (Network.handlePendingInstantiations) ; l'hôte instancie et envoie
36 objets réseau (lockers + player_other) au client
- [x] Multi : handshake P2P — PARTIEL (v0.7.0) : 2 clients dans la même
partie ✓, 36 objets réseau envoyés par l'hôte ✓, MAIS le client B ne
reçoit pas le player_join de l'hôte (direction des connexions TCP
2017 : l'hôte se connecte à 2829/2830 au lieu du port TCP de B) —
protocole jamais testé à 2 chez les équipes d'origine ; à debugger
avec les logs (serveur + client)
- [x] **Kubrow/sentinel AI** (roadmap Trello) — FAIT (v0.8.0) : compagnon
suivant le joueur + attaque au contact (dégâts KUBROW prévus par les
équipes d'origine) ; spawn en Défense ; assets originels réutilisés
(chemin data/kubrows corrigé)
- [x] Multi : self-host du matchmaker — FAIT (v0.6.0)
- [ ] Multi : handshake P2P restant — le client B ne reçoit pas le
player_join de l'hôte (direction des connexions TCP 2017 : l'hôte se
connecte à 2829/2830 au lieu du port TCP de B) — protocole jamais
testé à 2 chez les équipes d'origine ; à debugger avec les logs
(serveur + client)
- [ ] Test coop sur émulateur (client Android via 10.0.2.2) — BLOQUÉ : AVD
zombie (processus 91234 état UE, impossible à tuer sans redémarrage)

View File

@ -27,7 +27,6 @@ import com.ezardlabs.lostsector.levels.MultiplayerLobbyLevel;
import com.ezardlabs.lostsector.levels.ProceduralLevel;
import com.ezardlabs.lostsector.levels.SurvivalLevel;
import com.ezardlabs.lostsector.missions.SpawnPoint;
import com.ezardlabs.lostsector.objects.Kubrow;
import com.ezardlabs.lostsector.objects.Player;
import com.ezardlabs.lostsector.objects.enemies.corpus.crewmen.DeraCrewman;
import com.ezardlabs.lostsector.objects.enemies.corpus.crewmen.ProvaCrewman;
@ -80,12 +79,13 @@ public class Game extends BaseGame {
/*
* LS_LEVEL (env) : charger un niveau précis au démarrage (pattern du
* map.tmx override de Main.java) — outil de test/dev (ex :
* LS_LEVEL=multiplayer_lobby pour le multi, LS_LEVEL=defense pour la
* Défense sans clic).
* map.tmx override de Main.java) — test automatisé du lobby/multi sans
* clic : LS_LEVEL=multiplayer_lobby gradlew run.
*/
String startLevel = System.getenv("LS_LEVEL");
if (startLevel != null && !startLevel.isEmpty()) {
if (startLevel != null && !startLevel.isEmpty() && System.getenv("LS_MP_HOST") != null) {
// Un niveau non-menu ne sert qu'au test multi (env MP_HOST requis
// pour ne pas le rendre accessible par accident aux joueurs).
GameLog.i("LS-LEVEL", "LS_LEVEL override : démarrage sur '" + startLevel + "'");
LevelManager.loadLevel(startLevel);
} else {
@ -195,13 +195,5 @@ public class Game extends BaseGame {
private void registerSpawnPointPrefabs() {
PrefabManager.addPrefab("spawn_point", () -> new GameObject("Spawn Point", new SpawnPoint()));
/*
* COMPAGNON Kubrow (feedback utilisateur : "Kubrow/sentinel AI" de la
* roadmap) : coller aux colliders du joueur (150x100), pas de
* composants réseau (solo).
*/
PrefabManager.addPrefab("kubrow",
() -> new GameObject("Kubrow", new Renderer(), new Animator(), new Collider(150, 100),
new Rigidbody(), new Kubrow()));
}
}

View File

@ -12,7 +12,6 @@ import com.ezardlabs.dethsquare.TextureAtlas;
import com.ezardlabs.dethsquare.Vector2;
import com.ezardlabs.dethsquare.multiplayer.Network;
import com.ezardlabs.dethsquare.util.GameLog;
import com.ezardlabs.dethsquare.prefabs.PrefabManager;
import com.ezardlabs.lostsector.map.MapManager;
import com.ezardlabs.lostsector.missions.objectives.Cryopod;
import com.ezardlabs.lostsector.objects.enemies.CorpseFader;
@ -31,10 +30,6 @@ public class DefenseMission extends Mission {
GameObject player = Network.instantiate("player", MapManager.playerSpawn);
GameLog.i("LS-MISSION", "DefenseMission.load(): player spawned at " + MapManager.playerSpawn);
// COMPAGNON Kubrow (feedback utilisateur) : à côté du joueur.
GameObject.instantiate(PrefabManager.loadPrefab("kubrow"),
MapManager.playerSpawn.offset(-200, -100));
instantiateCamera(player);
instantiateMenus();

View File

@ -1,47 +1,12 @@
package com.ezardlabs.lostsector.objects;
import com.ezardlabs.dethsquare.Collider;
import com.ezardlabs.dethsquare.GameObject;
import com.ezardlabs.dethsquare.Input.KeyCode;
import com.ezardlabs.dethsquare.Time;
import com.ezardlabs.dethsquare.TextureAtlas;
import com.ezardlabs.dethsquare.Vector2;
import com.ezardlabs.dethsquare.animation.Animations;
import com.ezardlabs.dethsquare.animation.Animations.Validator;
import com.ezardlabs.dethsquare.util.GameLog;
import com.ezardlabs.lostsector.Game.DamageType;
import com.ezardlabs.lostsector.objects.enemies.Enemy;
/*
* COMPAGNON Kubrow (feedback utilisateur : "Kubrow/sentinel AI" de la
* roadmap Trello — le DamageType.KUBROW existait déjà dans Game.java, les
* équipes d'origine l'avaient prévu).
*
* IA simple de compagnon :
* - suit le joueur (course si loin > 350 px, idle si proche) ;
* - téléportation derrière le joueur s'il se perd (> 1500 px, puits,
* changements de niveau) ;
* - attaque l'ennemi le plus proche au corps à corps (dégâts 1, cooldown
* 1 s) avec le type de dégâts KUBROW prévu par les équipes d'origine.
*
* Assets : RÉUTILISATION des sprites 2017 (data/kubrows/white — le chemin
* images/kubrows de la classe dormante était périmé depuis la fusion des
* dossiers de 2017). AUCUNE nouvelle texture (directive AGENTS.md).
*
* Spawn : DefenseMission.load / ExterminateMission.load (à côté du joueur).
* Périmètre : le Kubrow ne prend pas part au multi (pas de composants
* Network*).
*/
public class Kubrow extends Entity {
private static final String TAG = "LS-GAMEPLAY";
private static final float FOLLOW_DISTANCE = 350f;
private static final float LOSE_DISTANCE = 1500f;
private static final float ATTACK_RANGE = 220f;
private static final float MOVE_SPEED = 10f;
private static final long ATTACK_COOLDOWN_MS = 1000;
private GameObject player;
private long nextAttack = 0;
private float facing = 1;
public Kubrow() {
super(5);
@ -49,99 +14,264 @@ public class Kubrow extends Entity {
@Override
public void start() {
gameObject.setTag("kubrow");
// Chemin CORRIGÉ : la classe dormante 2017 pointait vers
// images/kubrows (dossier fusionné en data/ par la tâche Trello
// "Merge image and animation directory structure").
com.ezardlabs.dethsquare.TextureAtlas ta =
com.ezardlabs.dethsquare.TextureAtlas.load("data/kubrows/white/atlas.png",
"data/kubrows/white/atlas.txt");
TextureAtlas ta = TextureAtlas.load("images/kubrows/white/atlas.png", "images/kubrows/white/atlas.txt");
gameObject.renderer.setTextureAtlas(ta, 200, 200);
gameObject.animator.setAnimations(Animations.load("data/kubrows", ta,
new Validator("idle", "run", "jump", "attack")));
gameObject.animator.play("idle");
GameLog.i(TAG, "Kubrow spawn (5 PV, compagnon du joueur)");
gameObject.animator.setAnimations(Animations.load("animations/kubrow", ta, new Validator("idle", "run",
"jump", "attack")));
}
// private float speed = 10;
// public boolean attacking = false;
// TargetType targetType = TargetType.PLAYER;
// Vector2 target;
//
// enum TargetType {
// PLAYER,
// ENEMY
// }
//
// public Kubrow() {
// super(3);
// }
//
// @Override
// public void start() {
// TextureAtlas ta = TextureAtlas.load("images/kubrows/white/atlas.png", "images/kubrows/white/atlas.txt");
// gameObject.renderer.setTextureAtlas(ta, 200, 200);
// gameObject.animator.setAnimations(new Animation("idle", TextureAtlas.load.Sprite[]{ta.getSprite("idle0")}, AnimationType.ONE_SHOT, Long.MAX_VALUE), new Animation("run",
// TextureAtlas.load.Sprite[]{ta.getSprite("run0"),
// ta.getSprite("run1"),
// ta.getSprite("run2"),
// ta.getSprite("run3"),
// ta.getSprite("run4"),
// ta.getSprite("run5"),
// ta.getSprite("run6")},
// AnimationType.LOOP, 100), new Animation("attack",
// TextureAtlas.load.Sprite[]{ta.getSprite("attack0"),
// ta.getSprite("attack1"),
// ta.getSprite("attack2"),
// ta.getSprite("attack3"),
// ta.getSprite("attack4"),
// ta.getSprite("attack5"),
// ta.getSprite("attack6"),
// ta.getSprite("attack7"),
// ta.getSprite("attack8"),
// ta.getSprite("attack9"),
// ta.getSprite("attack10"),
// ta.getSprite("attack11")},
// AnimationType.ONE_SHOT, 100, new Animation.AnimationListener() {
// @Override
// public void onAnimatedStarted(Animator animator) {
//
// }
//
// @Override
// public void onFrame(Animator animator, int frameNum) {
//
// }
//
// @Override
// public void onAnimationFinished(Animator animator) {
// //noinspection ConstantConditions
// attacking = false;
// }
// }), new Animation("jump", TextureAtlas.load.Sprite[]{ta.getSprite("jump0"),
// ta.getSprite("jump1"),
// ta.getSprite("jump2")}, AnimationType.ONE_SHOT, 100), new Animation("fall", TextureAtlas.load.Sprite[]{ta.getSprite("fall0")}, AnimationType.ONE_SHOT, 100));
// gameObject.animator.play("idle");
//
// }
// @Override
// public void update() {
// int x = 0;
// if (gameObject.rigidbody.gravity == 0) {
// if (target == null || transform.position.x == target.x) {
// NavMesh.NavPoint[] path = NavMesh.getPath(transform, Game.players[0].transform);
// if (path != null && path.length > 0) {
// int pathIndex = 0;
// if (path.length > 1 && path[0] != null && transform.position.x == path[0].position.x)
// pathIndex = 1;
// target = path[pathIndex].position;
// }
// }
// if (target != null) {
// if (target.x < transform.position.x) {
// x = -10;
// gameObject.renderer.hFlipped = true;
// } else if (target.x > transform.position.x) {
// x = 10;
// gameObject.renderer.hFlipped = false;
// }
// }
// transform.translate(x, 0);
// if (x == 0) {
// gameObject.animator.play("idle");
// } else {
// gameObject.animator.play("run");
// }
// }
// if (attacking) return;
//
// float x = 0;
//
// double minDistance = 1000;
// GameObject best = null;
// double temp;
// for (GameObject go : GameObject.findAllWithTag("enemy")) {
// if ((temp = Vector2.distance(transform.position, go.transform.position)) < minDistance) {
// minDistance = temp;
// best = go;
// }
// }
// if (best == null) {
// targetType = TargetType.PLAYER;
// } else {
// targetType = TargetType.ENEMY;
// }
// if (gameObject.rigidbody.gravity == 0) {
// NavMesh.NavPoint[] path = null;
// switch (targetType) {
// case PLAYER:
// path = NavMesh.getPath(transform, Game.players[0].transform);
// break;
// case ENEMY:
// path = NavMesh.getPath(transform, best.transform);
// break;
// }
// if (path != null && path.length > 0) {
// int pathIndex = 0;
// if (path.length > 1 && path[0] != null && transform.position.x == path[0].position.x)
// pathIndex = 1;
// target = path[pathIndex].position;
// }
// if (target != null) {
// if (target.x < transform.position.x) {
// x = -10;
// gameObject.renderer.hFlipped = true;
// } else if (target.x > transform.position.x) {
// x = 10;
// gameObject.renderer.hFlipped = false;
// }
// }
// transform.translate(x, 0);
// if (x == 0) {
// gameObject.animator.play("idle");
// } else {
// gameObject.animator.play("run");
// }
// }
// if (best == null) {
// if (gameObject.rigidbody.gravity == 0) {
// NavMesh.NavPoint[] path = NavMesh.getPath(transform, Game.players[0].transform);
// if (path != null && path.length > 1) {
// int pathIndex = 0;
// if (path.length > 1 && path[0] != null && transform.position.x == path[0].position.x)
// pathIndex = 1;
// if (path[pathIndex].position.x < transform.position.x) {
// x = -speed;
// gameObject.renderer.hFlipped = true;
// } else if (path[pathIndex].position.x > transform.position.x) {
// x = speed;
// gameObject.renderer.hFlipped = false;
// }
// }
// }
// } else {
// if (gameObject.rigidbody.gravity == 0) {
// if (best.transform.position.x - transform.position.x <= 106.25f) { // 125
// transform.position.x = best.transform.position.x - 106.25f;
// gameObject.animator.play("attack");
// attacking = true;
// //noinspection ConstantConditions
// ((Enemy) best.getComponentOfType(Enemy.class)).kubrowAttack(transform.position);
// return;
// } else {
// NavMesh.NavPoint[] path = NavMesh.getPath(transform, best.transform);
// if (path != null && path.length > 0) {
// int pathIndex = 0;
// if (path.length > 1 && path[0] != null && transform.position.x == path[0].position.x)
// pathIndex = 1;
// if (path[pathIndex].position.x < transform.position.x) {
// x = -speed;
// gameObject.renderer.hFlipped = true;
// } else if (path[pathIndex].position.x > transform.position.x) {
// x = speed;
// gameObject.renderer.hFlipped = false;
// }
// }
// }
// }
// }
//
// transform.translate(x, 0);
// if (x == 0) {
// gameObject.animator.play("idle");
// } else {
// gameObject.animator.play("run");
// }
// }
// @Override
// public void update() {
// int x = 0;
// if (gameObject.rigidbody.velocity.y == 0) {
// if (target == null || transform.position.x == target.x) {
// NavMesh.NavPoint[] path = NavMesh.getPath(transform, Game.players[0].transform);
// if (path != null && path.length > 0) {
// int pathIndex = 0;
// if (path.length > 1 && path[0] != null && transform.position.x == path[0].position.x)
// pathIndex = 1;
// target = path[pathIndex].position;
// }
// }
// if (target != null) {
// if (target.x < transform.position.x) {
// gameObject.transform.scale.x = -1;
// } else if (target.x > transform.position.x) {
// gameObject.transform.scale.x = 1;
// }
// if (target.y < transform.position.y) {
// if (gameObject.rigidbody.velocity.y >= 0) {
// switch ((int) (transform.position.y - target.y)) {
// case 50:
// gameObject.rigidbody.velocity.y = -15f;
// break;
// case 100:
// gameObject.rigidbody.velocity.y = -25f;
// break;
// case 150:
// gameObject.rigidbody.velocity.y = -27f;
// break;
// case 200:
// gameObject.rigidbody.velocity.y = -30f;
// break;
// default:
// break;
// }
// }
// } else {
// if (target.x < transform.position.x) {
// x = -10;
// } else if (target.x > transform.position.x) {
// x = 10;
// }
// }
// }
// }
// transform.translate(x, 0);
// if (x == 0) {
// gameObject.animator.play("idle");
// } else {
// gameObject.animator.play("run");
// }
// }
@Override
public void die(DamageType damageType, Vector2 attackOrigin) {
// Le compagnon meurt comme un ennemi (tag enemy_dead pour les
// listeners, CorpseFader possible côté mission) mais NE COMPTE PAS
// dans les kills de mission (pas de notifyEnemyDeath).
gameObject.setTag("enemy_dead");
GameLog.i(TAG, "Kubrow mort (" + damageType + ")");
GameObject.destroy(gameObject, 1000);
}
@Override
public void update() {
// Le joueur : re-trouvé à chaque mort/rechargement.
if (player == null || !player.isActive()) {
GameObject[] players = GameObject.findAllWithTag("player");
player = players.length > 0 ? players[0] : null;
if (player == null) {
gameObject.animator.play("idle");
return;
}
}
Vector2 myPos = transform.position;
Vector2 playerPos = player.transform.position;
float dx = playerPos.x - myPos.x;
float dy = playerPos.y - myPos.y;
float dist = (float) Math.sqrt(dx * dx + dy * dy);
// Perdu (puits, téléport du joueur...) : se téléporter près du joueur.
if (dist > LOSE_DISTANCE) {
transform.position.set(playerPos.x + 100, playerPos.y);
gameObject.rigidbody.velocity.set(0, 0);
GameLog.d(TAG, "Kubrow : téléporté près du joueur");
return;
}
// Ennemi le plus proche (portée d'attaque : 220 px).
GameObject nearestEnemy = null;
float bestDistSq = ATTACK_RANGE * ATTACK_RANGE;
for (GameObject e : GameObject.findAllWithTag("enemy")) {
if (!e.isActive()) continue;
float ex = e.transform.position.x - myPos.x;
float ey = e.transform.position.y - myPos.y;
float dSq = ex * ex + ey * ey;
if (dSq < bestDistSq) {
bestDistSq = dSq;
nearestEnemy = e;
}
}
if (nearestEnemy != null) {
// Attaque au contact : dégâts KUBROW (prévus par les équipes
// d'origine), cooldown 1 s pour un DPS raisonnable.
Enemy enemy = nearestEnemy.getComponentOfType(Enemy.class);
if (enemy != null && System.currentTimeMillis() >= nextAttack) {
enemy.applyDamage(1, DamageType.KUBROW, myPos);
nextAttack = System.currentTimeMillis() + ATTACK_COOLDOWN_MS;
facing = nearestEnemy.transform.position.x > myPos.x ? 1 : -1;
transform.scale.x = facing;
gameObject.animator.play("attack");
GameLog.d(TAG, "Kubrow : attaque " + nearestEnemy.name + " (-1 PV)");
}
return;
}
// Suivi du joueur : course si loin, idle si proche.
if (dist > FOLLOW_DISTANCE) {
facing = dx > 0 ? 1 : -1;
transform.scale.x = facing;
gameObject.rigidbody.velocity.x = 0;
transform.translate(MOVE_SPEED * facing * Time.fpsScaling60, 0);
gameObject.animator.play("run");
} else if (Math.abs(dy) < 100 && Math.abs(dx) < FOLLOW_DISTANCE) {
gameObject.animator.play("idle");
} else if (dy < -100) {
// Joueur plus haut : saut (anim jump, impulsion cohérente avec la
// hauteur manquante).
gameObject.rigidbody.velocity.y = -20f;
gameObject.animator.play("jump");
}
protected void die(DamageType damageType, Vector2 attackOrigin) {
}
}