Design Philsophies and shit.


#61

Hah yes, I discovered this myself the hard way(re. recursive vs queue). Feel free to compare your solution to mine and take away what you will. I’d be very interested to see if you did anything differently.

    private void floodLevel()
    {
        List<Point>     floodPoints = new ArrayList<>();
        List<Point>        discoveredPoints = new ArrayList<>();
        int             floodTileIndex = level_.getLayer(currentLayer_).getTileIndex(tileMouseAdapter_.getTileX(), tileMouseAdapter_.getTileY());
        Tile[][]         tileBucket = parent_.getCurrentTileBucket();
        Point             startPoint = new Point(tileMouseAdapter_.getTileX(), tileMouseAdapter_.getTileY());
        
        floodPoints.add( startPoint);
        discoveredPoints.add(startPoint);
        
        if ( tileBucket == null) {
            //use default tile to create a 1x1 bucket
            tileBucket = createDefaultTileBucket(1, 1);
        }
        
        saveLevelState("Tile Flood");
        
        while ( !floodPoints.isEmpty()) {
            Point floodPoint = floodPoints.remove(0);
            
            //search positions adjacent to the tile
            for ( int a = 0; a < 4; a++) {
                Point newPoint = new Point(floodPoint.getX() + TMath.VecX(a), floodPoint.getY() + TMath.VecY(a));
                int pointTileIndex = level_.getLayer(currentLayer_).getTileIndex(newPoint.getX(), newPoint.getY());
                //if we haven't discovered the tile and it matches the tile to flood
                if ( !discoveredPoints.contains(newPoint) &&
                     pointTileIndex >= 0 &&
                     pointTileIndex == floodTileIndex) {
                    floodPoints.add(newPoint);
                    discoveredPoints.add(newPoint);
                }
            }
        }
        
        for (Point floodPoint : discoveredPoints) {
            int tileSelX = TMath.Mod(floodPoint.getX() - startPoint.getX(), tileBucket[0].length);
            int tileSelY = TMath.Mod(floodPoint.getY() - startPoint.getY(), tileBucket.length);
            int tileIndex = tileBucket[tileSelY][tileSelX].getIndex();
            
            level_.getLayer(currentLayer_).setTile(floodPoint.getX(), floodPoint.getY(), tileIndex);
        }
   }

Edit: I realise this could be made potentially more efficient were I to also maintain a list of visited points as currently it’s possible I could check the same position twice for flooding.


#62

Not a lot that’s actually different glancing over it all, fundamentally. Your code makes mine look like a cheap hooker in a dark alleyway though XD especially because of the static calls to your math class. Where I am actually passing an object to perform the tile maths.

The only other differences are that I am creating new FloodActions via a pool, instead of instantiating them. Not sure if it’s really worth while or not, but I wanted to use a Pool somewhere in my code. And I am also iterating over the objects in the list, outside of the class that performs the action.

So, I have to pass a fair few objects to the node/action, including the queue it should add the found nodes/new actions to.

It’s all pretty stringy because of how man iterations I actually made of the tools and I will probably go back and redo it some time to be less all over the place, but for now, it works.


#63

Preliminary work on the tileset picker. Wracking my brain over it the last like week or so thinking of a nice way to do it by sharing textures between parent objects (the map map) and the tileset map, but I was just over complicating things and took a step back lol.

Still got some major things to work out, tileset switching, menu for tileset switching, getting the scroll pane to work correctly. Right now it gets cut off for some reason. I assume it’s something to do with something I did. (not visible in the image. Removed it for now)

Always feels good after struggling to figure something out and getting it :slight_smile: Especially with the selection code, fill code and then this tileset stuff, but as I said it was down to me just trying to be to technical.

Also did some work on the render calls. Doesn’t pull texture references from the map each time and holds it’s own cache of them.

Just updated the tileset picker. Spent a few hours figuring it all out, reading the source code a bit and figured some things out piece by piece. Some help from stack overflow also :smiley: still all super test code because it’s not encapsulated, but working nicely. The window itself can be resized and moved, etc also.

Well, except for the last tileset, which is smaller then the designated tileset size.

Next thing to work on is either selection previews, map loading and then multiple level rendering.


#64

Boop. Updated.


#65

Quite a lot of updates to this, but they’re not really all that visible as they were bugs I introduced by not thinking things through early on. Had an issue where the texture regions would read from top to bottom and then be placed from bottom to top, thus messing all kind of jazz up.

Still have a few things to fix because of this e.g y search directions for the flood tool. Shouldn’t be much of an issue though.

Had an issue because I was using the parents bounds for tile culling, rather then using the viewport. Which worked fine, but eventually broke down with some nested elements not actually having width and height values. Now i’m just being lazy and made the camera public static. Will pass the object later on.

Fixed a ton of UI issues and layout issues and started work on a top menu. Currently just a test button that says ass when you click it. The same area will possibly hold some information like tile ID.

Added in my own tileset to the mix for testing and also an different colored version.

Started work on the tile selection preview stuff, just hard coded right now and definitely not the right position.

I also updated the tileset with some new tiles, but nothing to special. Just some wooden walls.


#66

Nice progress, will you do any zooming?


#67

I plan to, but I want to hold off on that for now. Just trying to get the core things in really lol and then fix the things I break along the way. After I get loading levels and multiple level viewing in, I plan to look at that. So you can scale the entire map view for convenient map navigation.


#68

Been working on a few different things with this. Struggling a bit on some coordinate issues >.> I’m in the process of redoing how all the input works as I am having constant issues with it. I got burnt out on trying to fix it. So, I started on level loading and got sick of that quickly to haha, but worked through to get a mostly functional level loading system (barebones) I still need to add in tile state, alpha values into the loader, but a side from that it works quite nicely.

The map editing has been removed at the moment also, so no info is displayed for the actual map.

Done some snap to nearest tilesize for the tileset and also some display UI test stuff and info at the top.


#69

Bug fixes and bug fixes :slight_smile: Got a lot of things sorted today. Still lots of work to do, but I was able to make two decent looking maps with relative ease. Still tons of things to do like a layer switch pane, saving (not hard), undo, redo, getting my previewer working properly and some slight issues with flooding from one screen edge to another, which I had fixed already >.>

Made two maps as first recording messed up. Was quite useful as I noticed some issues with the tileset to.

[uploading time lapsed video now]


#70

Was expecting when the screen went blank the music took a pause to see a montage of the level take place soon afterwards haha. That editor looks like it has a decent flow but I failed to see how you were switching between layers. Great choice of music by the way.


#71

Tab and Shift+Tab to go up or down layers. I did have a screenshot of the whole level and it was in the thread initially, but it was removed because of the img tag bug :frowning: I should have just put them at the end.


#72

The whole thing made by you. Graphics, level and code. You’re a very talented individual. :smiley: