We have a new Beta: v0.8.13 ("Troubling Times") !

Useful links
Source code of the game - Contribution guide - ATCS Editor - Translate the game on Weblate - Example walkthrough - Andor's Trail Directory - Join the Discord
Get the game (v0.8.12.1) from Google, F-Droid, our server, or itch.io

Fight the bonemeal patrols, add belts…

Unstructured ideas, requests and suggestions for the development of the game.
Judoka
Posts: 9
Joined: Thu Sep 19, 2024 4:21 am
android_version: 14 - Android 14

Re: Fight the bonemeal patrols, add belts…

Post by Judoka »

I apologize for the delay. Weekdays are quite busy for me. I answer here for completeness of the thread. I'll move to Discord after this answer.
Nut wrote: Mon Oct 14, 2024 7:59 pm
Judoka wrote: Mon Oct 14, 2024 12:11 am The player's icon identifier is directly referenced in several source files,
E.g. the statue of the hero after helping Guynmart always shows the original hero icon. You mean things like this?
No. I mean like this:

Code: Select all

AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java:                heroicon.setImageResource(HeroCollection.getHeroLargeSprite(player.iconID));
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Stats.java:                    tv.setCompoundDrawablesWithIntrinsicBounds(HeroCollection.getHeroLargeSprite(player.iconID), 0, 0, 0);
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/activity/HeroinfoActivity.java:           world.tileManager.setImageViewTileForPlayer(getResources(), iv, world.model.player.iconID);
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java:          result.setBitmap(tileID_placeholder_hero, preloadedTiles.getBitmap(world.model.player.iconID));
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java:  public void setImageViewTile(Resources res, TextView textView, Player player) { setImageViewTileForPlayer(res, textView, player.iconID); }
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java:  public void setImageViewTile(Resources res, ImageView imageView, Player player) { setImageViewTileForPlayer(res, imageView, player.iconID); }
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/savegames/Savegames.java:                         displayInfo, world.model.player.iconID,
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/view/MainView.java:                       drawFromMapPosition(canvas, area, playerPosition, model.player.iconID);
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/view/MainView.java:                       tiles.drawTile(canvas, model.player.iconID, x, y, mPaint);
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/view/StatusView.java://                           new BitmapDrawable(res, world.tileManager.preloadedTiles.getBitmap(player.iconID))
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/view/StatusView.java:                     world.tileManager.setImageViewTileWithOverlay(res, heroImage, TileManager.iconID_moveselect, world.tileManager.preloadedTiles.getBitmap(player.iconID), true);
Each use, above, of player.iconID requires some analysis to make sure 1) the new logic is sound for the new purpose and 2) that it does not break anything. As I am just learning the code base, that is a bit time consuming, but tasks like this will become less cumbersome for me over time.
Nut wrote: Mon Oct 14, 2024 7:59 pm
Judoka wrote: Mon Oct 14, 2024 12:11 amthe player and monsters are not referenced polymorphically.
what do you mean with polymorphically?
Polymorphism is an object-oriented-programming (O.O.P.) abstraction concept embraced by Java, C++ and most other O.O.P. languages (some would say with negative consequences, but Android leaves little, if any, choice other than to use Java).
In A.T., the Player class inherits from (or "extends") a base class called Actor:

Code: Select all

…

public final class Player extends Actor {

…
So does the monster class:

Code: Select all

…

public final class Monster extends Actor {

…
This allows the engine to refer both to the player and the monsters with Actor references. It needn't differentiate between the two most of the time.
The Introduction to Computer Science example for this is often a chess program. One may create an abstract base (or "parent") class Piece with members color, row and column and a function move(int row, int column). One may then derive child classes Rook, Knight, Bishop, Queen, King and Pawn from Piece, with different logic for each's move() function.
The collection of live pieces may then be stored, all together, as an array of Piece objects, instead of separately storing each player's various pieces. When the program executes an array member's move() function, the language maps it to the appropriate move() for the child class of that piece.
That is what we have in some places in A.T., e.g., in ActorStatsListeners.java:

Code: Select all

…
        @Override
        public void onActorHealthChanged(Actor actor) {
                callAllListeners(this.onActorHealthChanged, actor);
        }
…
There are not two different sets of the logic, above, one for the player and another for monsters.
But, in the A.T. code that uses the iconID, we are passing around Player and Monster references, not Actor references, even though iconID is a property of Actor, inherited by its descendants Player and Monster. See, e.g., doDrawRect_Objects() in MainView.java:

Code: Select all

…
                if (!model.player.hasVFXRunning) {
                        drawFromMapPosition(canvas, area, playerPosition, model.player.iconID);
                } else if (area.contains(playerPosition)) {
                        int vfxElapsedTime = (int) (System.currentTimeMillis() - model.player.vfxStartTime);
                        if (vfxElapsedTime > model.player.vfxDuration) vfxElapsedTime = model.player.vfxDuration;
                        int x = ((model.player.position.x - mapViewArea.topLeft.x) * tileSize * vfxElapsedTime + ((model.player.lastPosition.x - mapViewArea.topLeft.x) * tileSize * (model.player.vfxDuration - vfxElapsedTime))) / model.player.vfxDuration;
                        int y = ((model.player.position.y - mapViewArea.topLeft.y) * tileSize * vfxElapsedTime + ((model.player.lastPosition.y - mapViewArea.topLeft.y) * tileSize * (model.player.vfxDuration - vfxElapsedTime))) / model.player.vfxDuration;
                        tiles.drawTile(canvas, model.player.iconID, x, y, mPaint);
                }
…
Regardless, I will do what I can to limit the scope of necessary downstream testing. But the change to allow the sprite to change and change back will, necessarily and inherently, be non-trivial.

It will be best and likely wise to test it in a beta,
/s/ Judoka.
Last edited by Judoka on Sun Oct 20, 2024 6:51 pm, edited 1 time in total.
User avatar
Nut
Posts: 1770
Joined: Mon Oct 27, 2014 12:14 pm
android_version: 8.0
Location: Glade

Re: Fight the bonemeal patrols, add belts…

Post by Nut »

thx for the background to polymorphism here. However, I don't know how consistently this was pursued in the engine...
For developing we use git branches, also we can switch easily between creation of a release APK or a beta APK. So yes, testing will be done in a beta APK.
Nut
Post Reply