SyntaxBomb - Indie Coders

General Category => Worklogs => Topic started by: iWasAdam on October 27, 2020, 07:38:58

Title: testing something new...
Post by: iWasAdam on October 27, 2020, 07:38:58
I thought I would pop back to isometric and build a new engine - this time with nightshade/gunfright in mind...
(https://vjointeractive.files.wordpress.com/2020/10/demo.gif?w=1008)
the base res is 256x192 Spectrum - but it can do other res and hi-res graphics too

I should add that this is BlitzNG
Title: Re: testing something new...
Post by: Xerra on October 27, 2020, 16:45:05
I do miss Blitz. I had some good email conversations with Brucey when we tried out some NG/IOS game converting with some of my stuff a few years back. Not sure I'd want to go back to programming with it now I've got so used to GMS. If I was doing app development then I'd obviously consider it again.

I'd used Blitz Basic since its original variant on the Amiga back in the mid-90's, sigh.
Title: Re: testing something new...
Post by: Steve Elliott on October 27, 2020, 18:49:18
Warming up for the arrival of your Spectrum Next Adam?  Marvellous.  You'll sell loads.   :D
Title: Re: testing something new...
Post by: 3DzForMe on October 30, 2020, 07:17:57
@xerra, Ditto. Although.... I still use Blitz3D, got something that produces a height map that AGK in turn uses to render a 3D height map..... Which is nice.
Title: Re: testing something new...
Post by: iWasAdam on October 30, 2020, 08:17:23
if anyone is interested I've just spent time shouting at the comp about isometric sorting. It turns out it's simple but not in an obvious way.

first
any object needs a base reference point at it's center
the object then needs a min and max bounds used for collision, etc

sorting
when you sort you do it in 2 steps
1. quick loop to give each object a distance from far away point 999,999 is a good one.
distance is sqrt(x*x+y*y)
2. do a simple sort on the distances, far away being at the first item

when drawing just use the sorted objects farthest first
Title: Re: testing something new...
Post by: Matty on October 30, 2020, 09:05:43
Easier way....

Before rendering calculate all iso sprites 'feet' screen y pos. Then put into an array of length screen height at each index an array of sprites with their x.  Then loop from 0 to screenheight through array drawing each group of sprites at that y pos.  Any ypos without any sprites gets skipped.
Title: Re: testing something new...
Post by: iWasAdam on October 30, 2020, 10:10:13
good call matty - a slightly different approach :)
Title: Re: testing something new...
Post by: Derron on October 30, 2020, 11:17:01
Matties approach requires 1080 arrays for "HD" - even if there are only 100 elements.
So if you only have a handful of elements - sort by "z" in a single array.

I used a kind of mix of your ideas :
a list (might be more - if layers are to "overdraw" each other) and a sort function.


Code: BlitzMax
  1.         Function _SortEntitiesByZ:int(o1:object, o2:object)
  2.                 local e1:TTileMapEntity = TTileMapEntity(o1)
  3.                 local e2:TTileMapEntity = TTileMapEntity(o2)
  4.                 if not e1 then return 1
  5.                 if not e2 then return -1
  6.  
  7.                 return e1.GetRenderDepth() - e2.GetRenderDepth()
  8.         End Function
  9.  
  10. and each tile/item:
  11.         Method GetRenderDepth:int()
  12.                 'when using 1.0 * height, then a very high item on 1,1 will get
  13.                 'drawn _after a low item on 1,2
  14.                 return area.GetX() + area.GetY() + 0.01 * area.GetH()
  15.         End Method
  16.  

Dunno why I added the height - must have had a reason for it.

GetX + GetY() because I had the position in a "2d top view grid" which then gets projected to isometric later.


bye
Ron
Title: Re: testing something new...
Post by: iWasAdam on October 30, 2020, 11:42:05
Not sure if that helps Derron.

I know that Matty is using C#. and I never use TMaps or TTileMapEntity or whatever  :o

just working on a graphics style - still at spectrum resolution, but with more colors
(https://vjointeractive.files.wordpress.com/2020/10/screenshot-2020-10-30-at-11.46.52-1.png?w=953)
Title: Re: testing something new...
Post by: Matty on October 30, 2020, 14:06:11
Just a quick point: 1. You don't have to have an array exist at a ypos if there are no sprites there, it can be null.  And 2....1080 arrays of variable length takes up tiny memory on any pc from the last 15 years....and no sort function is required...
Title: Re: testing something new...
Post by: Steve Elliott on October 30, 2020, 14:58:23
Looks great, maybe use some anti-aliasing with appropriate shades.
Title: Re: testing something new...
Post by: Derron on October 30, 2020, 16:05:44
Just a quick point: 1. You don't have to have an array exist at a ypos if there are no sprites there, it can be null.  And 2....1080 arrays of variable length takes up tiny memory on any pc from the last 15 years....and no sort function is required...

and what happens if the items move? you need to resize the array it leaves, you need to resize the one you send it to (or maybe create it there).
you also need to add / remove them when scrolling your map (so stuff comes "into display").

But do not get me wrong: your approach is fine - but in certain situations it might be doing "more" than other approaches (and vice versa). Always a kind of trade off.


bye
Ron
Title: Re: testing something new...
Post by: Matty on October 30, 2020, 16:49:01
True Derron.  And it's not difficult to apply multiple approaches per frame drawn if the scene complexity and or the render time exceeds a threshold limit.
SimplePortal 2.3.6 © 2008-2014, SimplePortal