Author Topic: I'm looking for helpers to make a joint game  (Read 4638 times)

0 Members and 1 Guest are viewing this topic.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #15 on: May 18, 2020, 02:48:18 am »
I will tell you honestly that I was still lazy in studying opengl.
I like all the possibilities that lie within it. light, speed.
But I don%u2019t just want to display it as a model.
OpenGL is very powerful if it used in right way.
Here is a short of video of the game engine I'm currently working -




PS : The video was recorded at 25FPS. But the actual program run at 60FPS
« Last Edit: May 18, 2020, 02:50:13 am by Ashish »
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #16 on: May 18, 2020, 03:23:43 am »
@Ashish

WOW Bro! That looks great! Glad to finally see a few people actually pushing QB64! It's Wolf3d/Kens labyrinth style and as an 80's baby i can dig that! All i can think to add is maybe you should have a look at some bump mapping on your doors and walls to really make it pop.

Unseen

Offline Unseen Machine

  • Forum Regular
  • Posts: 158
  • Make the game not the engine!
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #17 on: May 18, 2020, 05:50:56 am »
I had a look in my dropbox and found my Wolf3D map editor/renderer! I wrote it in 2011 when we had to use SFML to use GL! I'm moving house today but i might have a little go at updating it over the next week or so!

Here's some pics, one with lighting effects enabled.

Unseen

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #18 on: May 18, 2020, 11:29:44 am »
Congratulations Ashish for doing the 3d space with opengl!
Very good ! I wish I understood opengl so much!

I looked at the tutorial on your link! you write very nicely, understandably about the use of opengl 2d, colors, elements! (I suddenly had a lot :)

I searched in vain for an understandable description from the basics, in Hungarian, but I couldn't find it, so far your writing was the best!

I can't wait to continue! Show me what qb64 + opengl can do!

Good job if you’re expanding your 3d game, I’d love to watch a video of it the way it is  evolving!

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #19 on: May 18, 2020, 11:43:48 am »
Very good Unseen Machine ! There was no shadow in Wolf3d under Dos yet, now you have brought the space to life!

would it be possible for doom, shadows warrior, blood (my favorite) to revive the tracks? to improve textures and bring them to life in beautiful quality.

If the story and the enemies couldn’t be programmed in the same way, but I think it would be worth it to have a nostalgia walk in it.
« Last Edit: May 18, 2020, 11:53:19 am by MasterGy »

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #20 on: May 18, 2020, 12:09:54 pm »
Thanks @Unseen Machine. Looking forward to your 3d editor! :)
Thanks @MasterGy I am currently working on 2D transformation section.
So far, I added traps in my game engine. (like laser)
« Last Edit: May 18, 2020, 12:11:22 pm by Ashish »
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Galleon

  • QB64 Developer
  • Newbie
  • Posts: 25
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #21 on: May 21, 2020, 05:08:47 am »
RE: OpenGL vs _MAPTRIANGLE: OpenGL is (obviously) more powerful. However, the way I have seen OpenGL used by people in QB64 is heavily reliant on the fixed OpenGL pipelines and lighting found in OpenGL 1 which was all deprecated in OpenGL 2. Mobile devices do not support OpenGL 1. If QB64 ever did support mobile devices that code will simply not work. _MAPTRIANGLE was written to be fully compatible with OpenGL 2+ so it would work.

RE: _MOUSEMOVEMENTX & _MOUSEMOVEMENTY: Very broken ATM which means you cannot make first person mouse navigated content in the latest versions of QB64.

If I wanted to implement lighting using _MAPTRIANGLE I might do something like this in the code by MasterGy.
This code was a quick hack just to see what was possible and it may have flaws but the underlying concept should be sound enough.
Note that if the triangles are too big (like the floor from the code provided) it will be dark because all corners are a long way away from the player. Breaking the floor into multiple triangles would fix this problem. Performing SQR math on each triangle vertex is computationally expensive and a lookup table of SQR results may improve performance.

Add this code to MasterGy's code to see how this concept works:
somewhere in the init phase...
Code: QB64: [Select]
  1. lightmap32 = _NEWIMAGE(512, 512, 32)
  2. _DEST lightmap32
  3. FOR x = 0 TO 512
  4.     FOR n = 0 TO 255
  5.         b = x / 2
  6.         h = b + n
  7.         IF h > 255 THEN h = 255
  8.         IF h < b THEN h = b
  9.         l = b - n
  10.         IF l < -255 THEN l = -255
  11.         IF l > b THEN l = b
  12.  
  13.  
  14.         IF b = 0 THEN b = 1
  15.         IF l = 0 THEN l = 1
  16.         IF h = 0 THEN h = 1
  17.  
  18.         IF n <> 0 THEN
  19.             PSET (x, 256 + n), _RGBA(0, 0, 0, h)
  20.             PSET (x, 256 - n), _RGBA(0, 0, 0, l)
  21.         ELSE
  22.             PSET (x, 256), _RGBA(0, 0, 0, b)
  23.         END IF
  24.     NEXT
  25. lightmap33 = _COPYIMAGE(lightmap32, 33)
  26.  

Change _MAPTRIANGLE (sx1, sy1)-(sx2, sy2)-(sx3, sy3), pictri(triangles(actual_triangle, 3)) TO(wx1, wy1, wz1)-(wx2, wy2, wz2)-(wx3, wy3, wz3), , _SMOOTH to...
Code: QB64: [Select]
  1.         _DEPTHBUFFER LOCK
  2.         _MAPTRIANGLE (sx1, sy1)-(sx2, sy2)-(sx3, sy3), pictri(triangles(actual_triangle, 3)) TO(wx1, wy1, wz1)-(wx2, wy2, wz2)-(wx3, wy3, wz3), , _SMOOTH
  3.         _DEPTHBUFFER ON
  4.  
  5.         d1 = SQR(wx1 * wx1 + wy1 * wy1 + wz1 * wz1)
  6.         d2 = SQR(wx2 * wx2 + wy2 * wy2 + wz2 * wz2)
  7.         d3 = SQR(wx3 * wx3 + wy3 * wy3 + wz3 * wz3)
  8.  
  9.         b1 = d1 / 3
  10.         IF b1 > 255 THEN b1 = 255
  11.         IF b1 < 0 THEN b1 = 0
  12.         b2 = d2 / 3
  13.         IF b2 > 255 THEN b2 = 255
  14.         IF b2 < 0 THEN b2 = 0
  15.  
  16.         b3 = d3 / 3
  17.         IF b3 > 255 THEN b3 = 255
  18.         IF b3 < 0 THEN b3 = 0
  19.  
  20.         b3 = b3 - ((b1 + b2) / 2) + 256
  21.  
  22.         b1 = b1 * 2
  23.         b2 = b2 * 2
  24.  
  25.         _MAPTRIANGLE (b1, 256)-(b2, 256)-((b1 + b2) / 2, b3), lightmap33 TO(wx1, wy1, wz1)-(wx2, wy2, wz2)-(wx3, wy3, wz3), , _SMOOTH
  26.  
« Last Edit: May 21, 2020, 05:54:24 am by Galleon »

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #22 on: May 21, 2020, 12:20:20 pm »
Wooow, that's very interesting !! Thanks Galleon!
I am very glad that you drew my attention to this opportunity!
I haven’t known _DEPTHBUFFER so far, but as soon as I have time for it, I’ll study it.
Is this some kind of color-mixing mask that you project onto the texture?

It’s very interesting and an excellent idea to have a light effect.

Thanks !
Once this becomes a game, your name will be there!

So _MOUSEX therefore doesn't work on qb64 1.4? Um ... I did not know this!
« Last Edit: May 21, 2020, 12:21:27 pm by MasterGy »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #23 on: May 21, 2020, 05:22:14 pm »
Hi,

Galleon talk about _MOUSEMOVEMENTX, not about _MOUSEX.

This problem can be solved so:

Code: QB64: [Select]
  1. DIM SHARED OMX, OMY
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3.  
  4.  
  5.  
  6.     GETMovement mmx, mmy
  7.     LOCATE 1
  8.     PRINT mmx, mmy
  9.     _PRINTSTRING (x, y), " "
  10.     x = x + mmx
  11.     y = y + mmy
  12.     IF x > _WIDTH THEN x = _WIDTH
  13.     IF y > _HEIGHT THEN y = _HEIGHT
  14.     IF x < 0 THEN x = 0
  15.     IF y < 0 THEN y = 0
  16.     _PRINTSTRING (x, y), "*"
  17.     _LIMIT 50
  18.  
  19.  
  20.  
  21. SUB GETMovement (MousemovementX, MousemovementY)
  22.     MousemovementX = 0
  23.     MousemovementY = 0
  24.     IF _MOUSEX < OMX THEN MousemovementX = -10 'set other values for other sensitivity
  25.     IF _MOUSEX > OMX THEN MousemovementX = 10
  26.     IF _MOUSEY < OMY THEN MousemovementY = -10
  27.     IF _MOUSEY > OMY THEN MousemovementY = 10
  28.     _MOUSEMOVE _WIDTH / 2, _HEIGHT / 2
  29.     OMX = _WIDTH / 2
  30.     OMY = _HEIGHT / 2
  31.  
  32.  

This code locks mouse in middle on the screen, but you can use own mouse pointers, using SUB values (star demonstrate mouse pointer). In my 3D world with OpenGL, released on .NET 2 years back, is it so solved and works correctly.
« Last Edit: May 21, 2020, 05:25:47 pm by Petr »

Offline Galleon

  • QB64 Developer
  • Newbie
  • Posts: 25
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #24 on: May 21, 2020, 06:52:50 pm »
MasterGy, this works by drawing the same triangle twice. The first time it is drawn it is drawn normally. The second time it is drawn it is applying a single color texture (black for darkness, blue for sky-haze) with various levels of opacity over the top of the previous triangle. The trick is to have a 2D texture where all 3 levels of opacity can be represented in a triangular fashion. _DEPTHBUFFER is locked to make sure that the drawing of the 1st triangle does not block the drawing of the 2nd triangle.

Also, if you want to improve to look of the game further I suggest you look into using a softer/more blurry texture when triangles are further away to avoid that pixelated effect you are seeing on those wood textures. I believe the technical term for this is mipmapping. Here's a random link to a video showing the difference:
« Last Edit: May 21, 2020, 07:02:11 pm by Galleon »

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #25 on: May 22, 2020, 06:18:31 pm »
I made the Z-depth buffer into a large array.
I still don't understand what calculations Galleon's code does, but
  based on his writing, I made it so that you don't have to count in real time, you just read the corresponding shader of the current maptriangle from an array.

The program works, it works nicely, I really like the light effect, the only problem is that it is slow. There are few maptriangles in the image, no real-time calculation, and yet very slow.

Why?

When you start the program, you can use the "p" key to toggle the z-depth buffer function on and off.

Why does the display stutter?



https://drive.google.com/file/d/1kOEs3utkWtDubd6Ea8iz4WuPO2YwN0HT/view?usp=sharing

Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #26 on: May 22, 2020, 06:37:50 pm »
see when z-depthbuffer is on, it's very choppy, lagging, stuttering



when displayed, it does not perform a mathematical calculation but reads from an array

Code: QB64: [Select]
  1. FOR actual_triangle = 0 TO triangles - 1
  2.         IF triangles(actual_triangle, 10) THEN
  3.             wx1 = points(triangles(actual_triangle, 0), 4): wy1 = points(triangles(actual_triangle, 0), 5): wz1 = points(triangles(actual_triangle, 0), 6)
  4.             wx2 = points(triangles(actual_triangle, 1), 4): wy2 = points(triangles(actual_triangle, 1), 5): wz2 = points(triangles(actual_triangle, 1), 6)
  5.             wx3 = points(triangles(actual_triangle, 2), 4): wy3 = points(triangles(actual_triangle, 2), 5): wz3 = points(triangles(actual_triangle, 2), 6)
  6.             maptris = maptris + 1
  7.             sx1 = triangles(actual_triangle, 4): sy1 = triangles(actual_triangle, 5)
  8.             sx2 = triangles(actual_triangle, 6): sy2 = triangles(actual_triangle, 7)
  9.             sx3 = triangles(actual_triangle, 8): sy3 = triangles(actual_triangle, 9)
  10.             _DEPTHBUFFER LOCK
  11.             _MAPTRIANGLE (sx1, sy1)-(sx2, sy2)-(sx3, sy3), pictri(triangles(actual_triangle, 3)) TO(wx1, wy1, wz1)-(wx2, wy2, wz2)-(wx3, wy3, wz3) ', , _SMOOTH
  12.             _DEPTHBUFFER ON
  13.             _MAPTRIANGLE (lb(actual_triangle, azbx, azby, azbz, 0), 256)-(lb(actual_triangle, azbx, azby, azbz, 1), 256)-(lb(actual_triangle, azbx, azby, azbz, 3), lb(actual_triangle, azbx, azby, azbz, 2)), lightmap33 TO(wx1, wy1, wz1)-(wx2, wy2, wz2)-(wx3, wy3, wz3) ', , _SMOOTH
  14.         END IF
  15.     NEXT actual_triangle

Offline Galleon

  • QB64 Developer
  • Newbie
  • Posts: 25
    • View Profile
Re: I'm looking for helpers to make a joint game
« Reply #27 on: May 23, 2020, 08:06:35 am »
Firstly, I realised I over-complicated things with my "find triangle shape in alpha texture" approach. A texture with a single horizontal line of alpha values with all points on that line would have worked just fine.

You are most likely incurring a time penalty because:
a) Switching source textures too often
or
b) Switching between Z-buffer modes too often
With some logical experimentation you can identify exactly which is the case but I'm guessing (a) is the case.

If it is (a) you can possibly just add another line containing the alpha pixels to all of your textures (as long as you are not tiling them - specifying texture coordinates which loop, I doubt this is the case here).
If you want to get fancy you could add ambient, flat-lighting, and angle-based-lighting alpha line.