Best method for dynamic tilable art?
by Adam McDonald · in Torque Game Builder · 12/27/2012 (2:04 pm) · 1 replies
I'm working on a 2D platformer in which objects in the world change appearance frequently. This is crucial to the gameplay:
- Character changes colour.
- Objects in the world remain their regular colour, but interact with the character differently.
- Objects change in appearance slightly to reflect how they interact with the character (based on a colour wheel - I'd go into detail, but it's not all relevant).
I have been using scene objects as "tiles" (or "blocks", as I refer to them in my code), which was fine when I was first starting out... but now that my rooms are getting bigger, performance is taking a HUGE hit. I tried grouping the objects and it seemed to help a little bit, but not enough to convince me this is the most efficient way to do this.
There are 9 types of blocks for 6 different colours, each having its own class, that all have 4 different states. There are some objects in the game made up of hundreds of these blocks.
Here's an example of the code for the Orange Bottom Left block:
Is there a way I could do this using the tile editor? I'm a little bit hesitant to do custom tile sheets for each version of each screen, or to use the same code but use larger custom-drawn images. I'd prefer to keep a modular method, if possible.
If you're having trouble picturing what exactly I'm trying to achieve, here are screenshots showing the difference between when the character is yellow and when the character is green. As you can see, the objects in the game indicate how you can interact with them (checker - pass through, rubbery - bounce off, brick - solid, flat colour - sticky).
- Character changes colour.
- Objects in the world remain their regular colour, but interact with the character differently.
- Objects change in appearance slightly to reflect how they interact with the character (based on a colour wheel - I'd go into detail, but it's not all relevant).
I have been using scene objects as "tiles" (or "blocks", as I refer to them in my code), which was fine when I was first starting out... but now that my rooms are getting bigger, performance is taking a HUGE hit. I tried grouping the objects and it seemed to help a little bit, but not enough to convince me this is the most efficient way to do this.
There are 9 types of blocks for 6 different colours, each having its own class, that all have 4 different states. There are some objects in the game made up of hundreds of these blocks.
Here's an example of the code for the Orange Bottom Left block:
function orangeBlockBL::onLevelLoaded(%this, %scenegraph)
{
%this.enableUpdateCallback();
}
function orangeBlockBL::onUpdate(%this)
{
%this.setCurrentAnimation();
}
function orangeBlockBL::setCurrentAnimation(%this)
{
if ($colour == 1)
{
%this.playAnimation(solid_orangeBL);
}
if ($colour == 2)
{
%this.playAnimation(stick_orange);
}
if ($colour == 3)
{
%this.playAnimation(solid_orangeBL);
}
if ($colour == 4)
{
%this.playAnimation(pass_orange);
}
if ($colour == 5)
{
%this.playAnimation(repel_orangeBL);
}
if ($colour == 6)
{
%this.playAnimation(pass_orange);
}
}Is there a way I could do this using the tile editor? I'm a little bit hesitant to do custom tile sheets for each version of each screen, or to use the same code but use larger custom-drawn images. I'd prefer to keep a modular method, if possible.
If you're having trouble picturing what exactly I'm trying to achieve, here are screenshots showing the difference between when the character is yellow and when the character is green. As you can see, the objects in the game indicate how you can interact with them (checker - pass through, rubbery - bounce off, brick - solid, flat colour - sticky).
About the author
Torque Owner Adam McDonald