News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Maze rendering???

Started by ScottieB, October 23, 2013, 07:51:32 AM

Previous topic - Next topic

ScottieB

I'm haveing trouble rendering this new maze game I'm makeing.
When I texture it it's all off.
I also can't seem to use quads while depth sorting.
I either need a way to properly texturemap or some way to depth sort with regular drawing routines.
Ultimately I would like texturemaps but can't seem to get everything lined up.
Can someone please help me?
Thanks
ScottieB.

ScottieB

Another querk that seems to happen from time to time is
the look into the map array seems to go off the boundries
would anyone know why???
I also know that the program could be shorted but I first had to get the
right variables for the proper drawing of all directions.
I guess I could use images to do depth sorting of regular graphics but
is this wise???
Any help in brushing this program up would be geratly appreciated.
I still don't know why you can depth sort textured polys and not regular polys???
At least that's what is doing to me.
Please, Anyone who can help with any of these problems reply back.
Thanks.
SocttieB. 

ScottieB

Ok, I've fixed the off map error.  I was calculating in the wrong direction in the east halls.
Still wondering about other things.  Anyone, got any ideas???

kevin

#3
 ???  There's no depth sorting or polygon rendering in it.    You need to sort the faces from far to near (painters algorithm), then draw them in that order.   The built in cameras already do this.   Create a camera, capture the drawn tris / quads to the scene and make sure you set capturedepth.   

   Example: ASC II 3D Object Loader / Viewer V0.02


 The structure of the loops seem to be full of redundancy.  
 
PlayBASIC Code: [Select]
      If Direction = 0 Or Direction = 1 And Map(X_Location,Y_Clear) = 1 Then Y_Player_2 = Y_Position:X_Player_2 = 1
If Direction = 0 Or Direction = 1 And Map(X_Location,Y_Clear) = 1 Then Longitude(X_Position,Y_Position) = 1
If Direction = 0 Or Direction = 1 And Map(X_Location,Y_Clear) = 0 Then Longitude(X_Position,Y_Position) = 0

; Draw walls to longitude array.

If Direction = 0 Or Direction = 1 And Map(X_Location,Y_Clear) = 2 Then Longitude(X_Position,Y_Position) = 2
If Direction = 0 Or Direction = 1 And Map(X_Location - 1,Y_Clear) = 2 Then Longitude(X_Position - 1,Y_Position) = 2
If Direction = 0 Or Direction = 1 And Map(X_Location + 1,Y_Clear) = 2 Then Longitude(X_Position + 1,Y_Position) = 2



  In this fragment there's over a dozen redundant Direction = 0 Or Direction = 1 operations.

PlayBASIC Code: [Select]
      If Direction = 0 Or Direction = 1
if Map(X_Location,Y_Clear) = 1 Then Y_Player_2 = Y_Position:X_Player_2 = 1
If Map(X_Location,Y_Clear) = 1 Then Longitude(X_Position,Y_Position) = 1
If Map(X_Location,Y_Clear) = 0 Then Longitude(X_Position,Y_Position) = 0

; Draw walls to longitude array.
If Map(X_Location,Y_Clear) = 2 Then Longitude(X_Position,Y_Position) = 2
If Map(X_Location - 1,Y_Clear) = 2 Then Longitude(X_Position - 1,Y_Position) = 2
If Map(X_Location + 1,Y_Clear) = 2 Then Longitude(X_Position + 1,Y_Position) = 2
endif




PlayBASIC Code: [Select]
      If Direction = 0 Or Direction = 1
if Map(X_Location,Y_Clear) = 1 Then Y_Player_2 = Y_Position:X_Player_2 = 1
If Map(X_Location,Y_Clear) = 1 Then Longitude(X_Position,Y_Position) = 1
If Map(X_Location,Y_Clear) = 0 Then Longitude(X_Position,Y_Position) = 0

; Draw walls to longitude array.
If Map(X_Location,Y_Clear) = 2 Then Longitude(X_Position,Y_Position) = 2
If Map(X_Location - 1,Y_Clear) = 2 Then Longitude(X_Position - 1,Y_Position) = 2
If Map(X_Location + 1,Y_Clear) = 2 Then Longitude(X_Position + 1,Y_Position) = 2
endif



 
    Rather than access the same cell within an array, it's faster and shorter to pull the value into a variable and perform comparisons upon the variable.    


PlayBASIC Code: [Select]
      If Direction = 0 Or Direction = 1

CurrentTile=Map(X_Location,Y_Clear)

; the compares here obviously are no longer required
if CurrentTile = 1 Then Y_Player_2 = Y_Position:X_Player_2 = 1
If CurrentTile = 1 Then Longitude(X_Position,Y_Position) = 1
If CurrentTile = 0 Then Longitude(X_Position,Y_Position) = 0

; Draw walls to longitude array.
If CurrentTile = 2 Then Longitude(X_Position,Y_Position) = 2
If Map(X_Location - 1,Y_Clear) = 2 Then Longitude(X_Position - 1,Y_Position) = 2
If Map(X_Location + 1,Y_Clear) = 2 Then Longitude(X_Position + 1,Y_Position) = 2
endif



         Same goes for offsets when scanning through an array.  It's quicker and shorter to  compute offsets once, rather than every time it's needed.  Preferably outside of any nested loop.    


PlayBASIC Code: [Select]
    For Ylp = 1 to Height-1

; pre compute in outer loop, since these never change across the row
YlpMinus1 = Ylp-1
YlpPlus1 = Ylp+1

For Xlp = 1 to Width-1

; Compute the offset for this row
XlpMinus1 = Ylp-1
XlpPlus1 = Ylp+1

do stuff

next
next





 Recommended Reading: A Crash Course In BASIC program Optimization



stevmjon

hey scottieb

I love these old style dungeon games. reminds me of the first one I played. there was a text bar at the bottom of the screen, and you had to type in your commands to move around eg. m l (means move left). it was a good game in its day.

I like what you have done so far, can you post your progress.

  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.