Active Forums => QB64 Discussion => Topic started by: MasterGy on April 21, 2021, 01:45:17 pm
Title: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 21, 2021, 01:45:17 pm
Hello ! I opened a new post for the game because there is orders of magnitude more in the game than ever before. Also, because some of those who tried it didn’t look at the last link, but instead corrected and updated the first one in the post. From now on, if I update, the link will only be in one place, only here, in this section. Also because it’s not a “hibernate”. I didn’t write the latter elements in 4 dimensions, that part of the thing became uninteresting. I didn’t make a video of the game because I didn’t want to cover up the game’s solution. Get started and only one thing is important: get out of the maze! How do the gates open? What does the fairy do? The controls are simple: WASD, mouse left shoot, right mouse button, you can develop a strong fireball. From now on, I will want main enemies (witch, devil, fire-killing dragon) that will be activated when each gate is opened and will be orders of magnitude stronger than these little enemies. I want you to describe how easy it was to figure out how to get out. What is the strategy? What bugs do you find?
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Galleon on April 22, 2021, 12:22:18 am
I genuinely enjoyed playing your game.
Here are my thoughts: * I suggest not including exe files when sharing games on the QB64 forum because an .exe file can contain a virus. Or provide 2 separate downloads (one which is the exe version and one which is the source) * Don't split your game across 2 bas files if you can avoid it (I had to build each one separately) * Consider using partial transparency on the maze windows (but this is hard because to do it well you will need to draw all objects in order of distance) * Use lower resolution textures for far away objects (this is called mipmapping) * It's not obvious what to do when you get to a gate, I went looking for a red key-card... * Not obvious that you can charge up your weapon with right mouse and that a charge attack will break a gate, and sometimes it glitches and doesn't fully charge * 3D navigation system - At first glance this is a 3D maze with no up/down orientation, but that is not the way the player rotates - I suggest a proper 3D orientation system which supports turning on all 3 axes. It can be annoying when you are trying to turn (what you believe is) right and the player spins/rolls * If it was not for the fairy I would probably have given up, and when I couldn't see her I just moved around randomly
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Galleon on April 22, 2021, 02:48:35 am
Here it is also with the ordering of the textures so the semi-transparent windows don't block the drawing of things behind them. I used a (slow, but didn't notice the difference on my comp) bubble sort for sorting the triangles but in theory as this is grid-based you should be able to come up with a much better way of drawing them in order. *** updated to v3 which has some fixes *** *** I am aware that some game-logic (being hit by enemies for example) has been broken by reordering of parts of code so if you want the proper game experience best play the one MasterGy shared. Treat this more as an example of how you might use mipmaps and transparency ***
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 22, 2021, 01:28:56 pm
Hi Galleon! As I mixed the concrete today and looked at the forum over the phone, I saw that something had happened. I couldn’t wait to get home and watch the game, I saw in the screenshot that it was really good! What you did is huge! On the one hand, because you analyzed and modified my code according to your idea! Seeing other people's thinking and code is a huge intelligence, mainly because I barely write a comment. The other is that you took the time! This is an even bigger thing! And the result is huge! I recommend everyone to try the GALLEON version as well! For now, unfortunately, I don’t even understand how I can make a texture transparent. I wanted the cube to have a window glass effect, but I wanted to leave that for later. You solved it! Elegantly, beautifully, the way I imagined. Thank you very much for that! I still have to understand the midmap and the glass-effect thing. unfortunately your conversion is running very slowly on my computer but it makes sense! good direction! worth dealing with! Display is very important! _maptriangle and friends. From this, the task must be solved. Thanks for the idea and for dealing with it! Follow the fairy…. The right-mouse shot is also taken from the magazine on the right. If the magazine is not full, you will not be able to create 100 shot-energy fireballs. Before breaking through the wall, it’s worth checking this out as well as striving to make the magazine full. If there is little ammo in the magazine, it has an “R” button and reloads, just like in other fps games.
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Galleon on April 22, 2021, 11:08:44 pm
I'm glad you like my graphical "enhancement" suggestions. I recommend you use a tool like MinMerge to compare the source files before and after my changes because it will give a clearer idea of what I changed. There are a lot of things that can be improved/fixed but I don't really want to do any more on this than show you the possibilities.
Here are some ideas I have...
Distance sorting triangles with partial-transparency slowness: (i) use the previous distance sorted array as the basis of the next array (most data will be in the right order (or close to the right order) already so the sort will be very quick or (ii) build a binary-node tree of distances and then traverse that tree <-- recommended solution or (iii) as the map is a grid, and only the walls have partial transparency, process the map from furthest grid coordinates to closest grid co-ordinates
Startup slowness for mipmap generation: (i) Pre-generate the images at different resolutions/blurry-ness and store as files (could be impossible because they contain grid co-ordinates and colours) or (ii) Use integer math (atm SINGLE is the default data type which I didn't realise when coding this, no doubt this slowed down the mipmap generation code) <-- recommended solution Note: AT present all mipmaps are the same size just with different blurry-ness, ideally the lower quality ones would be lower resolution too but you need to adjust texture co-ordinates for that
Also note that along with making each mipmap more blurry the further it is, I also darkened them (only a little bit) as they are further away. This achieved a simple lighting effect which added a bit of atmosphere.
Whether you use my ideas or not doesn't bother me. Thank you for making and sharing interesting 3D games and experiences with the QB64 community.
'***Here is an updated version with some speed improvements for mipmap generation (integer math) and distance sorting (re-use previously sorted data)***
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 23, 2021, 12:53:49 pm
Again, I was really looking forward to getting home and trying it out. Unfortunately, it doesn't start with any of the qb64 versions. The window opens for a moment and exits.
sorry, it's already resolved. (I made my own mistake, I just started the generated exe and didn't notice that the file describing the parameters of the playing field, which is generated by the starter, is missing)
I tried to put both the game and the starter in 1 file, but despite the "RUN" key, the program crashes after a few starts. It would be nice if the "RUN" command came up with a full memory cleanup and started from scratch)
thank you so much for working on the development! I’m glad someone adds an idea and an implementation. I’ll be studying the solution over the weekend, and for now, I’m just admiring the rendering. Unfortunately, the large maze slows down the machine very much. As you wrote, I have already blocked the display for an unfinished game (tree_house_v40) in a similar way. I figured out in advance where I was, what it should look like. The same can be applied to mipmap.
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Galleon on April 23, 2021, 10:15:57 pm
The last version I shared yesterday supports multiple mipmap levels. It is probably set to 7 by default and it may generate too many textures for your system (as in your game every wall has its own texture to begin with).
Try changing it to 3... DIM SHARED mipmapLevels AS LONG mipmapLevels = 3 'max=20, recommended=7 (the higher the level the slower startup will be)
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 24, 2021, 02:35:56 am
I would like to transfer the glass effect anyway, and the mipmap will be done when the program is ready. For now, unfortunately, I don't understand either _alpha or the glass effect. Galleon solved it fantastically, and despite the code there, I don’t understand. I don’t know what the reason might be, I don’t understand the connections. I wrote a program quickly and I would like someone to help me in making the sq as it needs to be supplemented to make that circle, hole glass effect.
Note: PAINT is a special case where _DONTBLEND is actually unrequired but this is most likely a... Anyway for all other drawing/printing if you want to override the dest with the source color (not blend the source colour with the dest color) and the source color has an alpha component you need to to use _DONTBLEND
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Petr on April 24, 2021, 05:54:22 am
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Petr on April 24, 2021, 05:57:47 am
You can also create shadows - just add white or black to the original texture with the set transparency (if it is not better to have these textures ready in memory before use)
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 24, 2021, 06:05:09 am
I do not understand :))))
You succeeded with this little code. I also add color to the glass. I either add it to black or extract it from white. It worked. Even though I try to just add titm_game_88.bas to be glass, I can't. I don't even understand exactly what _blend, _dontblend does, although I'm very much studying. Either nothing is visible or the windows will be black.
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Petr on April 24, 2021, 06:26:55 am
Ok, so BLEND allow transparency. DONTBLEND disable transparency and program speed is then higher. You use hardware textures, right? For use with hardware _MAPTRIANGLE use it in this way:
_PUTIMAGE(300,20)-(500,120), HardTexture,0'place hardware image to software background - PUTIMAGE use standard coordinates system for Hardware textures
_MAPTRIANGLE(0,0)-(_WIDTH,0)-(_HEIGHT,0), HardTexture TO(-1,1,-3)-(1,1,-3)-(-1,-1,-3),0'place hardware textured triangle to software background - MAPTRIANGLE use OpenGL coordinate system
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 24, 2021, 06:36:10 am
I had a lot of questions.
I do not understand. if I make a window, I only see the maze through the window, but not the sky and the Earth. Does _maptriangle end with ", 0"?
I don't see all this.
is there any difference in use to ".32" or ".33" in the image? I noticed there wasn't.
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 24, 2021, 06:39:55 am
ok, I understood "0", he's the screen. I also mean transparency. Yet in the game, I don’t see the sky and the earth. But I don't understand that.
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Petr on April 24, 2021, 06:53:11 am
Is the sky and earth also a hardware texture, or is it a software texture? Is the sky and the ground painted before a window with a transparent texture?
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Galleon on April 24, 2021, 06:53:45 am
Quote
I do not understand. if I make a window, I only see the maze through the window, but not the sky and the Earth.
That's right. And you will not see all of the maze only parts of the maze.
To understand why this is requires a complex explanation which you may not understand but I will try.
On a 3D surface there is something called a Z-buffer. When you draw a triangle the distance of each pixel is stored in the Z-buffer. When you draw another triangle it will only draw the pixels if they are closer than the first pixels. This works fine when a pixel is completely transparent (alpha=0, it will not update the Z-buffer) or not transparent at all (alpha=255, it will update the Z-buffer). But what if alpha=128? Should it update the Z-buffer or not update the Z-buffer? Whatever it does could be wrong.
This is why partial transparency (alpha=1...alpha=254) is hard. But the solution is... 1. Draw all not transparent at all/completely transparent first (the earth, the stars, the monsters...) 2. Sort all surfaces which contain partial transparency from furthest to closest and draw them in that order (in my version that is why it sorts the map's triangles based on distance)
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 24, 2021, 06:56:22 am
sorry, I was in a hurry. finally resolved. the order of drawing is the key. thanks for the help
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Galleon on April 24, 2021, 07:20:36 am
For anyone who wants to read more on the topic of Z-buffers and semi-transparency this article covers it in more detail. https://www.sjbaker.org/steve/omniv/alpha_sorting.html (https://www.sjbaker.org/steve/omniv/alpha_sorting.html) For the code I provided in my previous full program example to MasterGy I manually sort each of the semi-transparent maze-polygons by their distance and to keep it fast I re-use the previously sorted distance array which results in 50x less sort iterations. Bubble sort is bad, but performs reasonably for "almost already sorted" content (https://www.toptal.com/developers/sorting-algorithms/nearly-sorted-initial-order#:~:text=Insertion%20sort%20is%20the%20clear,adapt%20to%20nearly%20sorted%20data. (https://www.toptal.com/developers/sorting-algorithms/nearly-sorted-initial-order#:~:text=Insertion%20sort%20is%20the%20clear,adapt%20to%20nearly%20sorted%20data.))
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 24, 2021, 10:12:19 am
well, it took 1 day for me to understand. Although, that if I use transparency, why sort it? If I don’t put the maze in order of distance, sometimes I can’t even see myself. Why? Without using the mipmap, I came up with a very simple solution for sequencing. So that you don't have to line up, so it's a huge array, and as far as the distance is, it's also the index, and I'll write in which triangle. So the larger maze also runs well. Thank you Galleon for showing me this opportunity!
Window glass texture can not be without sorting?
I posted the update at the beginning of the post.
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 25, 2021, 03:07:38 am
I improved the graphics. As the distance increases, the walls of the maze, the glass, darken, and the resolution of the texture deteriorates. Very good this _maptriangle, and the options. Thanks again to Galleon for the idea and the help!
(download at the beginning of the post)
Title: Re: Terror in the MAZE v20 (and newers)
Post by: Petr on April 25, 2021, 06:46:12 am
Very nice game, perfectly done! Thank for sharing.
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on April 25, 2021, 07:44:31 am
Thank you very much Petr! It's not ready yet, I want to include main enemies with different behaviors (which are activated after the box is blown up), to make the level varied, to fix a few things, and what else comes to mind. :)
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on May 04, 2021, 04:29:41 pm
Hello ! I'll post soon. enemies are thieves, dragons are merciless, get out of the maze only for the chosen ones :)
video v33
Title: Re: Terror in the MAZE v20 (and newers)
Post by: MasterGy on May 09, 2021, 02:45:45 am
Hello ! I managed to fix a lot of bugs, there is also a main enemy. I’ve put it up for download, I don’t think I’ll put more things in it anymore. The trouble is that at this size, you have to wait a long time to create an exe. Each change takes a lot of time. V36 ! Download at the beginning of the post.
Title: Re: Terror in the MAZE v20 (and newers)
Post by: bplus on May 09, 2021, 02:37:15 pm