How do I create a 900 block grid?

Get help using Construct 2

Post » Sat Oct 01, 2016 7:21 pm

First your random problem:

Else is a little bit tricky. The event sheet is read and each event executed in order from top to bottom, as long as the conditions match. Else means only run this if the event previously did NOT run (unless you have a series of elses, but that works as an extended if-else chain). So the way it is now, lets say your random picked 3, which would be dirt. The dirt event runs. The grass event does not run. The tree event DOES run because the grass event didn't, so it immediately covers your dirt with a tree.

To solve -
Explicitly define 4<=rng10<=6 in event 7
Or Add Else to event 6 as well, to make it a proper if-else chain.

Your terrain manipulation problem is similar. When you touch grass, event 12 runs and creates a tree. Then event 13 runs because a tree is now there where you touched, and then turns the tree to dirt. This is another bit of learning curve for the event sheet system because Triggers (the green arrow) don't follow the normal flow of top to bottom, and will run whenever the trigger happens. Thus you can't use Else with a trigger.

This is a little troubling because when you turn one object into another, triggers will run on the new object and I can't think of a solution off the top of my head. The solution would be to use another system/approach, which I hate to bring up because you would have to mostly start over, but here goes. This is how I would normally approach a project of this type. Instead of using a unique object per tile type...

1. (Better) Put all your tiles into one object called "Tile", and control look and properties by animation frame and instance variables. For example On Clicked Tile, with subevents If animation frame=1, do something, else if animation frame=2, do something ect. On generation, usually you want to save the tile x/y position as instance variables, and any other properties/identification you like. The type of tile is determined by the animation frame number.

2. (Best) Learn/use the tilemap object and build a tilemap system. They are made for tile based games. https://www.scirra.com/manual/172/tilemap
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Sat Oct 01, 2016 8:00 pm

I thought of a way for you to continue with multiple objects - you'll use on touch start or on tap gesture as your trigger, so there is only one event that triggers on touch, like so - Image
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Sat Oct 01, 2016 8:01 pm

Yea, I was thinking there would be a better technique than what I was doing.

And that else, although makes sense when you put it that way, it's not how other languages I know use it.

I'll chalk that one up to learning and watch tutorials on tile mapping. Although the game isn't fully formed in my head just yet, I think the direction I'm going will turn into something fruitful.

I'm sure I'll ask for more assistance in the future. Thanks.

P.S. the total number of sprites in the grid was 1952, not 900... kinda funny.
B
7
S
2
Posts: 28
Reputation: 483

Post » Sat Oct 01, 2016 8:04 pm

oosyrag wrote:I thought of a way for you to continue with multiple objects - you'll use on touch start or on tap gesture as your trigger, so there is only one event that triggers on touch, like so - Image


I'm going to assume the best way is to still do the tile mapping. I'd rather do it the best way possible than to work around with what I have.
B
7
S
2
Posts: 28
Reputation: 483

Post » Sat Oct 01, 2016 8:17 pm

Else in C2 is definitely one of the special cases and different than other programming. Not sure if you found this page - https://www.scirra.com/tutorials/292/gu ... t-features

Additional tips and tricks - Looking in the debug to see if things are expected is always a good idea - in your case you're creating way more sprites than expected, probably because a lot of them were overlapping.

A related trick is to set sprites to 50% opacity when working. I do this for almost all my projects, as it makes it very easy to spot mistakes as opposed to digging through the debug.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests