Page 1 of 1

Dynamic tile rendering question

PostPosted: Sat Jul 04, 2015 5:09 pm
by tzoli
Hi guys!

It's been a long time since I posted something here. :)
I have a question which I couldn't figure out, no matter how hard I was thinking about it. The current system of Pixelcraft is kinda lame, so I thought I would recreate it with a friendlier user interface and a cleaner code. One thing that I really want to change is the map system. I want it to be fluid (when passing from one 'map' (chunk) to another just like in Terraria, or any other game, the camera follows the character and you always see what is in front of you.
At one of my topics someone posted a system like that but I can't find it anymore...

If you have any ideas or complete system, I would be grateful if you would share it with me.
Thanks! :)

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 10:01 am
by bat78
There are not much users available or at least not enough to answer on time.

So you better be a little more specific. Surely, I can create you or tell you how you can create any system all by yourself as long as I know exactly do you mind.
And in that case - I don't.
I haven't played Terraria, neither your Pixelcraft.

Why don't you provide a link to Pixelcraft so I can try it ( I don't have time to risk by searching it )
and a video of a game that implements what you call "Dynamic tile rendering".. or a wikipedia page maybe.

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 11:12 am
by tzoli
Imagine any platformer game. The camera follows the character seamlessly. I want that but in my case the map is built up by blocks (a lot of them) just like in Mincraft or my game Pixelcraft: http://game-editor.com/forum/viewtopic.php?f=6&t=11881&hilit=pixelcraft.
In my game if you leave a "chunk" you continue in an other but the camera is fixed. I want the camera to follow the player.

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 11:20 am
by bat78
tzoli wrote:Imagine any platformer game. The camera follows the character seamlessly. I want that but in my case the map is built up by blocks (a lot of them) just like in Mincraft or my game Pixelcraft: http://game-editor.com/forum/viewtopic.php?f=6&t=11881&hilit=pixelcraft.
In my game if you leave a "chunk" you continue in an other but the camera is fixed. I want the camera to follow the player.


If this is what I think it is.. then why don't you just set the camera to follow the player.
For instance, setting view's parent to be the player entity.

If you want the camera to follow player entity conditionally (for instance when payer entity locates after the second half of the screen)
you can set the view's parent by virtue of the function ChangeParent

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 12:17 pm
by tzoli
The problem is not the camera following the player but the map rendering in front of him and optionally (for optimization) disappearing behind him.

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 12:45 pm
by bat78
tzoli wrote:The problem is not the camera following the player but the map rendering in front of him and optionally (for optimization) disappearing behind him.


For dynamically generating terrain you must render those CHUNKS in real time.
Which means keeping track of offsets and using CreateActor when needed.
Minecraft actually loads terrain just like it is in your Pixelcraft btw.

For best performance I would re-render terrain only in the scope of the camera. One vertical of blocks at time.

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 5:14 pm
by bat78
There, I just created this.
video.zip
(478.53 KiB) Downloaded 156 times


What you see is infinite terrain of real-time generating blocks.
The entire screen is one canvas that covers the view.

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 5:21 pm
by tzoli
Yeah it is what I meant.
Could you tell me what to do, or maybe a demo, because I'm not really into canvases. I would be really grateful. :)

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 5:32 pm
by bat78
tzoli wrote:Yeah it is what I meant.
Could you tell me what to do, or maybe a demo, because I'm not really into canvases. I would be really grateful. :)


Okay I will send you this demo. This is a base system and I created it only as a question if this is what you needed.. So obviously it is far from perfect.
But I am so sure you can learn a lot from it:
merkyrial.zip
with a random name
(178.17 KiB) Downloaded 165 times

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 5:34 pm
by tzoli
bat78 wrote:Okay I will send you this demo. This is a base system and I created it only as a question if this is what you needed.. So obviously it is far from perfect.
But I am so sure you can learn a lot from it


I'm sure that I'll learn one thing or two, it doesn't matter if it's not perfect, since I only need a start and from there I will try to upgrade it.
Thank you! :D

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 6:10 pm
by bat78
There are a lot of stuff that could be optimized.
The loop could be omitted entirely.

Re: Dynamic tile rendering question

PostPosted: Sun Jul 05, 2015 11:50 pm
by Zivouhr
Interesting approach with the canvas. I'll have to take a look.

I can imagine Bat's suggestion may be more efficient than the way I made Tomb of Twelve's giant world.

With all the backgrounds on, the game would run at a crawl, but once I set Green region boxes as On/Off zones using visibility (or transparency if you wanted to test that), the game ran a lot better and faster (though laptops it tends to run slow). If I had to make the game again, I'd consider eliminating the Warp Doors, since they require the "Warp to" landscape be visible before it's warped to, otherwise, there could be a delay when it becomes visible and the character would warp into empty darkness, which is what I experienced until I triggered its visibility before the character even reaches the Warp door.

Once he left the green box (the box with the green lines that you can program functions into) zone of background 1, he'd enter a midway zone that would keep zone 1 on, but activate zone 2 before he sees background 2. Then when he entered the zone 2 activation, that would shut off zone 1 from being visible, since it was no longer in view.

Re: Dynamic tile rendering question

PostPosted: Mon Jul 06, 2015 7:50 am
by bat78
Zivouhr wrote:Interesting approach with the canvas. I'll have to take a look.

I can imagine Bat's suggestion may be more efficient than the way I made Tomb of Twelve's giant world.

May be.

Zivouhr wrote:With all the backgrounds on, the game would run at a crawl, but once I set Green region boxes as On/Off zones using visibility (or transparency if you wanted to test that), the game ran a lot better and faster (though laptops it tends to run slow). If I had to make the game again, I'd consider eliminating the Warp Doors, since they require the "Warp to" landscape be visible before it's warped to, otherwise, there could be a delay when it becomes visible and the character would warp into empty darkness, which is what I experienced until I triggered its visibility before the character even reaches the Warp door.

Once he left the green box (the box with the green lines that you can program functions into) zone of background 1, he'd enter a midway zone that would keep zone 1 on, but activate zone 2 before he sees background 2. Then when he entered the zone 2 activation, that would shut off zone 1 from being visible, since it was no longer in view.

Lol, we have the habit to talk about our own games in the other's posts.
Don't worry about fps Zivouhr. When the imminent big gE project comes out, I intend to also release wanle SCORE.