Author Topic: Terror in the MAZE v20 (and newers)  (Read 7594 times)

0 Members and 1 Guest are viewing this topic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #15 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?

Offline Galleon

  • QB64 Developer
  • Newbie
  • Posts: 25
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #16 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)













Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #17 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

Offline Galleon

  • QB64 Developer
  • Newbie
  • Posts: 25
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #18 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
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.)

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #19 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.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #20 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)
« Last Edit: April 25, 2021, 03:11:07 am by MasterGy »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #21 on: April 25, 2021, 06:46:12 am »
Very nice game, perfectly done! Thank for sharing.

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #22 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. :)

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #23 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



Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #24 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.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Terror in the MAZE v20 (and newers)
« Reply #25 on: May 09, 2021, 02:37:15 pm »
Bravo, MasterGy!