It's currently fine for tiles and layers, the various layers and tiles can manipulated by Lua, FPS is pretty good.
But this new rendering method isn't going to work with the current code base - so I need to rewrite how entities (creatures) are handled. That's what I'm doing now, it's getting there though I think afterwards it will need some "sleekening".
Hopefully they'll be walking around by the end of this weekend.
It's sooo humid here at the moment :P
And now for a random text file from my desktop beating out some of the issues I was having.
Recently I've been playing with Lua again, I'm still working on getting my map rendering stuff very solid before I plug it into EINFALL. I want to get it in there and not have to mess with it again :D
Anyway my Lua problem goes something like this-
=Lua Question=
Let's say I have a Class Person, then I have several instances p1, p2, p3
Person has a moveto(x,y) command
I want a script inside each person that uses the moveto command local to the particular instance of the class - what's the best way to do this?
(What do I mean local to a particular instance of the class? Well let's say I have a script and it's shared by p1, p2 and p3. When "moveto" is called in the script it should move the object that called it)
=Answer=
The one way that springs to mind right now is to pull the class object (p1 p2, or p3) into the Lua script so it knows what is currently calling it.
Therefore we can create a Lua global:
_FocusedPerson = ?;
and create the moveto(x,y) command in lua
moveto(x,y)
_FocusedPerson.MoveTo(x,y); -- move to here is called a C# function in Person
end
Then in the C# person class have.
class Person
{
public void ExecuteScript(Lua lua)
{
lua[_FocusedPerson] = this;
lua.DoString(script);
}
public void MoveTo(x, y)
{
...
}
}
=Alternative Answer=
Handle the specific object instances seperately in Lua. (not something I'm going to be doing)
=Thoughts about Entities on Tile Maps=
Where do we put them?
I think this is the big question. Where do we put the entities?
1. Game.AllTheEntities[0] = Bob?
2. Game.Map[0].MapEntities[0] = Bob?
3. Game.Map[0].Tiles[0,0].Entity = Bob?
These are the three main places that jump out at me. Game in my opinion is too high level and too messy.
1 - It's harder to not process and not render the entites you don't need to.
2 - I think I'm choosing something like this.
3 - I can't do multi-tile characters!
I think it depends on what your programming.
(Note I've currently decided to do option 1 :0, TileMap's getting to croweded and "coupled")
=Entity Movement=
Entites should stand on grass, covered with flowers. But they should stand behind leafy foliage.
Tricksy. Let's say
[0,0]grass = layer 0
[0,0]flowers = layer 1
[0,1]leaf foilage = layer 1
If we walked from 0,0 to 0,1 we can't leave the entity on the same layer or we'll be standing on top of the leafy foilage - that wouldn't look nice!
Oh dear we can't do the simple solution - an entity can't be merely assigned a layer and then left to get on with it. Everytime the player moves from tile to tile - he needs to be inserted into the scenery according to a heurisitic.
All layers need an extra value that I'm going to call hangRank, the hangingRank determines whether a tile should hang over the player.
A tree trunks hang rank would be 0, as would grass and all that.
The leafy foliage hangrank would be 1.
Each time the player moves we check the currect tiles hangRank and make sure it matches with the next movements hangRank. We can then render by hangrank not by layer. Yay.
So I'm going to have entites and then make hangRank stuff works correctly.
=A little later=
Wait that's far far to complicated.
Instead I'll keep the current layer system but every say 10 layers I'll call that a "hard layer" one that players might stand on, object might sit on.
Then the main render loop will look a little like:
for(int i = 0; i < layerMax; i++)
{
int hardLayer = 0;
foreach(Texture t in LayerTextures)
{
RenderLayer(i, t);
}
if(layer == (hardLayer * hardLayerSize) - 1)
{
foreach(Texture t in entityTextures)
{
RenderEntities(i, t);
}
hardLayer++;
}
}
=Z-fighting=
Now for a vaguely unrelated topic (this isn't Z-fighting in the floating point 3D graphics problem sense)
Let's say we have a building, let's say a tree grows behind the building. The tree's leafy layers should be shoved behind the building.
TTT
+---T-+
| | Not this
| |
+-----+
TTT
+-----+
| | But this
| |
+-----+
Yes, I know, I'm probably not going to have growing trees, but I do intend to have building construction - I know biting off, chewing more than, and all that. Anyway here's the solution as I see it.
I want a third type of tile, or possible addition to the normal tile, IConstruction, which means it's grouped with other tiles.
The Y-Line of the wall / buidling is the highest (nearest bottom of the screen) tiles Y position. The trees Y line is the same.
So the trees Y-Line is going to be the bottom of the trunk, let's say the tree's trunk is at 3,3. Then the house back wall's lowest line is 3,4, the trunk and all other parts of the tree must make sure their layers are lower than the wall.
..and that's the end of one of my note files.