Skip to content

Commit

Permalink
Compat 5.9.0 (#351)
Browse files Browse the repository at this point in the history
* fix bug from tilemapExt not placing tiles

* mode: 5.9  compat

* ProjectJumper: 5.9.0 compat

* Pathfinding: 5.9.0 compat

* FlxNapeTilemap: 5.9.0  compat

* Tilemap: 5.9.0 compat

* HeatmapPathfinder: 5.9.0 compat

* Flixius: 6.0.0 compat

* Minimalist TD: 6.0.0 compat

* NeonVector: 6.0.0 compat

* FlxAction: 5.9.0 compat

* DynamicShadows: 5.9.0 compat

* FlxGameOfLife: 5.9.0 compat

* FlxCaveGenerator: 5.9.0 compat

* pathfinder: more

* BSPMapGen: 5.9.0 compat
  • Loading branch information
Geokureli authored Jun 16, 2024
1 parent f3dcbc3 commit dd0afb8
Show file tree
Hide file tree
Showing 35 changed files with 180 additions and 145 deletions.
3 changes: 3 additions & 0 deletions Arcade/Flixius/Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@

<!-- ______________________________ Haxedefines _____________________________ -->

<!--Disable the legacy health system-->
<haxedef name="FLX_NO_HEALTH" />

<!--Enable the Flixel core recording system-->
<!--<haxedef name="FLX_RECORD" />-->

Expand Down
6 changes: 3 additions & 3 deletions Arcade/Flixius/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class PlayState extends FlxState
}
}

function eBulletHitPlayer(EB:FlxSprite, P:FlxSprite):Void
function eBulletHitPlayer(EB:FlxSprite, P:Player):Void
{
if (EB.alive)
{
Expand All @@ -355,15 +355,15 @@ class PlayState extends FlxState
_hits.add(hit);
}

function playerHitEnemy(P:FlxSprite, E:FlxSprite):Void
function playerHitEnemy(P:Player, E:Enemy):Void
{
if (E.alive)
{
E.kill();
addExplosions(E);
FlxG.camera.flash(FlxColor.WHITE, .1);
_score += 100;
_sprPlayer.hurt(1);
P.hurt(1);
}
}

Expand Down
14 changes: 11 additions & 3 deletions Arcade/Flixius/source/Player.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import flixel.util.FlxColor;
class Player extends FlxSprite
{
public var dying:Bool = false;
public var health:Int = 10;

var _dyingTimer:Float = 2;
var _deathCallback:FlxSprite->Void;
Expand All @@ -21,8 +22,15 @@ class Player extends FlxSprite
health = 10;
_deathCallback = DeathCallback;
}

override public function kill():Void

public function hurt(damage:Int)
{
health -= damage;
if (health <= 0)
kill();
}

override function kill():Void
{
health = 0;
dying = true;
Expand All @@ -33,7 +41,7 @@ class Player extends FlxSprite
FlxG.camera.flash(FlxColor.WHITE, .1);
}

override public function update(elapsed:Float):Void
override function update(elapsed:Float):Void
{
super.update(elapsed);
if (dying)
Expand Down
3 changes: 3 additions & 0 deletions Arcade/MinimalistTD/Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@

<!-- ______________________________ Haxedefines _____________________________ -->

<!--Disable the legacy health system-->
<haxedef name="FLX_NO_HEALTH" />

<!--Enable the Flixel core recording system-->
<!--<haxedef name="FLX_RECORD" />-->

Expand Down
13 changes: 7 additions & 6 deletions Arcade/MinimalistTD/source/Enemy.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package;

import flixel.FlxG;
import flixel.FlxSprite;
import flixel.path.FlxPath;
import flixel.math.FlxPoint;
import flixel.path.FlxPath;

class Enemy extends FlxSprite
{
public var moneyGain:Bool = true;
public var maxHealth:Float = 1.0;
public var health:Float = 1.0;

/**
* Create a new enemy. Used in the menu and playstate.
Expand All @@ -35,9 +36,9 @@ class Enemy extends FlxSprite
/**
* The alpha of the enemy is dependent on health.
*/
override public function update(elapsed:Float):Void
override function update(elapsed:Float):Void
{
alpha = health / maxHealth;
// alpha = health / maxHealth;
super.update(elapsed);
}

Expand All @@ -46,7 +47,7 @@ class Enemy extends FlxSprite
*
* @param Damage The damage to deal to this enemy.
*/
override public function hurt(Damage:Float):Void
public function hurt(Damage:Float):Void
{
health -= Damage;

Expand Down Expand Up @@ -86,7 +87,7 @@ class Enemy extends FlxSprite
* and then uses FlxPath.start() to set this enemy on the path. Speed is determined by wave number, unless
* in the menu, in which case it's arbitrary.
*/
public function followPath(Path:Array<FlxPoint>, Speed:Int, ?OnComplete:FlxPath->Void):Void
public function followPath(Path:Array<FlxPoint>, Speed:Int, ?OnComplete:() -> Void):Void
{
if (Path == null)
throw("No valid path was passed to the enemy! Does the tilemap provide a valid path from start to finish?");
Expand All @@ -95,6 +96,6 @@ class Enemy extends FlxSprite
Path[0].y = y;

path = new FlxPath().start(Path, Speed, 0, true);
path.onComplete = OnComplete;
path.onEndReached.add((_) -> OnComplete());
}
}
2 changes: 1 addition & 1 deletion Arcade/MinimalistTD/source/MenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class MenuState extends FlxState
/**
* Starts the enemy on the map path.
*/
public function enemyFollowPath(?_):Void
public function enemyFollowPath():Void
{
_enemy.setPosition(startPosition.x, startPosition.y - 12);
var path:Array<FlxPoint> = _map.findPath(startPosition, endPosition);
Expand Down
4 changes: 2 additions & 2 deletions Arcade/MinimalistTD/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ class PlayState extends FlxState
/**
* Called when a bullet hits an enemy. Damages the enemy, kills the bullet.
*/
function hitEnemy(bullet:Bullet, enemy:FlxSprite):Void
function hitEnemy(bullet:Bullet, enemy:Enemy):Void
{
enemy.hurt(bullet.damage);
bullet.kill();
Expand Down Expand Up @@ -719,7 +719,7 @@ class PlayState extends FlxState
}

// Can't place towers on the road
if (_map.getTile(Std.int(xPos / TILE_SIZE), Std.int(yPos / TILE_SIZE)) == 0)
if (_map.getTileIndexAt(xPos, yPos) == 0)
{
FlxG.sound.play("deny");

Expand Down
4 changes: 2 additions & 2 deletions Effects/DynamicShadows/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class PlayState extends FlxState
{
for (tileX in 0...foreground.widthInTiles)
{
var tileIndex = foreground.getTile(tileX, tileY);
var tileIndex = foreground.getTileIndex(tileX, tileY);
var xPos:Float = tileX * TILE_SIZE;
var yPos:Float = tileY * TILE_SIZE;

Expand All @@ -133,7 +133,7 @@ class PlayState extends FlxState
*/
function cleanTile(x:Int, y:Int):Void
{
foreground.setTile(x, y, 0);
foreground.setTileIndex(x, y, 0);
}

override public function update(elapsed:Float):Void
Expand Down
12 changes: 6 additions & 6 deletions Features/FlxNapeTilemap/source/gameobj/CustomNapeTilemap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package gameobj;

import Constants.TileType;
import flixel.addons.nape.FlxNapeTilemap;
import flixel.system.FlxAssets;
import flixel.math.FlxPoint;
import flixel.system.FlxAssets;
import nape.geom.Vec2;

using logic.PhysUtil;
using Lambda;
using logic.PhysUtil;

class CustomNapeTilemap extends FlxNapeTilemap
{
Expand Down Expand Up @@ -40,7 +40,7 @@ class CustomNapeTilemap extends FlxNapeTilemap

for (tx in 0...widthInTiles)
{
if (TileType.ONE_WAY.has(getTileByIndex(ty * widthInTiles + tx)))
if (TileType.ONE_WAY.has(getTileIndex(tx, ty)))
{
if (!prevOneWay)
{
Expand All @@ -54,20 +54,20 @@ class CustomNapeTilemap extends FlxNapeTilemap
else if (prevOneWay)
{
prevOneWay = false;
var startPos = getTileCoordsByIndex(startY * widthInTiles + startX, false);
var startPos = getTilePos(startX, startY, false);
PhysUtil.setOneWayLong(this, startPos, length);
}
}

if (prevOneWay)
{
prevOneWay = false;
var startPos = getTileCoordsByIndex(startY * widthInTiles + startX, false);
var startPos = getTilePos(startX, startY, false);
PhysUtil.setOneWayLong(this, startPos, length);
}
}

for (point in getTileCoords(TileType.SPAWN, false))
for (point in getAllTilePos(TileType.SPAWN, false))
{
point.x += scaledTileHeight * 0.5;
spawnPoints.push(point);
Expand Down
2 changes: 1 addition & 1 deletion Features/FlxNapeTilemap/source/logic/PhysUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PhysUtil
{
tilemap.body.space = null;
var polygon:Polygon;
var coords:Array<FlxPoint> = tilemap.getTileCoords(index, false);
var coords:Array<FlxPoint> = tilemap.getAllTilePos(index, false);
for (point in coords)
{
polygon = new Polygon(vertices, mat);
Expand Down
6 changes: 3 additions & 3 deletions Features/HeatmapPathfinding/source/DistanceTilemap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DistanceTilemap extends FlxTilemap

function getTileScoreByIndex(index:Int):Int
{
if (collisionMap.getTileCollisions(collisionMap.getTileByIndex(index)) == NONE)
if (collisionMap.getTileData(index).solid)
return getDistanceToTargetByIndex(index);

return maxDistance;
Expand Down Expand Up @@ -106,11 +106,11 @@ class DistanceTilemap extends FlxTilemap

function setTileByDistance(index:Int, distanceRatio:Float)
{
setTileByIndex(index, Std.int(colorTiles * distanceRatio), true);
setTileIndex(index, Std.int(colorTiles * distanceRatio), true);
}

function setBlockedTile(index:Int)
{
setTileByIndex(index, blockedTile, true);
setTileIndex(index, blockedTile, true);
}
}
4 changes: 2 additions & 2 deletions Features/HeatmapPathfinding/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ class PlayState extends FlxState

function getTileAt(x:Float, y:Float):Int
{
return tilemap.getTile(Std.int(x / TILE_SIZE), Std.int(y / TILE_SIZE));
return tilemap.getTileIndexAt(x, y);
}

function setTileAt(x:Float, y:Float, value:Int):Void
{
tilemap.setTile(Std.int(x / TILE_SIZE), Std.int(y / TILE_SIZE), value, true);
tilemap.setTileIndexAt(x, y, value, true);

updateDistanceMap();
}
Expand Down
4 changes: 2 additions & 2 deletions Features/Pathfinding/source/BigMoverPathfinder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class BigMoverPathfinder extends FlxDiagonalPathfinder
(heightInTiles - 1) / 2 * map.height / map.heightInTiles
);
// offset to center of top-left tile
final startIndex = map.getTileIndexByCoords(FlxPoint.weak(start.x - offset.x, start.y - offset.y));
final endIndex = map.getTileIndexByCoords(FlxPoint.weak(end.x - offset.x, end.y - offset.y));
final startIndex = map.getMapIndexAt(start.x - offset.x, start.y - offset.y);
final endIndex = map.getMapIndexAt(end.x - offset.x, end.y - offset.y);
offset.put();

final data = createData(map, startIndex, endIndex);
Expand Down
10 changes: 5 additions & 5 deletions Features/Pathfinding/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class PlayState extends FlxState
function clearMap()
{
for (i in 0...map.totalTiles)
map.setTileByIndex(i, 0);
map.setTileIndex(i, 0);

redrawPath();
}
Expand Down Expand Up @@ -258,22 +258,22 @@ class PlayState extends FlxState
// Check mouse pressed and unit action
if (FlxG.mouse.pressed)
{
var index = map.getTileIndexByCoords(FlxG.mouse.getWorldPosition(FlxPoint.weak()));
var index = map.getMapIndexAt(FlxG.mouse.x, FlxG.mouse.y);
if (index != -1)
{
var tileEmpty = map.getTileByIndex(index) == 0;
var tileEmpty = map.getTileIndex(index) == 0;
if (FlxG.mouse.justPressed)
{
// start toggle tiles
isPlacing = tileEmpty;
map.setTileByIndex(index, isPlacing ? 1 : 0, true);
map.setTileIndex(index, isPlacing ? 1 : 0, true);

mapChanged = true;
}
else if (tileEmpty == isPlacing)
{
// continue toggling tiles on mouse drag
map.setTileByIndex(index, isPlacing ? 1 : 0, true);
map.setTileIndex(index, isPlacing ? 1 : 0, true);

mapChanged = true;
}
Expand Down
3 changes: 2 additions & 1 deletion Features/Replay/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class PlayState extends FlxState

override public function update(elapsed:Float):Void
{
FlxG.collide(_tilemap, _player);
// FlxG.collide(_tilemap, _player);
FlxG.collide(_player, _tilemap);

// Update the player
_player.acceleration.x = 0;
Expand Down
4 changes: 2 additions & 2 deletions Features/SetTileProperties/source/PlayState.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package;

import flixel.effects.particles.FlxEmitter;
import flixel.FlxG;
import flixel.FlxObject;
import flixel.FlxState;
import flixel.effects.particles.FlxEmitter;
import flixel.text.FlxText;
import flixel.tile.FlxTile;
import flixel.tile.FlxTilemap;
Expand Down Expand Up @@ -108,7 +108,7 @@ class PlayState extends FlxState

function removeTile(Tile:FlxTile):Void
{
_map.setTileByIndex(Tile.mapIndex, 0, true);
_map.setTileIndex(Tile.mapIndex, 0, true);
}

function leftHit(Tile:FlxObject, Particle:FlxObject):Void
Expand Down
2 changes: 1 addition & 1 deletion Features/Tilemap/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class PlayState extends FlxState
// FlxTilemaps can be manually edited at runtime as well.
// Setting a tile to 0 removes it, and setting it to anything else will place a tile.
// If auto map is on, the map will automatically update all surrounding tiles.
_collisionMap.setTile(Std.int(FlxG.mouse.x / TILE_WIDTH), Std.int(FlxG.mouse.y / TILE_HEIGHT), FlxG.keys.pressed.SHIFT ? 0 : 1);
_collisionMap.setTileIndexAt(FlxG.mouse.x, FlxG.mouse.y, FlxG.keys.pressed.SHIFT ? 0 : 1);
}

updatePlayer();
Expand Down
2 changes: 1 addition & 1 deletion Input/FlxAction/source/Player.hx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Player extends FlxSprite
move = new FlxActionAnalog();

if (actions == null)
actions = FlxG.inputs.add(new FlxActionManager());
actions = FlxG.inputs.addInput(new FlxActionManager());
actions.addActions([up, down, left, right, trigger1, trigger2, move]);

// Add keyboard inputs
Expand Down
10 changes: 5 additions & 5 deletions Other/BSPMapGen/source/play/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ class PlayState extends FlxState
override public function create():Void
{
map = new FlxTilemap();
var csvData:String = FlxStringUtil.bitmapToCSV(GenerateState.mapData);
final csvData:String = FlxStringUtil.bitmapToCSV(GenerateState.mapData);
map.loadMapFromCSV(csvData, "assets/images/tiles.png", TILE_SIZE, TILE_SIZE, AUTO);
add(map);

// Randomly pick room for player to start in
var emptyTiles:Array<FlxPoint> = map.getTileCoords(0, false);
var randomEmptyTile:FlxPoint = emptyTiles[FlxG.random.int(0, emptyTiles.length)];

final emptyTiles:Array<Int> = map.getAllMapIndices(0);
final randomEmptyTile:FlxPoint = map.getTilePos(emptyTiles[FlxG.random.int(0, emptyTiles.length)]);
add(new Player(randomEmptyTile.x, randomEmptyTile.y));
randomEmptyTile.put();

var gutter:Int = 10;
final gutter:Int = 10;
add(new FlxButton(gutter, gutter, "Back (Space)", back));
}

Expand Down
Loading

0 comments on commit dd0afb8

Please sign in to comment.