2d coordinate system

Get help using Construct 2

Post » Tue Nov 18, 2014 8:32 pm

Try using the On Create trigger of the planet object to set your values.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Tue Nov 18, 2014 8:52 pm

Well it really has to be predefined. The values should be like following,

<PlanetName> This is predefined (Char Variable)
<PlanetMass> This is Predefined (Long Variable)
<PlanetX> This can be random(x) on creation of object (Integer)
<PlanetY> This can be random(x) on creation of object (Integer)

So basically a couple things need to be predefined and some items can be random on creation or randomly predefined.

Hope this explains it a little better and I really appreciate the help. I understand it can be hard to understand what someone is asking just through writing.
B
9
S
1
Posts: 56
Reputation: 576

Post » Tue Nov 18, 2014 9:57 pm

Without a definite idea of what you are trying to achieve all we can do is just keep trying to gently poke you in the right direction.

For example if you have a set number of planets (i.e always 10 & always the same planets) you can fill in all the instance variables in the layout editor. Then you could randomize the X&Y at the start of layout.

instancevariables.capx

In the example the planets can overlap but it's just to show you that you could randomize X&Y even with planets predefined in the layout editor.

If you're going to have random numbers of planets (possibly moons) then there are multiple ways of storing their data and populating the random planets at runtime. You could randomize them completely or randomly choose a planet from a list of predefined planets.

If that's where you're heading then just post here and I'm sure you'll find the help you need.
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Tue Nov 18, 2014 10:04 pm

I think you're complicating things. I also come from an OO background. C2 does have some OO concepts. Consider the following:

Object Types:
An Object Type is kind of like a class, with class variables (called instance variables in C2).
Setting 'instance variable' values on an Object Type (via the properties in the editor or programatically) sets them for new, spawned Object instances.
You cannot have an Object Type 'inherit' another.

Objects:
An Object is an 'instance' of an Object Type.
Setting 'instance variable' values on an Object instance (via the properties in the editor or programatically) sets them for just that Object instance, overriding the Object Type.

Families:
A Family is kind of like an abstract class, with class variables (called Family instance variables).
Object Types can 'inherit' from these by placing the Object Type into a Family (or more than one Family, for 'multiple inheritance').
You cannot have an Family 'inherit' another (cannot place a Family in a Family). So 'inheritance' is only one level deep.
Setting 'Family instance variable' values on an Object (via the properties in the editor or programatically) sets them for just that Object instance, overriding the Family.

Note: Effects and Behaviours work similarly to Instance variables on the above.

Apologies for any mistakes in the above, which I'm sure I'll be corrected on :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Nov 18, 2014 10:10 pm

Ya I see what you are saying but to do it that way is possibly not doable in larger universe.

Say for example you have a playfield, x=0, y=y to x=5000, y=5000. A fairly large playfield.
Now you like to have 200 planets. You want pre-defined names, so you need a list of 200 names.
You want a random placement of the planets through plx=(1+random(5000)) and ply=1+random(5000)

Now if we do like the above example you would have to make a sprite object, 200 of them and
fit them in on the screen just so you can pre-define some values to them.

This is where C++ came in handy with its classes, vectors and arrays.

Or what do you think?
B
9
S
1
Posts: 56
Reputation: 576

Post » Tue Nov 18, 2014 11:12 pm

Now I'm starting to have fun a bit of basic Procedural Generation :)

For 200 planets you still only need 1 sprite. You can use multiple frames & set a width dynamically.

200planets.capx

Planets can still overlap in the example but that can be sorted at a later date. The layout is 5000x5000.

You say you'd need 200 predefined names which is true but wouldn't the same be true in C? I put a very basic 3 syllable name generator into the example, you'll get duplicate names & unpronounceable names but again that can be solved with a more robust (i.e not slapped together in a few minutes) name generator.

There are is no planet information in the example because I don't know if we are now in the realms of ProcGen planets, predefined planets or somewhere in between.

I hope we're getting somewhere slowly but I love this sort of stuff and have wanted to make something like this in the past.

If you have any more info post it and we'll see where the example goes :)
You do not have the required permissions to view the files attached to this post.
Last edited by Minor on Tue Nov 18, 2014 11:22 pm, edited 1 time in total.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Tue Nov 18, 2014 11:18 pm

You can have a very large layout, which is much bigger than the viewable screen (viewport, or 'window size' in project properties) and generate your planets at random x,y locations at startup. Only onscreen objects (in the viewport) are rendered so its feasible. Or you could have multiple 'zones/levels' (layouts) to break it up, and switch between them during the game. Is that what you're after? You can store your names (or other level data) in JSON text files and load them dynamically. I have not done such large layouts so I'm sure others will chime in.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Nov 19, 2014 12:27 pm

Yes Minor you hit the nail on the head or however you frase it, LOL.

Your example explains a lot of what I am trying to do. Think of the old Amiga game ELITE, <HTML>http://en.wikipedia.org/wiki/Elite_(video_game)</HTML> but in a 2D environment with a LOT more planetary data.
Basically it's Elite on steroids. I started making this in C a few years back but got derailed with RL issues and lost my HDD in a crash so all my files disappeared and I lost interest. But, now with Construct I figured I'd give it another try. I thought it was going to be easy with the knowledge I have of C but that was NOT the case as I have discovered lol.

Anyways yes your example is fairly easy to implement bits and pieces into my game. As a matter of fact it's AMAZING how much you can do with so little in Construct when you really know it like you do.

Thx again and look for more questions in the near future from me hahaha.

Thx guys!
B
9
S
1
Posts: 56
Reputation: 576

Previous

Return to How do I....?

Who is online

Users browsing this forum: amazingdream, Exabot [Bot], lordsas, tarek2 and 59 guests