Design paradigm... Thought?

Discussion and feedback on Construct 2

Post » Sat Jun 06, 2015 12:44 am

Okay everyone,

This is an advanced topic, but I would welcome everyone's thoughts on this. Perhaps the topic is complex but the solution is simple.

Lets say you are making a mario like game. Every character that runs around in the game is playable by the player.

Lets call these characters, "Characters". Lets also assume we are not using the platformer behavior (numerous problems with it prevent me from using it even as a base, but if one wanted to use physics the needs would be the same).

Every "Character" needs a way to track whether or not it is on the ground, on a wall, etc. as well as points to check for collisions. Every character also needs a control interface. If the player is in control, the interface will get input from the player, otherwise it gets input from the AI

On an individual level, programing a character is simple enough. Each character becomes a compound object placed in a container. Other objects are used to determine state, and just to keep things clean I will also use other objects to store certain information about the player. Since the character is wrapped up in a container, object picking is easy. You can simple say things like, every tick -> set position of foot state to maincharacter image point whatever.

But, though it may be simple enough to make this, repeating the above events (can be around 600) for every character type in the game is an obvious no go.

This is where families and functions come into play. But this is also where I can't figure out a fool proof way to hook everything up sensibly. As I said, on an individual level, containers make this a breeze. But I can't get that eeze of functioning to the family level.

On the last project I switched to unity so I could code, but I want to keep the next project in construct.


Does anyone have some good hookup ideas to get this system going without a lot of tedium and code repetition, the complete lack of OOP in construct can really bite at times and it seems to take more work to get simple oop ideas working.
Last edited by ruskul on Sat Jun 06, 2015 1:00 am, edited 1 time in total.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Sat Jun 06, 2015 12:47 am

If one could create a compound object but have contruct2 work with it as a single object... that would be nice :)

container like prefab made of objects in a family... idk
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Sat Jun 06, 2015 1:00 am

I would just have one player object (invisible) and change the character sprite that I pin to it. When they are not pinned to the Player, they are pinned to a parent controller (using UID references). The player FSM could be huge but I think this would be the easiest to implement - for me, at least! Then you won't need to worry about how to control lots of different objects, each with platform behavior etc; max speeds / jump powers all contained in an array, loaded from csv for ease. If you're not using spriter, put the characters in a family and control animations that way.

I think this is what I would do, at least to start...

This is a concept I had a while ago, but I got distracted :).
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Sat Jun 06, 2015 1:21 am

@colludium

Just to clarify, when you say pin, you are not meaning the "pin behavior" but rather the use of UIDs to stick where it belongs?

So instead of having families, you simply create a single character object (compound contained in a container). You then just stick the appropriate sprite to it based on what it is? What is csv?

Lastly if it is just a single character, it seems like it would be rubbish trying to figure what to do for the character laws (how fast to deccelerate, maxspeed, and so on)

For example... (burried in the fsm): Assume the player is in the air and the controller has indicated right.

velocity X += Airacceleration * dt.

But how do I know what air acceleration to use? If I was a pikachu it should be higher than a geodude.
then you would need some variable on the character that is Character type, and then you have tone of repetitive branching ifs:

if Geodude AirAcceleration = 20;
if Pick'a'Chu AirAcceleration = 10,000,000;
continued for 100s more...

velocity += Airacceleration * dt

edit

or, on start up you load the character laws from a xml file Character.AirAcceleration = xml file "characterName" AirAcceleration.

Does this make sense, or am I missing something
Last edited by ruskul on Sat Jun 06, 2015 1:32 am, edited 1 time in total.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Sat Jun 06, 2015 1:24 am

@Colludium "comma seperated values" , excel

I think @rexrainbow plugins should be added to construct. Officially bought and added. His expertise has been invaluable.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Sat Jun 06, 2015 1:36 am

ruskul wrote:I think @rexrainbow plugins should be added to construct. Officially bought and added. His expertise has been invaluable.


Yes indeed. C2 is largely devoid of usefulness without them!! I'm just putting together a quick example of what I mean in my explanation above - I'm going to ditch the csv import for now, but hopefully you'll get the idea. I'm not saying it'll be pretty, or even the best way to do it, but it's how I would probably start.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Sat Jun 06, 2015 1:52 am

ruskul wrote:I think @rexrainbow plugins should be added to construct. Officially bought and added. His expertise has been invaluable.


+1000.

Speaking of rex: http://c2rexplugins.weebly.com/rex_ginstgroup.html
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Sat Jun 06, 2015 2:15 am

Here you go - a very simple character swap platform demo link to capx. It's not pretty, but it's a simple way to inherit the platform perf of the next character. I hope it helps!
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,230
Reputation: 44,892

Post » Sat Jun 06, 2015 6:34 pm

@TiAm - nice, that is pretty sweet
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Sat Jun 06, 2015 7:04 pm

@Colludium - cool thanks for the capx. That is a neat way of handling that stuffs. Perhaps I am not seeing beyond the first order application of this but my primary concern is tied to the inability to use the platformer behavior. In order to recreate the behavior on your own, you need compound objects, and making those compound objects abstract so that anything can use them is my primary concern.

Does this make sense?

Let me see if I can fish out a capx that explains it.... well... I can't actually use my capx (Not willing to share at this point)

Basically, To keep it simple I'll pretend characterManagers, and characterColliders, are the only objects that make up the compound object.

There is two families. Managers and colliders. When a manager is created, it creates 4 colliders, and stores the uid of each. The biggest problem is actually to do with creating an object and immediately getting its uid. I had to create an object and its components and then hook it up the next fram by testing for overlaps. This is not ideal if two objects spawn on each other to start out...
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests