Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : MAPSTER tile engine
Author | Message | ||||
Nautilus Newbie Joined: 01/01/2021 Location: GermanyPosts: 16 |
Hi and Happy Easter to all, after finishing my first game, i started a new long term project: a tile engine called MAPSTER at the moment it's still in a very early stage, but there are 2 demos to try out. give it a try (arrow keys to move, esc to quit) hints and suggestions are welcome grotto_escape.zip magic_cliffs.zip |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Nautilus, Congratulations! This is absolutely beautiful! I was going to try and tackle tiles next in my game engine, and here you come along with these two beautiful demos. I'll find the answer in the code but I do have one burning question right off the bat: Are all tiles pre-rendered on multiple pages or a big framebuffer or some such prior to display, or are they rendered on-the-fly from the map as you scroll? I'm just wondering if this will scale to a long level of a horizontal shooter for instance. The tiles are beautiful. Are they your own? Epsilon CMM2 projects |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
I found my answer in the RefreshTiles sub. The tiles are blitted on-the-fly. Excellent :-) This is also the first time I see there's such a thing as a JASC-PAL format. That's a nice find. Which program did you use that generates this palette file, if I may ask? Epsilon CMM2 projects |
||||
Nautilus Newbie Joined: 01/01/2021 Location: GermanyPosts: 16 |
Thanks for your response epsilon And yes, the scene blitted on-the-fly - so a looOOOoong level for a shooter is no problem The palette file is a part of my workaround to loading "palette based bitmaps" fast and with the correct colours. I'am using GraphicsGale (former a comercial program, now freeware), that can read and write JASC-palette files. Paint Shop Pro using this too (the format is described here: https://liero.nl/lierohack/docformats/other-jasc.html ). The tilesets are based on the game assets from ansimuz. You can download it for free at https://itch.io/game-assets Next step is the implementation of tile animation (lava falls, torches, water, more lava falls ) |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8600 |
This is very impressive. Trivial but don't forget the max and min functions and also (not relevant here) the choice function.They can save quite a lot of code sub MoveCam(deltaX%, deltaY%) CamX% = MIN(WORLD_W-CAM_W,max(0,CamX% + deltaX%)) CamY% = MIN(WORLD_H-CAM_H,MAX(0,CamY% + deltaY%)) refresh% = TRUE end sub |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Thanks. Those are great resources. I'm looking forward to that. Are you using a level editor to create the tilemap.csv? Epsilon CMM2 projects |
||||
Nautilus Newbie Joined: 01/01/2021 Location: GermanyPosts: 16 |
Thanks for this nice piece of code BTW: page copy OVERLAY_PAGE to HIDDEN_PAGE, I, 1 does not work the way i want. The result is a black screen. Blitting with the &b100-attribute works fine. So whats the problem with DONTCOPYBLACK in PAGE COPY? |
||||
Nautilus Newbie Joined: 01/01/2021 Location: GermanyPosts: 16 |
Yes - the TILED map editor is your friend ( https://www.mapeditor.org/ ) |
||||
MauroXavier Guru Joined: 06/03/2016 Location: BrazilPosts: 303 |
Nautilus, very clever idea, I will get a look at this software. Thanks for the tip! Meanwhile, I suffered developing a map editor only to have the experience creating maps directly on the CMM2... But for sure this isn't the most recommendable experience to speed up the development of a 2D game. Now I'm seriously thinking about quit making another map editor to the INTO THE DARKNESS game. About your engine, I found the source code very well indented and understandable. I have a suggestion to speed up your rendering, change your engine to make only one full refresh at the beginning, and after make it refresh only a line or column on the sides of the screen as it moves. If you use a parallax background, you can store the main tiled screen on another page to join it in the background after, this way you don't need to rewrite all the scene again too. |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
Fantastic. I'm almost disappointed because I wanted to create a tool like this on CMM2. But I still can of course :-) I spent some time with GraphicsGale today. I love the option to export sprite meta-data as a .csv along with the spritesheet. Between these tools and your own code, I can scratch off half of my to-do list. I have a background in the demoscene, on c64 and PC. This is my first foray into game development. What is your background, if you want to share? Do you have any prior exposure to game development, or are you just more diligent than I am in your tools research? :-) Epsilon CMM2 projects |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8600 |
It is a manual bug or at least the code doesn't match the manual Try page copy 0 to 1,i,t where "t" is for transparent |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
There's more than meets the eye here. The CMM2 BMP loader assumes the default RGB332 palette in 8-bit mode, so you have to jump through a few hoops to get a BMP image displayed correctly using a custom palette. I think what you did is you saved off your BMP's real palette on grotto_escape.pal, then replaced the palette in the BMP with the CMM2 default RGB332 palette. When you load this BMP on CMM2, it looks all wrong, but with grotto_escape.pal in the CLUT, it displays correctly. The (wrong) RGB values in the BMP get mapped back to correct RGB values through the custom CLUT. I gave it a try by generating the RGB332 palette in the JASC-PAL format and swapping it with the palette of an 8-bit BMP using GraphicsGale. Works great :-) This is neat. RGB332 is limiting. With a custom palette you can stretch 8-bit color mode a lot further, and you can do it without losing the BMP loader. Epsilon CMM2 projects |
||||
jirsoft Guru Joined: 18/09/2020 Location: Czech RepublicPosts: 532 |
I don't think so. I have written custom save of BMP in GRF.INC and I'm saving the real (current) palette and it's loading back OK. I did it mainly because of possibility to write real 8bpp and 16bpp BMPs, because SAVE IMAGE saves 24bpp image (I don't know why), but also palette works great. Jiri Napoleon Commander and SimplEd for CMM2 (GitHub), CMM2.fun |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
That works because the BMP loader looks up your BMP's palette RGB888 values and maps them to the nearest RGB332 values which are in the default palette, so it may look correct, but it's an approximation. If the BMP being saved only contains colors out of the RGB332 palette it's even 100% accurate. However, you import tilesets, spritesheets or something like that from sites like itch.io, they'll use colors outside of the RGB332 palette. The mapping to RGB332 will work fairly well, but the color resolution is limited. It'll be noticeable when you have more than three shades of blue for instance. Epsilon CMM2 projects |
||||
Nautilus Newbie Joined: 01/01/2021 Location: GermanyPosts: 16 |
That was exactly the point - wrong colors and lost details when loading palette based tilesets (from itch.io,opengameart ...) I first tried to read the raw data of the bitmaps directly. It worked, but very slow (4 seconds for a small image) :( With the palette swap it is much faster and not much work (and yes, it works exactly as you described it). Here is "my" CMM2 system palette: CMM2palette.zip Otherwise programming is just a hobby. But i'm very busy professionally and free time is scarce. Maybe that's why i'll look more often for existing tools before i write some myself ;) @peter: the "t"-attribute for PAGE COPY works fine :) |
||||
Nautilus Newbie Joined: 01/01/2021 Location: GermanyPosts: 16 |
at the beginning i wanted to realize it exactly like that. but i decided against it, because i really want to have tile animation (lava falls !!! ) but i keep the idea in my mind (maybe a special version for a special game) ... |
||||
MauroXavier Guru Joined: 06/03/2016 Location: BrazilPosts: 303 |
You can refresh only animated tiles on the screen, not all tiles in a single refresh. I made it in the MAZE OF CHAOS (aka Gauntlet clone) to animate some objects and the speed gain was very noticeable. It would impossible to keep four players running at the same time if I chose to refresh all tiles in each game loop. In your case, I believe it would be a good way as you are working in a higher resolution than my games. |
||||
Nautilus Newbie Joined: 01/01/2021 Location: GermanyPosts: 16 |
you're absolutely right, but i'm afraid that i'll have to adjust the refresh_tiles routine every time i add a new feature. at the moment i find the mapster design very simple and flexible and for now i want to continue this way. it could be that in a few months i realise: i am wrong and then you can send me this picture but at the moment i am very satisfied with the speed and there is still room for optimisation (also with regard to the upcoming firmware version). ps: the first animated lava fall is already running on my cmm2 stay tuned! |
||||
Nautilus Newbie Joined: 01/01/2021 Location: GermanyPosts: 16 |
a short update on the current status of the mapster tile engine: - a simple timer system is running - tile animation support (lava falls ) - creation and integration of a collision map works well, but is still completely useless at the moment now i'm working on the game object structure and tile collisions. this is all quite new to me - searching the net for information, but most tutorials are not in basic and/or deal with an existing game engine and less with the principle behind it and/or are object oriented (and basic is not) ... i think the biggest challenge is to keep it BASIC ... but it's coming along. here's a new demo to watch: grotto_escape_demo2.zip |
||||
epsilon Senior Member Joined: 30/07/2020 Location: BelgiumPosts: 255 |
The tile animation looks great! I'll probably try to steal that In xDragon, a rectangular box of configurable width and height is associated with each sprite. The box has world coordinates which can be easily reduced to tile coordinates (e.g. divide by 16 if world coordinates are pixels units and tiles are 16 pixels wide and high), so it's not too hard to figure out which tiles the object is occupying. For these tiles, I check the tileId in the collision layer of the tile map and based on that I decide if we have a collision or not. In the collision layer I currently just use 2 tileIds: 0=no collision, 1=collision. With additional tileIds this can be extended to differentiate between collision-from-left, collision-from-above etc. which may help to determine the response to a collision, e.g. in which direction to bounce. This method is not pixel-perfect, but in most cases you don't really need to be pixel-perfect. Yeah, people here on TBS have shown that a lot is possible in pure BASIC, but I'm too lazy for that. If I find that a certain chunk of code is too slow, I just rewrite in C. Epsilon CMM2 projects |
||||
Print this page |