One Object Type to rule them all... or not?

Get help using Construct 2

Post » Mon Feb 02, 2015 8:38 pm

Sorry for the title but i had to do it..
By now most of you surely had to choose how to create many different enemies, characters, items, etc.
As i saw so far there's two main ways of doing it, take enemies as instance:

First Way: You create an individual "Object Type" (sprite) for each enemy. Then you play with instances of these many object types.

Second Way: You create only one general/abstract "enemy" object type and then you individualize each enemy as different animations or animation frames of this general object type.
For example, you create an Object Type "EasyEnemies". Then from animation frame 0 to 6 you add all animations of enemy "spider". From frame 7 to 10 you add all animations for enemy "skeleton" and so for.
Then you spawn instances of this single object type at the frame that reference the enemy you want to spawn.


This second way is widely used in many tutorials and examples in C2.
For certain objects/sprites, like statics scenery, looks like a good way to go. Frame 0 is a rock, frame 1 is a tree, and it's easy to reference and spawn each sprite/object like this.

But what about complex objects/sprites, like enemies, or say, 7 player's characters?
If i add all enemies sprites in a single object type i would get a very "heavy" object loaded into memory, increasing loading time and, most likely, i could just want 6 of 20 enemies encapsulated in this single object type or "animation frame"method.
For all those 20 enemies as a single object type there's also each individual animation. And fear arise...

It terrifies me to go this second way for complex objects/sprites if i have to load and keep into memory so many sprites that i could or could not need in a certain moment or level. However i keep seeing people using this method for everything, from rocks and trees to all enemies and player's characters. So i'm starting to think that i'm missing something or i'm misunderstanding something.

Sorry for the wall of text but this is a major grey area that i never solved and never get enough info to feel safe using it freely.

Tell me your story, it will help me a lot! One Object type for many "enemies" or better keep'em separated each in it own object type and start developing the damn game?

Thanks dudes (and dudas).
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Mon Feb 02, 2015 8:55 pm

for enemies i would recommend useing a family and make all enemie style a own sprite.
You can than make every option to the family and it will change for all enemies, you can set the strenght of an enemy just in it instances variables.

adding a animation with different images just makes sense in my opinon if you have for an example the same rock with different colors from purple to yellow or something.
Its very easy to work with but makes your sprite senseless big if you use 1 sprite for everything and will slow your game down.
I used this methode in a game where something just change its skin if the player gets leveled up, so i packed every skin in 1 sprite and made "set frame to level", its very lazy and makes my code smaller. But i know that it wound effect a lot in my game that i am makeing right now because it has no moveing elements and will hopefully dont make any lags.
Read this:
yeah, i really like to say that you should "Read this:"
B
12
S
5
Posts: 138
Reputation: 1,490

Post » Tue Feb 03, 2015 3:16 am

Thanks @EyeForcz - So it's not that crazy to keep using a 1:1 enemy:object type at least for enemies and complex multi-animation heavy sprites. I'm ok using one object type for all, lets say, 1 frame static colliders. Each frame being a different object (tree, rock, pillar, etc).

And for more complex objects i keep them each in it's own object type, maybe using the frame technique for evolved forms of the same sprite, like weak spider (green), strong spider (red). Being from frame 0 to 10 reserved to the green weak spider and from 11 to 21 reseved to the red spider (evolution through instance variables/array).

Someone else found that using a single big object type (sprite) worth all possible dangers against using individual object types per sprite? I'm spinning in my axis for more stories!!
Wicked combinations of families, arrays, containers, whatever are welcome.
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Wed Feb 04, 2015 12:13 pm

Bumping for more opinions...
One big "Sprite" Object Type as container of many enemies/characters (with its own animations for each) accessed each by animation frames references or keep'em each in it own Object Type and don't call for unnecesary problems?

I see this one object type for all method, for example, in Kyatric's "myMiniRpg" capx example and many other popular examples and tutorials. If they choose that method, maybe there's a reason why... or maybe was chosen because those examples were just quick examples without enough enemy types/animations... I don't know..

Please, if you evere used a big single Sprite Object Type containing all or many enemy types (spiders, skeletons, werewolves, etc) and found it worth it agains using a single object for each enemy please tell your experience. (Enemies just as an example).

Thanks!
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Wed Feb 18, 2015 6:02 am

I'm kind of dying here...
Question:
There's a clean way to manage an array without using the "animation frame" or "animation state" method as a reference to the array index?
I'm struggling because that method doesn't scale well when there's many, say, monsters stored in the array, each with it's own set of animations.
It force me to keep a single big "object type" as a container of all monsters with all their animations in memory. I use them all or not (monsters is just an example of something stored in the array).

I'm trying to use arrays in conjunction with a Family (monsters) or with individual object types per monster so to keep memory low and to keep animation states cleaner for each monster.

Question again:
Someone ever used another method than the commonly used "animation frame = array index"? Or ever used it with a big array of objects with many animations (for instance, 200 monsters with 4 animations states each)?

It blows my mind trying to scale Construct 2 to handle many enemies stored in an array while keeping them in their own object type.

Please help :cry: and thanks in advance!
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Wed Feb 18, 2015 8:37 am

Are you finding problems using the object-type-per-enemy method? Coupled with good use of Families I think it is easier to think about. Maybe share what you have done, at least in concept.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Feb 18, 2015 9:38 am

Could you explain why you want all your enemies grouped into the same object type? That sounds like it'd be a nightmare to code... It's much less complicated to just use multiple object types and put them all into a family.
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Wed Feb 18, 2015 8:44 pm

Hello to all.
If you look around the many tutorials and capx examples about arrays you most likely saw a method were a single sprite object loads all monsters types sprites (just an example) and use their animation frames to reference each monster that should take data from the array.

I want to avoid that method, at least, for complex objects like enemies. But all examples use this animation frame method and i get stuck eventually.

There's a popular array example made by Kyatric explaining arrays and how to loop through it (it's called MyMiniRPG.capx) and use the animation frame method.
I want to convert that example to use individual object types per monster grouped in a family (families could be avoided for now if you want) but i can't grasp the right method.

Let's say we have a 2d array of 50 monsters, X reference the index of each monster and Y reference each attribute of each monster.
Now we create each monster as a separate object type with instance variables to load and save data taken from the array (Or use a "Monsters" family instance variables).
Now imagine some kind of spawner object in the level spawning random monsters using the array data to "fill" each monster instance variables giving each one their particular attributes.
How should i proceed without looping the array using animation frames as reference? I don't supposed to know the exact x (index) position of a particular monster in the array so i have to relay on loopindex somehow.

Did you ever used arrays to load data to an object type looping the indexes without relying in the animation frame method?
I can't give a .capx file because there's nothing until you take data from the array. But below i leave Kyatric's example, if you can do the same he did but using individual object types per monster and a different looping method i will be saved. Or point me some directions and i will follow from there.

Link to Kyatric's array example:
http://www.scirra.com/forum/forum_posts.asp?TID=48528&PID=305024&title=rpg-problem#305024

Thanks folks!
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Wed Feb 18, 2015 8:54 pm

Just have an ID value for each monster type. This can be your index into an array. edit: the problem is with spawning. I guess you could 'cheat' and use the 'nickname' plugin to spawn based on monster name from the array.

edit2: try this. Without nickname plugin. Uses a Family and separate objects, with the same array and other code structure.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Feb 18, 2015 11:13 pm

Oh man, I've never seen that nickname plugin before. @Rexrainbow you're a goddam rock star
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Next

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], menos30, Moordhuis, RetroSpock, TRMG and 6 guests