Mission Exterminate jouable + pouvoirs tactiles + fix QuadTree majeur

- QuadTree.build : bounds cassés d'origine (right comparé à left, bottom jamais
  affecté) -> tout collider/renderer hors du rectangle mal calculé était perdu
  au split : chute libre à travers les cartes procédurales (la Défense ne
  marchait que par accident)
- ExterminateMission : code mort 2017 rendu jouable (ExterminateLevel, spawn
  SINGLE exact via SpawnPoint, spawn repositionné sur la carte procédurale,
  SmartCamera à la place de CameraMovement cassé hors scale=1, texte de
  mission recréé après destroyAll, entrée Exterminate au menu principal)
- TouchControls : boutons de pouvoirs 1-4 (ALPHA_1..4, coûts desktop)
- GraphicsEngine : culling dynamique (TODO 2017, exception couche GUI),
  rendu séquentiel (GC mobile), stat LS-RENDER throttlée
- AudioSource : setLoop AVANT play ; AndroidAudioUtils : bascule MediaPlayer
  si boucle demandée après un play SoundPool
- AndroidRenderUtils : normalisation des chemins ../ (tilesets TMX)
- Player.onCollision : quake tolérant à CameraMovement ou SmartCamera
- Physics.MAX_MOVEMENT déplacé depuis Rigidbody (TODO amont)
- Discipline AGENTS.md : vérification visuelle du rendu obligatoire à chaque test
This commit is contained in:
Siphonight 2026-11-15 14:37:03 +01:00
parent 00cc6ee471
commit f17fe91879
16 changed files with 271 additions and 56 deletions

View File

@ -6,6 +6,37 @@ lignée du jeu amont (0.2.2 en 2017, abandonné).
## [Non publié] ## [Non publié]
### Ajouté
- Mission **Exterminate** jouable : le code de mission mort depuis 2017 est
rattaché à un niveau (`ExterminateLevel`, 15 ennemis), le spawn est forcé
"ni plus ni moins" via `SpawnPoint` SINGLE (TODO amont résolu), spawn posé
sur la carte procédurale, entrée **Exterminate** dans le menu principal
- HUD tactile : **boutons de pouvoirs 1-4** (colonne gauche) — injectent
ALPHA_1..4, coûts d'énergie identiques au desktop
- Stat de rendu throttlée `LS-RENDER: visible=N/M cam=... scale=...`
(diagnostic écran noir)
### Corrigé
- **`QuadTree.build`** : calcul des bounds cassé d'origine (`right` comparé à
`left`, `bottom` jamais affecté, étirement carré de secours) — tout objet
hors du rectangle mal calculé était perdu au split : sur les cartes
procédurales (colliders à y≈25600), le joueur traversait toute la carte en
chute libre. La Défense ne marchait que par accident (ordre de création +
élargissement carré)
- `CameraMovement` raisonnait en monde non-échelle (ne marchait qu'avec la
fenêtre 1920x1080 du desktop 2017) — ExterminateMission passe à SmartCamera
- `Player.onCollision` : quake d'atterrissage supposait un `SmartCamera` (NPE
sur les niveaux à `CameraMovement`)
- Culling du rendu (TODO 2017 "only add renderers that are visible") avec
exception de la couche GUI (coordonnées écran) ; rendu séquentiel au lieu
de `parallelStream` (pression GC mobile)
- Boucle audio : `AudioSource` appelle désormais `setLoop` AVANT `play` ;
le back-end Android bascule en `MediaPlayer` si la boucle est demandée
après un play SoundPool
- Normalisation des chemins `../` dans le chargement d'images Android
(tilesets des TMX procéduraux)
- `Rigidbody.MAX_MOVEMENT` déplacé dans `Physics` (TODO amont)
## [0.3.0] — 2026-11-15 ## [0.3.0] — 2026-11-15
Première publication du portage 2026. Le jeu, abandonné en 2017 sur Première publication du portage 2026. Le jeu, abandonné en 2017 sur

View File

@ -124,6 +124,9 @@ Points d'ancrage du portage (patch → cible) :
| `destroyAll()` purge `tags` | `core/GameObject` | fuite d'état inter-niveaux (cryopods fantômes) | | `destroyAll()` purge `tags` | `core/GameObject` | fuite d'état inter-niveaux (cryopods fantômes) |
| `DefenseMission.load()` recrée `director` | jeu | crash au 2ᵉ chargement de mission (bug upstream) | | `DefenseMission.load()` recrée `director` | jeu | crash au 2ᵉ chargement de mission (bug upstream) |
| Avalanche réactivé (état CASTING enregistré, animations renommées) | `Player`, `Frost`, `Avalanche` | 4ᵉ pouvoir jouable (3 chantiers 2017 terminés) | | Avalanche réactivé (état CASTING enregistré, animations renommées) | `Player`, `Frost`, `Avalanche` | 4ᵉ pouvoir jouable (3 chantiers 2017 terminés) |
| `QuadTree.build` bounds | `core/QuadTree` | collisions/rendu des cartes procédurales (chute libre à travers la carte) |
| Mission Exterminate + niveau + menu | `ExterminateMission`, `ExterminateLevel`, `MainMenu` | code mort 2017 rendu jouable (spawn SINGLE exact) |
| Boutons de pouvoirs tactiles | `TouchControls` | pouvoirs 1-4 jouables sur Android |
| HUD tactile | `lost-sector/.../hud/TouchControls` | Android uniquement (attaché en 1ᵉʳ de chaque niveau) | | HUD tactile | `lost-sector/.../hud/TouchControls` | Android uniquement (attaché en 1ᵉʳ de chaque niveau) |
## Maintenance ## Maintenance

17
TODO.md
View File

@ -112,12 +112,21 @@ reste du portage Android.
et le tester — FAIT (v0.3.0) : état CASTING enregistré, animation et le tester — FAIT (v0.3.0) : état CASTING enregistré, animation
"cast" jouée par l'état, effet Avalanche renommé vers les vraies "cast" jouée par l'état, effet Avalanche renommé vers les vraies
animations ; test in-game complet restant sur desktop réel animations ; test in-game complet restant sur desktop réel
- [ ] `ExterminateMission.java:32` : forcer le nombre d'ennemis - [x] `ExterminateMission.java:32` : forcer le nombre d'ennemis — FAIT :
- [ ] `Rigidbody.java:4` : déplacer `MAX_MOVEMENT` dans `Physics` SpawnPoint SINGLE + niveau `ExterminateLevel` + entrée menu (le code
- [ ] `PumpkinDeraCrewman` : ajuster le collider citrouille (TODO d'origine) était mort depuis 2017, rattaché à aucun niveau)
- [ ] `GraphicsEngine.java:82` : culling réel des renderers invisibles - [x] `Rigidbody.java:4` : déplacer `MAX_MOVEMENT` dans `Physics` — FAIT
- [x] `GraphicsEngine.java:82` : culling réel des renderers invisibles — FAIT
(exception couche GUI, rendu séquentiel)
- [ ] `PumpkinDeraCrewman` : TODO inaccessible — le fichier est ENTIÈREMENT
commenté (code mort gélé en 2016, jamais compilé, jamais enregistré
comme prefab). Décision : ne pas patcher du code mort ; ressusciter
l'ennemi seulement si les ennemis Halloween reviennent à l'ordre du jour
- [ ] Squelette d'une 2ᵉ Warframe (classe `Warframe` générique prête) — - [ ] Squelette d'une 2ᵉ Warframe (classe `Warframe` générique prête) —
nécessite des assets (sprites/anim JSON) : blocage artistique nécessite des assets (sprites/anim JSON) : blocage artistique
- [ ] `CameraMovement` : classe cassée avec `Screen.scale != 1` (monde
non-échelle) — contournée (SmartCamera partout) ; à corriger ou
supprimer si plus aucun usage
## 7. Décisions à prendre ## 7. Décisions à prendre

View File

@ -146,6 +146,16 @@ public class AndroidAudioUtils implements AudioUtils {
public void setLoop(int id, boolean loop) { public void setLoop(int id, boolean loop) {
looping.put(id, loop); looping.put(id, loop);
pendingLoops.put(id, loop); pendingLoops.put(id, loop);
/*
* setLoop APRÈS un play() déjà parti en SoundPool (ordre historique de
* AudioSource.start) : basculer sur MediaPlayer, SoundPool ne sait pas
* boucler un stream déjà déclenché.
*/
if (loop && activeStreams.containsKey(id)) {
Integer stream = activeStreams.remove(id);
if (stream != null) soundPool.stop(stream);
play(id); // repart en MediaPlayer grâce au flag looping qui précède
}
} }
@Override @Override

View File

@ -137,9 +137,23 @@ public class AndroidRenderUtils implements RenderUtils {
int[] returnVals = new int[3]; int[] returnVals = new int[3];
InputStream in = IO.getInputStream(path); /*
* Normalisation du chemin (comme le back-end desktop) : les TMX
* procéduraux référencent leurs tilesets avec des chemins relatifs
* ("../corpus_tileset.png") — AssetManager ne résout pas les "..",
* il faut les aplatir avant assets.open().
*/
String normalisedPath;
try {
normalisedPath = new java.net.URI(path).normalize().getPath();
} catch (java.net.URISyntaxException e) {
e.printStackTrace();
normalisedPath = path;
}
InputStream in = IO.getInputStream(normalisedPath);
if (in == null) { if (in == null) {
throw new ImageNotFoundError(path); throw new ImageNotFoundError(normalisedPath);
} }
try { try {

View File

@ -62,8 +62,15 @@ public final class AudioSource extends Script {
public void start() { public void start() {
if (initial != null) { if (initial != null) {
current = initial.id; current = initial.id;
play(); /*
* setLoop AVANT play() : le back-end Android construit son lecteur
* de boucle (MediaPlayer) au moment du play — l'ordre historique
* (play puis setLoop, AudioSource.java 2017) faisait démarrer la
* musique une fois sans jamais la répéter. setLoop avant un id
* jamais joué est inoffensif sur tous les back-ends.
*/
setLoop(loop); setLoop(loop);
play();
setVolume(volume); setVolume(volume);
} }
AudioManager.addAudioSource(this); AudioManager.addAudioSource(this);

View File

@ -7,6 +7,17 @@ import java.util.stream.Stream;
public class Physics { public class Physics {
/**
* Déplacement maximal d'un Rigidbody en une seule étape de simulation, en
* unités monde : au-delà, le mouvement est découpé en itérations (voir
* Rigidbody.update) pour éviter que les collisions ne "tunnelisent" à
* travers les colliders fins lors des grosses vitesses / chutes de FPS.
*
* Déplacé ici depuis Rigidbody (TODO 2017 résolu) : c'est une constante de
* PHYSIQUE de simulation, pas un détail du composant.
*/
public static final float MAX_MOVEMENT = 50f;
public static RaycastHit raycast(Vector2 origin, Vector2 direction, float distance, int layerMask) { public static RaycastHit raycast(Vector2 origin, Vector2 direction, float distance, int layerMask) {
direction.normalise(); direction.normalise();
Vector2 end = new Vector2(origin.x + direction.x * distance, origin.y + direction.y * distance); Vector2 end = new Vector2(origin.x + direction.x * distance, origin.y + direction.y * distance);

View File

@ -25,31 +25,35 @@ public final class QuadTree<T extends Bounded> {
} }
public void build(List<T> objects) { public void build(List<T> objects) {
float left = 0; /*
float top = 0; * Calcul des bounds : le code d'origine était cassé — `right` était
float right = 0; * comparé à `b.left` (au lieu de b.right) et `bottom` n'était jamais
float bottom = 0; * affecté correctement (condition dupliquée sur `left > right`), avec
* un étirement carré en secours qui masquait le problème.
*
* Conséquence : tout objet dont les bounds sortaient du rectangle mal
* calculé était silencieusement PERDU au split (le redistribute ne
* garde que les objets contenus par un nœud enfant) — sur les cartes
* procédurales (colliders à y≈25600), le QuadTree couvrait (0..1600,
* 0..1600) et le joueur traversait toute la carte en chute libre. La
* Défense ne "marchait" que par accident (ordre de création des
* colliders + élargissement carré couvrant la carte).
*/
float left = Float.MAX_VALUE;
float top = Float.MAX_VALUE;
float right = -Float.MAX_VALUE;
float bottom = -Float.MAX_VALUE;
for (Bounded b : objects) { for (Bounded b : objects) {
if (b.getBounds().left < left) { RectF r = b.getBounds();
left = b.getBounds().left; if (r.left < left) left = r.left;
if (r.right > right) right = r.right;
if (r.top < top) top = r.top;
if (r.bottom > bottom) bottom = r.bottom;
} }
if (b.getBounds().left > right) { if (left > right) { // liste vide : bounds neutres
right = b.getBounds().right; left = top = right = bottom = 0;
}
if (b.getBounds().top < top) {
top = b.getBounds().top;
}
if (b.getBounds().left > right) {
bottom = b.getBounds().bottom;
}
}
float width = right - left;
float height = bottom - top;
if (width > height) {
bounds.set(left, top, left + width, top + width);
} else if (top > left) {
bounds.set(left, top, left + height, top + height);
} }
bounds.set(left, top, right, bottom);
for (T b : objects) { for (T b : objects) {
if (b.getGameObject() == null || b.getGameObject().isStatic) { if (b.getGameObject() == null || b.getGameObject().isStatic) {
insert(b); insert(b);

View File

@ -1,7 +1,6 @@
package com.ezardlabs.dethsquare; package com.ezardlabs.dethsquare;
public final class Rigidbody extends Script { public final class Rigidbody extends Script {
private static final float MAX_MOVEMENT = 50; // TODO move into Collider/Physics
public Vector2 velocity = new Vector2(0, 0.9375f); public Vector2 velocity = new Vector2(0, 0.9375f);
public float gravity = 1.25f; public float gravity = 1.25f;
@ -15,21 +14,21 @@ public final class Rigidbody extends Script {
float y = velocity.y * Time.fpsScaling60; float y = velocity.y * Time.fpsScaling60;
float xAbs = Math.abs(velocity.x * Time.fpsScaling60); float xAbs = Math.abs(velocity.x * Time.fpsScaling60);
float yAbs = Math.abs(velocity.y * Time.fpsScaling60); float yAbs = Math.abs(velocity.y * Time.fpsScaling60);
if (xAbs > yAbs && xAbs > MAX_MOVEMENT) { if (xAbs > yAbs && xAbs > Physics.MAX_MOVEMENT) {
int iterations = (int) (x / MAX_MOVEMENT); int iterations = (int) (x / Physics.MAX_MOVEMENT);
float ratio = MAX_MOVEMENT / x; float ratio = Physics.MAX_MOVEMENT / x;
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
transform.translate(x * ratio, y * ratio); transform.translate(x * ratio, y * ratio);
} }
ratio = (x % MAX_MOVEMENT) / x; ratio = (x % Physics.MAX_MOVEMENT) / x;
transform.translate(x * ratio, y * ratio); transform.translate(x * ratio, y * ratio);
} else if (yAbs > xAbs && yAbs > MAX_MOVEMENT) { } else if (yAbs > xAbs && yAbs > Physics.MAX_MOVEMENT) {
int iterations = (int) (y / MAX_MOVEMENT); int iterations = (int) (y / Physics.MAX_MOVEMENT);
float ratio = MAX_MOVEMENT / y; float ratio = Physics.MAX_MOVEMENT / y;
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
transform.translate(x * ratio, y * ratio); transform.translate(x * ratio, y * ratio);
} }
ratio = (y % MAX_MOVEMENT) / y; ratio = (y % Physics.MAX_MOVEMENT) / y;
transform.translate(x * ratio, y * ratio); transform.translate(x * ratio, y * ratio);
} else { } else {
transform.translate(x, y); transform.translate(x, y);

View File

@ -3,7 +3,9 @@ package com.ezardlabs.dethsquare.graphics;
import com.ezardlabs.dethsquare.Camera; import com.ezardlabs.dethsquare.Camera;
import com.ezardlabs.dethsquare.QuadTree; import com.ezardlabs.dethsquare.QuadTree;
import com.ezardlabs.dethsquare.RectF; import com.ezardlabs.dethsquare.RectF;
import com.ezardlabs.dethsquare.Screen;
import com.ezardlabs.dethsquare.util.GameListeners; import com.ezardlabs.dethsquare.util.GameListeners;
import com.ezardlabs.dethsquare.util.GameLog;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -18,7 +20,9 @@ public class GraphicsEngine {
GameListeners.addRenderListener(GraphicsEngine::render); GameListeners.addRenderListener(GraphicsEngine::render);
} }
private static final ArrayList<Renderer> renderers = new ArrayList<>(); private static final byte GUI_LAYER = 2;
private static final ArrayList<Renderer> renderers = new ArrayList<>();
private static final QuadTree<Renderer> qt = new QuadTree<>(30); private static final QuadTree<Renderer> qt = new QuadTree<>(30);
private static float[] vertices = new float[0]; private static float[] vertices = new float[0];
@ -79,13 +83,43 @@ public class GraphicsEngine {
visible.clear(); visible.clear();
qt.retrieve(visible, Camera.main); qt.retrieve(visible, Camera.main);
visible.addAll(renderers); // TODO only add renderers that are visible /*
* Culling des renderers dynamiques (TODO 2017 résolu : "only add
* renderers that are visible") : test d'intersection avec les bounds
* de la caméra. Les renderers GUI sont EXCUS : leurs bounds sont en
* coordonnées écran (position indépendante de la caméra), le test
* monde les ferait disparaître dès que la caméra s'éloigne de
* l'origine. Les statiques sont déjà filtrés par le QuadTree.
*/
RectF cameraBounds = Camera.main == null ? null : Camera.main.getBounds();
for (Renderer renderer : renderers) {
if (cameraBounds == null || renderer.getLayer() == GUI_LAYER
|| RectF.intersects(cameraBounds, renderer.getBounds())) {
visible.add(renderer);
}
}
render(visible); render(visible);
// Stat throttlé (1 ligne / 5 s à 60 fps) : indispensable pour
// diagnostiquer un écran noir (culling, caméra, échelle).
frameCount++;
if (frameCount % 300 == 0) {
RectF cb = cameraBounds;
RectF first = visible.isEmpty() ? null : visible.get(0).getBounds();
GameLog.i("LS-RENDER", "visible=" + visible.size() + "/" + (renderers.size() + 1)
+ " cam=" + (cb == null ? "null" : cb.left + "," + cb.top + " .. " + cb.right + "," + cb.bottom)
+ " scale=" + Screen.scale + " screen=" + Screen.width + "x" + Screen.height
+ " sample=" + (first == null ? "none" : first.left + "," + first.top));
}
} }
private static long frameCount = 0;
private static void render(ArrayList<Renderer> renderers) { private static void render(ArrayList<Renderer> renderers) {
renderers.parallelStream() // Séquentiel : le parallelStream d'origine générait de la pression GC à
// chaque frame (flagrant sur mobile — TODO perf Android) pour un
// groupement qui reste de toute façon consommé sur le thread appelant.
renderers.stream()
.filter(renderer -> renderer.enabled && renderer.gameObject.isActive()) .filter(renderer -> renderer.enabled && renderer.gameObject.isActive())
.collect(Collectors.groupingBy(Renderer::getKey, TreeMap::new, Collectors.toList())) .collect(Collectors.groupingBy(Renderer::getKey, TreeMap::new, Collectors.toList()))
.forEach((key, renderersList) -> { .forEach((key, renderersList) -> {

View File

@ -18,6 +18,7 @@ import com.ezardlabs.dethsquare.multiplayer.NetworkTransform;
import com.ezardlabs.dethsquare.prefabs.PrefabManager; import com.ezardlabs.dethsquare.prefabs.PrefabManager;
import com.ezardlabs.dethsquare.util.BaseGame; import com.ezardlabs.dethsquare.util.BaseGame;
import com.ezardlabs.lostsector.levels.DefenseLevel; import com.ezardlabs.lostsector.levels.DefenseLevel;
import com.ezardlabs.lostsector.levels.ExterminateLevel;
import com.ezardlabs.lostsector.levels.ExploreLevel; import com.ezardlabs.lostsector.levels.ExploreLevel;
import com.ezardlabs.lostsector.levels.MainMenuLevel; import com.ezardlabs.lostsector.levels.MainMenuLevel;
import com.ezardlabs.lostsector.levels.MultiplayerLevel; import com.ezardlabs.lostsector.levels.MultiplayerLevel;
@ -57,6 +58,7 @@ public class Game extends BaseGame {
LevelManager.registerLevel("survival", new SurvivalLevel()); LevelManager.registerLevel("survival", new SurvivalLevel());
LevelManager.registerLevel("procedural", new ProceduralLevel()); LevelManager.registerLevel("procedural", new ProceduralLevel());
LevelManager.registerLevel("defense", new DefenseLevel()); LevelManager.registerLevel("defense", new DefenseLevel());
LevelManager.registerLevel("exterminate", new ExterminateLevel());
LevelManager.registerLevel("multiplayer_lobby", new MultiplayerLobbyLevel()); LevelManager.registerLevel("multiplayer_lobby", new MultiplayerLobbyLevel());
LevelManager.registerLevel("multiplayer", new MultiplayerLevel()); LevelManager.registerLevel("multiplayer", new MultiplayerLevel());
LevelManager.registerLevel("main_menu", new MainMenuLevel()); LevelManager.registerLevel("main_menu", new MainMenuLevel());

View File

@ -0,0 +1,18 @@
package com.ezardlabs.lostsector.levels;
import com.ezardlabs.lostsector.missions.ExterminateMission;
import com.ezardlabs.lostsector.missions.Mission;
import com.ezardlabs.lostsector.objects.hud.TouchControls;
/*
* Niveau mission Exterminate : carte procédurale Corpus, exactement
* numEnemiesToKill ennemis sur les points de spawn (SpawnPoint SINGLE),
* objectif = tous les éliminer (TODO 2017 résolu, le code de mission existed
* mais n'était rattaché à AUCUN niveau — mort depuis l'origine).
*/
public class ExterminateLevel extends MissionLevel<ExterminateMission> {
public ExterminateLevel() {
super(new ExterminateMission(15));
}
}

View File

@ -1,19 +1,23 @@
package com.ezardlabs.lostsector.missions; package com.ezardlabs.lostsector.missions;
import com.ezardlabs.dethsquare.AudioListener;
import com.ezardlabs.dethsquare.AudioSource; import com.ezardlabs.dethsquare.AudioSource;
import com.ezardlabs.dethsquare.AudioSource.AudioClip; import com.ezardlabs.dethsquare.AudioSource.AudioClip;
import com.ezardlabs.dethsquare.AudioManager.AudioGroup;
import com.ezardlabs.dethsquare.Camera; import com.ezardlabs.dethsquare.Camera;
import com.ezardlabs.dethsquare.GameObject; import com.ezardlabs.dethsquare.GameObject;
import com.ezardlabs.dethsquare.GuiText; import com.ezardlabs.dethsquare.GuiText;
import com.ezardlabs.dethsquare.TextureAtlas; import com.ezardlabs.dethsquare.TextureAtlas;
import com.ezardlabs.dethsquare.Vector2; import com.ezardlabs.dethsquare.Vector2;
import com.ezardlabs.dethsquare.prefabs.PrefabManager; import com.ezardlabs.dethsquare.prefabs.PrefabManager;
import com.ezardlabs.lostsector.camera.SmartCamera;
import com.ezardlabs.lostsector.map.MapManager; import com.ezardlabs.lostsector.map.MapManager;
import com.ezardlabs.lostsector.map.procedural.MapConfig; import com.ezardlabs.lostsector.map.procedural.MapConfig;
import com.ezardlabs.lostsector.missions.Mission.EnemyStatusListener; import com.ezardlabs.lostsector.missions.Mission.EnemyStatusListener;
import com.ezardlabs.lostsector.objects.CameraMovement;
import com.ezardlabs.lostsector.objects.CameraMovement.FollowType;
import com.ezardlabs.lostsector.objects.enemies.Enemy; import com.ezardlabs.lostsector.objects.enemies.Enemy;
import com.ezardlabs.lostsector.objects.hud.TouchControls;
import java.util.LinkedHashMap;
public class ExterminateMission extends Mission implements EnemyStatusListener { public class ExterminateMission extends Mission implements EnemyStatusListener {
private final int numEnemiesToKill; private final int numEnemiesToKill;
@ -21,28 +25,60 @@ public class ExterminateMission extends Mission implements EnemyStatusListener {
public ExterminateMission(int numEnemiesToKill) { public ExterminateMission(int numEnemiesToKill) {
this.numEnemiesToKill = numEnemiesToKill; this.numEnemiesToKill = numEnemiesToKill;
TextureAtlas ta = TextureAtlas.load("fonts/atlas.png", // NB : PAS de TextureAtlas/GuiText ici — l'atlas chargé au
"fonts/atlas.txt"); // Game.create() (registerLevel) est détruit par le premier
missionText = new GuiText("Enemies remaining: " + numEnemiesToKill, ta, // destroyAll() au changement de niveau ; le texte est recréé dans
40); // load(), après le chargement de la carte.
} }
@Override @Override
public void load() { public void load() {
// TODO force a certain number of enemies to spawn - no more, no less /*
* TODO 2017 résolu ("force a certain number of enemies to spawn - no
* more, no less") : SpawnPoint en mode SINGLE sur les points de spawn
* de la carte procédurale — exactement numEnemiesToKill ennemis, aucun
* de plus. Probabilités calquées sur celles de la Défense.
*/
LinkedHashMap<String, Float> spawnProbabilities = new LinkedHashMap<>();
spawnProbabilities.put("dera_crewman", 0.3f);
spawnProbabilities.put("prova_crewman", 0.5f);
spawnProbabilities.put("supra_crewman", 0.2f);
SpawnPoint.setSingleSpawnMode(numEnemiesToKill, 1000, 5000, spawnProbabilities);
MapManager.playerSpawn = new Vector2(20.0f, 20.0f); MapManager.playerSpawn = new Vector2(20.0f, 20.0f);
MapConfig mapCfg = new MapConfig(MapConfig.ProceduralType.CORPUS, 16); MapConfig mapCfg = new MapConfig(MapConfig.ProceduralType.CORPUS, 16);
MapManager.loadProceduralMap(mapCfg); MapManager.loadProceduralMap(mapCfg);
/*
* Spawn sur le début de la carte procédurale : les segments sont posés
* à partir de PROC_START_POS (en tuiles) — le playerSpawn (20,20)
* historique tombait dans le vide à ~25 600 px du premier segment
* (1 tuile = TILE_SIZE * MAP_SCALE = 100 px). loadProceduralMap ne
* repositionne pas le spawn, on le fait donc ici, APRÈS le chargement.
*/
MapManager.playerSpawn = new Vector2(
MapManager.PROC_START_POS.x * MapManager.TILE_SIZE * MapManager.MAP_SCALE + 100f,
MapManager.PROC_START_POS.y * MapManager.TILE_SIZE * MapManager.MAP_SCALE + 100f);
GameObject player = GameObject GameObject player = GameObject
.instantiate(PrefabManager.loadPrefab("player"), .instantiate(PrefabManager.loadPrefab("player"),
MapManager.playerSpawn); MapManager.playerSpawn);
/*
* SmartCamera (comme Défense/Survival/Procedural) et non
* CameraMovement : ce dernier raisonne en monde NON multiplié par
* Screen.scale alors que le pipeline de rendu dessine à pos*scale —
* la caméra regardait le mauvais endroit dès que scale != 1 (ne
* marchait qu'avec la fenêtre 1920x1080 du desktop 2017).
*/
GameObject.instantiate(new GameObject("Camera", new Camera(true), GameObject.instantiate(new GameObject("Camera", new Camera(true),
new CameraMovement(player.transform, FollowType.SMOOTH), new SmartCamera(player.transform, 1000, new Vector2(100, 100)),
new AudioSource(new AudioClip("audio/theme.ogg"), true)), new AudioListener(),
new AudioSource(new AudioClip("audio/theme.ogg"), true, 1, AudioGroup.MUSIC)),
new Vector2(MapManager.playerSpawn)); new Vector2(MapManager.playerSpawn));
TextureAtlas fontAtlas = TextureAtlas.load("fonts/atlas.png", "fonts/atlas.txt");
missionText = new GuiText("Enemies remaining: " + numEnemiesToKill, fontAtlas, 40);
GameObject.instantiate( GameObject.instantiate(
new GameObject("Mission Progress Text", missionText), new GameObject("Mission Progress Text", missionText),
new Vector2(20, 20)); new Vector2(20, 20));
@ -57,5 +93,10 @@ public class ExterminateMission extends Mission implements EnemyStatusListener {
public void onEnemyKilled(Enemy enemy) { public void onEnemyKilled(Enemy enemy) {
missionText.setText( missionText.setText(
"Enemies remaining: " + (numEnemiesToKill - enemiesKilled)); "Enemies remaining: " + (numEnemiesToKill - enemiesKilled));
// Fin de mission quand le quota est atteint (aucun état de fin de jeu
// dédié en 2017 : completeMission remonte aux listeners de statut).
if (enemiesKilled >= numEnemiesToKill) {
completeMission();
}
} }
} }

View File

@ -15,6 +15,7 @@ import com.ezardlabs.dethsquare.Vector2;
import com.ezardlabs.dethsquare.animation.Animator; import com.ezardlabs.dethsquare.animation.Animator;
import com.ezardlabs.dethsquare.graphics.Renderer; import com.ezardlabs.dethsquare.graphics.Renderer;
import com.ezardlabs.lostsector.camera.SmartCamera; import com.ezardlabs.lostsector.camera.SmartCamera;
import com.ezardlabs.lostsector.objects.CameraMovement;
import com.ezardlabs.lostsector.effects.Dust; import com.ezardlabs.lostsector.effects.Dust;
import com.ezardlabs.lostsector.objects.warframes.Warframe; import com.ezardlabs.lostsector.objects.warframes.Warframe;
import com.ezardlabs.lostsector.objects.weapons.primary.Gorgon; import com.ezardlabs.lostsector.objects.weapons.primary.Gorgon;
@ -259,8 +260,22 @@ public class Player extends Script {
jumpCount = 0; jumpCount = 0;
if (collision.speed > 37) { if (collision.speed > 37) {
stateMachine.setState(State.LANDING); stateMachine.setState(State.LANDING);
/*
* Quake d'atterrissage : le composant caméra dépend du niveau
* (SmartCamera pour la Défense, CameraMovement pour
* l'Exterminate) — le code d'origine supposait SmartCamera et
* NPE dès la première collision sur les autres missions.
*/
SmartCamera smartCamera = Camera.main.gameObject.getComponent(SmartCamera.class);
if (smartCamera != null) {
smartCamera.startQuake(100, 0.3f);
} else {
CameraMovement cameraMovement = Camera.main.gameObject.getComponent(CameraMovement.class);
if (cameraMovement != null) {
cameraMovement.startQuake(100, 0.3f);
}
}
//noinspection ConstantConditions //noinspection ConstantConditions
Camera.main.gameObject.getComponent(SmartCamera.class).startQuake(100, 0.3f);
GameObject.destroy( GameObject.destroy(
GameObject.instantiate(new GameObject("Dust", new Renderer(), new Animator(), new Dust()), GameObject.instantiate(new GameObject("Dust", new Renderer(), new Animator(), new Dust()),
new Vector2(transform.position.x - 262, transform.position.y + 150)), 300); new Vector2(transform.position.x - 262, transform.position.y + 150)), 300);

View File

@ -35,9 +35,10 @@ import com.ezardlabs.dethsquare.Vector2;
* position souris et l'appui MOUSE_LEFT sont à jour quand les menus lisent * position souris et l'appui MOUSE_LEFT sont à jour quand les menus lisent
* Input.mousePosition / getKeyDown(MOUSE_LEFT). * Input.mousePosition / getKeyDown(MOUSE_LEFT).
* *
* Boutons : A / D (déplacement), JUMP (saut + double saut), II (pause = ÉCHAP, * Boutons : A / D (déplacement), JUMP (saut + double saut), 1-4 (pouvoirs de
* ouvre le menu en jeu). Le bouton d'ATTAQUE n'existe pas : toucher n'importe * Frost — injectent ALPHA_1..ALPHA_4, mêmes coûts d'énergie que sur desktop),
* où hors bouton = clic maintenu (mélée), comme sur desktop. * II (pause = ÉCHAP, ouvre le menu en jeu). Le bouton d'ATTAQUE n'existe pas :
* toucher n'importe où hors bouton = clic maintenu (mélée), comme sur desktop.
* *
* Rendu : rectangles translucides (white.png teinté) + labels texte police * Rendu : rectangles translucides (white.png teinté) + labels texte police
* bitmap du jeu. Sprites dédiés à dessiner plus tard (voir TODO.md). * bitmap du jeu. Sprites dédiés à dessiner plus tard (voir TODO.md).
@ -52,6 +53,13 @@ public class TouchControls extends Script {
new Button("D", KeyCode.D, HSide.LEFT, 0.135f, VSide.BOTTOM, 0.035f), new Button("D", KeyCode.D, HSide.LEFT, 0.135f, VSide.BOTTOM, 0.035f),
new Button("JUMP", KeyCode.SPACE, HSide.RIGHT, 0.035f, VSide.BOTTOM, 0.215f), new Button("JUMP", KeyCode.SPACE, HSide.RIGHT, 0.035f, VSide.BOTTOM, 0.215f),
new Button("II", KeyCode.ESCAPE, HSide.LEFT, 0.035f, VSide.TOP, 0.045f), new Button("II", KeyCode.ESCAPE, HSide.LEFT, 0.035f, VSide.TOP, 0.045f),
// Pouvoirs de Frost : colonne gauche entre II (haut) et A/D (bas).
// Coûts d'énergie identiques au desktop (5/10/25/50) — l'injection
// passe par ALPHA_1..4, le code du jeu ne change pas.
new Button("1", KeyCode.ALPHA_1, HSide.LEFT, 0.035f, VSide.BOTTOM, 0.20f, 0.8f),
new Button("2", KeyCode.ALPHA_2, HSide.LEFT, 0.035f, VSide.BOTTOM, 0.35f, 0.8f),
new Button("3", KeyCode.ALPHA_3, HSide.LEFT, 0.035f, VSide.BOTTOM, 0.50f, 0.8f),
new Button("4", KeyCode.ALPHA_4, HSide.LEFT, 0.035f, VSide.BOTTOM, 0.65f, 0.8f),
}; };
private boolean mouseDown = false; private boolean mouseDown = false;
@ -71,23 +79,30 @@ public class TouchControls extends Script {
final VSide vSide; final VSide vSide;
final float offsetX; // fractions de Screen.width/height final float offsetX; // fractions de Screen.width/height
final float offsetY; final float offsetY;
final float sizeFactor; // taille relative au bouton standard
GameObject[] objects; // {fond, label} GameObject[] objects; // {fond, label}
Renderer background; Renderer background;
GuiText text; GuiText text;
boolean pressed = false; boolean pressed = false;
Button(String label, KeyCode keyCode, HSide hSide, float offsetX, VSide vSide, float offsetY) { Button(String label, KeyCode keyCode, HSide hSide, float offsetX, VSide vSide, float offsetY) {
this(label, keyCode, hSide, offsetX, vSide, offsetY, 1f);
}
Button(String label, KeyCode keyCode, HSide hSide, float offsetX, VSide vSide, float offsetY,
float sizeFactor) {
this.label = label; this.label = label;
this.keyCode = keyCode; this.keyCode = keyCode;
this.hSide = hSide; this.hSide = hSide;
this.offsetX = offsetX; this.offsetX = offsetX;
this.vSide = vSide; this.vSide = vSide;
this.offsetY = offsetY; this.offsetY = offsetY;
this.sizeFactor = sizeFactor;
} }
/** Rect du bouton en PIXELS écran, recalculé à chaque frame (resize). */ /** Rect du bouton en PIXELS écran, recalculé à chaque frame (resize). */
RectF rect(float screenW, float screenH) { RectF rect(float screenW, float screenH) {
float size = Math.min(screenW, screenH) * 0.15f; float size = Math.min(screenW, screenH) * 0.15f * sizeFactor;
float x = hSide == HSide.LEFT ? offsetX * screenW : screenW - offsetX * screenW - size; float x = hSide == HSide.LEFT ? offsetX * screenW : screenW - offsetX * screenW - size;
float y = vSide == VSide.TOP ? offsetY * screenH : screenH - offsetY * screenH - size; float y = vSide == VSide.TOP ? offsetY * screenH : screenH - offsetY * screenH - size;
return new RectF(x, y, size, size); return new RectF(x, y, size, size);

View File

@ -37,6 +37,7 @@ public class MainMenu extends Menu {
protected String[] getOptions() { protected String[] getOptions() {
return new String[]{ return new String[]{
"Play", "Play",
"Exterminate",
"Settings", "Settings",
"Quit" "Quit"
}; };
@ -46,6 +47,7 @@ public class MainMenu extends Menu {
protected MenuAction[] getActions() { protected MenuAction[] getActions() {
return new MenuAction[]{ return new MenuAction[]{
(menu, index, text) -> LevelManager.loadLevel("defense"), (menu, index, text) -> LevelManager.loadLevel("defense"),
(menu, index, text) -> LevelManager.loadLevel("exterminate"),
new MenuAction() { new MenuAction() {
@Override @Override
public void onMenuItemSelected(Menu menu, int index, String text) { public void onMenuItemSelected(Menu menu, int index, String text) {