The Musings of a Non-Programmer

Discussion and feedback on Construct 2

Post » Mon Jul 25, 2011 6:25 pm

I'm an artist. Lemme just throw that out there first and foremost. I don't code, and I very nearly failed the one Computer Science course I attempted to take (to be fair, that was in-part due to the teacher).

Still, I'm trying out Construct to see if I *can* do this at all.

The first thing I did was go through the Ghost Shooter tutorial, and that was relatively helpful, but left a lot of things open.

Currently, I'm trying to take baby steps through a project of mine (a mashup of Advance Wars and Nethack, complete with procedural level generation). Figuring that terrain generation would be the hardest thing to achieve for me at first, I went ahead and got started. I want to use the Diamond-Square algorithm for creating my maps, but I don't know enough about how to handle arrays in C2 in order to even get started.

So here's question #1 (of many, many to come): how on Earth do I fill an array with variables? Does it start filled with 0? And how do I key each number to be relative to a sprite?

Here's my barren and pathetic excuse for a capx. It's got my sprites, though, and the little dog from one of the Zelda games acting as my camera for viewing the map (once I can manage to get it generating). Based on the algorithm, I was attempting to set each corner of Map to 4, and then I was going to set up something to 1). execute the algorithm itself, and 2). set each element in the array to translate to a sprite somehow (0 being water, 1 being sand, 2 being grass, and 3 being mountains). I'm starting simple, like I said. It'll look nicer and be much more complex later on, but for now I can barely get started.

I really appreciate you guys bearing with me on this (those of you who read through my whining). Thanks a lot.
B
2
G
2
Posts: 12
Reputation: 674

Post » Mon Jul 25, 2011 6:55 pm

Hey, welcome to the forum :)

[QUOTE=Olothontor]Figuring that terrain generation would be the hardest thing to achieve for me at first, I went ahead and got started.[/quote]
If you're not familiar with how events work, procedural generation is kind of jumping in to the deep end. I think it's best to start with simple projects and build your way up from there, otherwise you will quickly get stuck!

[quote]So here's question #1 (of many, many to come): how on Earth do I fill an array with variables?[/quote]
It all comes down to setting up some events that call the 'Set at XY' action (for a 2D grid, anyway).

[quote]Does it start filled with 0?[/quote]
Yep.

[quote]And how do I key each number to be relative to a sprite?[/quote]
Do you mean actually creating the sprites from the data in the array? A 'For Each Element' (on XY axes) event should do that. Each iteration compare the current number in the array, and create a sprite based on that number. Subevents are good there.

I was going to explain this, but I just added it in to your capx. Try this: http://dl.dropbox.com/u/15217362/tileengine.capx

You should be careful about creating lots of sprites, though. Having too many sprites can slow down the game a lot. I'd recommend waiting until the next release or two when we add 'snap to grid', then maybe put it together in the layout editor, using tiled backgrounds wherever possible for large areas of sprites. Otherwise, the sheer sprite count could slow down performance.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Jul 25, 2011 7:03 pm

Thanks, for both the welcome and the advice.

I think I kinda see how I can do this now... but as I said, there are undoubtedly more questions to come. Again, thank you for bearing with me.

The edit to my capx was very helpful.

I'll post here again when I run into another wall.

EDIT: How did you create subevents underneath of the subevent? Under the For Each loop of the Array you made, there are more subevents that handle the actual placement of tiles, but I can't see how you did that.

EDIT2: I found one way I could do it, although I'm sure there's an easier way (create the subevent and then just drag it over to the right until the black line becomes an arrow).Olothontor2011-07-25 19:20:15
B
2
G
2
Posts: 12
Reputation: 674

Post » Mon Jul 25, 2011 7:27 pm

Select a sub-event, right click and you can "Add sub-event". (or "Add blank sub-event")

If you go for some "moving" of block in the sub-levels (if you know what I mean):
Click on a block and keep your left button down.
Move your cursor over the white part (stating the actual event) of an event block.
A black line will appear with an arrow shape at one of its end under the event you're overing, meaning that releasing the left button will move the selected block as a sub-event of the overed event. (ouch, simple concept, hard to put in words ^^)

Edit: Ninja'dKyatric2011-07-25 19:30:03
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Jul 25, 2011 7:39 pm

Hehe, thanks Kyatric. Good to know.

Alright, so I've got a simple random generator going... or I would, at least, if I didn't get this error: "Assertion failure: No default instance when creating object."

As with most errors, it's *just* vague enough to let me miss what it's trying to tell me. Not sure what's going on.

Capx.
B
2
G
2
Posts: 12
Reputation: 674

Post » Mon Jul 25, 2011 7:54 pm

The errors tell you that you are trying to create an object, but this object has no default instance (meaning, it doesn't even exist anywhere on your layout).

And it is true. The sprite in the left corner with the other terrain sprites is nammed "Sprite5".
In the right window, click the tab "Projects" and check the folder "Object". It has many more objects than it appears.

Two solutions : either change the code when Map.CurValue is 1 to create a "Sprite5" object.
Or (and advised) delete every unused object from the tab Project (including the object Sand), then rename Sprite5 to Sand and complete your code (the line at Map.CurValue = 1 should have disapeared). Simply select the line above (creating water) hold ctrl and drag/drop to copy it.
This should do the trick.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Jul 25, 2011 8:16 pm

It works!



Step 2: Actually plug in the algorithm (not sure if I want Perlin noise or the Diamond-Square yet).
Step 3: Add transition tiles to make it more natural.
Step 4: ???
Step 5: profit.

Thank you, Kyatric. I've cleaned up the objects, the only things left are the things that I'm actually using.
B
2
G
2
Posts: 12
Reputation: 674

Post » Mon Jul 25, 2011 8:38 pm

- snip -

Scratch all of that, I found an Action that System can perform that rounds numbers up. Now, to figure out how to translate the formula into terms Construct can translate...Olothontor2011-07-25 21:42:13
B
2
G
2
Posts: 12
Reputation: 674

Post » Mon Jul 25, 2011 9:41 pm

Well the function random(x,y) returns decimal numbers.

Ceil() rounds number up to an integer, floor() rounds number down to an integer and round() rounds to the nearest integer.

For example:
random(0,3) will return a decimal.
round(random(0,3)) will return an integer.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Jul 25, 2011 9:50 pm

Awesome, thanks.

Yet another question: is there a way to create a seeded random number generator?
B
2
G
2
Posts: 12
Reputation: 674

Next

Return to Construct 2 General

Who is online

Users browsing this forum: BackendFreak, blackant, Mirlas, shinichild, TheRealDannyyy and 8 guests