testing something new...

Started by iWasAdam, October 27, 2020, 07:38:58

Previous topic - Next topic

iWasAdam

I thought I would pop back to isometric and build a new engine - this time with nightshade/gunfright in mind...

the base res is 256x192 Spectrum - but it can do other res and hi-res graphics too

I should add that this is BlitzNG

Xerra

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.
M2 Pro Mac mini - 16GB 512 SSD
ACER Nitro 5 15.6" Gaming Laptop - Intel® Core™ i7, RTX 3050, 1 TB SSD
Vic 20 - 3.5k 1mhz 6502

Latest game - https://xerra.itch.io/Gridrunner
Blog: http://xerra.co.uk
Itch.IO: https://xerra.itch.io/

Steve Elliott

Warming up for the arrival of your Spectrum Next Adam?  Marvellous.  You'll sell loads.   :D
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

3DzForMe

@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.
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

iWasAdam

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

Matty

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.

iWasAdam

good call matty - a slightly different approach :)

Derron

#7
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) Select

Function _SortEntitiesByZ:int(o1:object, o2:object)
local e1:TTileMapEntity = TTileMapEntity(o1)
local e2:TTileMapEntity = TTileMapEntity(o2)
if not e1 then return 1
if not e2 then return -1

return e1.GetRenderDepth() - e2.GetRenderDepth()
End Function

and each tile/item:
Method GetRenderDepth:int()
'when using 1.0 * height, then a very high item on 1,1 will get
'drawn _after a low item on 1,2
return area.GetX() + area.GetY() + 0.01 * area.GetH()
End Method


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

iWasAdam

#8
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

Matty

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...

Steve Elliott

Looks great, maybe use some anti-aliasing with appropriate shades.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Derron

Quote from: 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...

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

Matty

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.