Some technical questions

Discussion and feedback on Construct 2

Post » Mon May 11, 2015 2:24 pm

Hi there,

@Ashley I have few technical questions I'm hoping someone could answer for me:

- What's best way to create an event sequencing? I tried setting a variable number, and then top condition for each sequence, and at the bottom, I had plain sub event adding 1 to sequencing variable, but seems like not all events are finished within same tick and so it ended up braking.
Therefore: - Which of the following two actions is being completed the same tick as the action triggered and which one doesn't: Create object or Spawn object? Also Id like to know which other actions are being completed on the next tick?
- Another question about sequencing is when the variable is being changed trough other set of events, it's not working, and I don't know why.
Examples
Not working: Every tick: add 1 to Variable, Variable grater then 6, set Variable to 0. If variable = 0, player is not moving along path, has player in sight: find path.
Working: Every 0.0128 sec, player is not moving along path, has player in sight: find path.

- When "repeat" and it has variable to check then add to the same variable, is it only checking that variable on each repeat or only on start of the loop?
- What's best use of "While"?

Thanks!
M
Last edited by megatronx on Mon May 11, 2015 4:32 pm, edited 1 time in total.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
86
S
28
G
21
Posts: 1,976
Reputation: 19,306

Post » Mon May 11, 2015 2:51 pm

the way I understand it is each tick (@ 60fps) has the potential to be executed up to 16ms after one another. But it's usually a lot less. the actual time varies from program to program and computer to computer.

If you add 1 to a variable every tick, by the time you get to 6... approx 0.1 seconds of wall clock time will have passed. (this will vary a tad). You could use dt to make it more consistent between computers.

if you are changing things in subevents I think they are done at the "end of the sheet", so you have to wait for the next tick for the results to update in the next top level event. Maybe this is causing a problem for you?

EDIT: meant to say tick instead of Action on the first line
Last edited by jobel on Mon May 11, 2015 5:18 pm, edited 1 time in total.
B
88
S
29
G
14
Posts: 1,158
Reputation: 15,011

Post » Mon May 11, 2015 2:55 pm

megatronx wrote:- When "repeat" and it has variable to check then add to the same variable, is it only checking that variable on each repeat or only on start of the loop?


I think a Repeat only happens once in a tick. I think it's only a shortcut instead of you having to copy & paste the actions you want repeated.
B
88
S
29
G
14
Posts: 1,158
Reputation: 15,011

Post » Mon May 11, 2015 3:03 pm

Apart from wait, create object, and async. Actions , everything is done in order from top to bottom, an action is over before the next one.

every tick add 1 to variable
Variable greater than 6, set it to 0 . [...]
If variable equal 0, [...] find path

Be sure that the event to set it to 0 does not occur right before checking it, or more simply, use a time difference, it is more adapted to your use.

create object and spawn another object are not done before the next top level event (aka the next event that is not a sub event of another one).

For every async conditions, there is a trigger associated with it (local storage, ajax, etc..)

If you check a value and do a loop, just see the order you did it, the loop comes first? Then it will check the value everytime, it is after? Then the oppositz, the value is checked before doing the loop.

Sequencing can be problematic since the time between two events can vary (heck even if it was not the case, switching to a display of 120Hz would make it twice as short as a 60Hz display).

Never used while loops as I prefer to use for loops, but maybe they are more flexible, be sure that it will not be endless.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Mon May 11, 2015 4:54 pm

@jobel @Aphrodite

Thx for clarifying, though I still don't understand if created object through create or spawn is calculated same tick of not? I'm working on randomly generated map, and this is somewhat crucial i think as currently I'm getting some minor annoying bugs.

Ps. The prototype version worked flawlessly, but the "clean and optimised version" broked! Same with version after. IRONY!
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
86
S
28
G
21
Posts: 1,976
Reputation: 19,306

Post » Mon May 11, 2015 5:25 pm

megatronx wrote:I still don't understand if created object through create or spawn is calculated same tick of not? I'm working on randomly generated map, and this is somewhat crucial i think as currently I'm getting some minor annoying bugs.


I randomly generate the world map in my game as well. Although I only do it once at the beginning of the game. I do all the Creates/Spawns in OnStartOfLayout, then I refer to those objects in the main game loop. Do you have a similar set up?
B
88
S
29
G
14
Posts: 1,158
Reputation: 15,011

Post » Mon May 11, 2015 5:30 pm

Just a quick contribution - going back to the initial post, the problem seems to be about managing states and building a sequene of events i.e. logic blocks ; it sounds to be a perfect fit for a finite state machine. Building the logic as a FSM will make it easier to isolate each logic block, author transition logic, and manage state if you need to add/remove some
Image
B
23
S
9
Posts: 237
Reputation: 2,207

Post » Mon May 11, 2015 6:15 pm

@Refeuh
I'm not really great with terminology. Atm my state machines are like that

If Var = 1 : do stuff, aad 1 to var
If Var = 2 etc.

And

Every tick add 1 to Var2
If Var2 = 1: do stuff
if Var 2 = 2, etc

Both have issues

@jobel
I tried couple of techniques. Once layout starts , I run a crawler from center of the layout. There problems with overlapping already spawned tiles, even thought they are set up correctly. Another technique was to generate floor first, then do offset calculation, and move everything so that whole map is placed tile away from 0,0. Then for each floor, i set up a value in 2d array. Then did applying of wall and other objects on to the array itself. It worked, as far as remember until something happened that made it broken and I couldn't figure out what.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
86
S
28
G
21
Posts: 1,976
Reputation: 19,306

Post » Mon May 11, 2015 6:34 pm

megatronx wrote:I tried couple of techniques. Once layout starts , I run a crawler from center of the layout. There problems with overlapping already spawned tiles, even thought they are set up correctly. Another technique was to generate floor first, then do offset calculation, and move everything so that whole map is placed tile away from 0,0. Then for each floor, i set up a value in 2d array. Then did applying of wall and other objects on to the array itself. It worked, as far as remember until something happened that made it broken and I couldn't figure out what.


yeah I'd have to see it, any chance you can make a minimal test capx just showing what you are trying to do?
B
88
S
29
G
14
Posts: 1,158
Reputation: 15,011

Post » Mon May 11, 2015 6:53 pm

jobel wrote:
megatronx wrote:I tried couple of techniques. Once layout starts , I run a crawler from center of the layout. There problems with overlapping already spawned tiles, even thought they are set up correctly. Another technique was to generate floor first, then do offset calculation, and move everything so that whole map is placed tile away from 0,0. Then for each floor, i set up a value in 2d array. Then did applying of wall and other objects on to the array itself. It worked, as far as remember until something happened that made it broken and I couldn't figure out what.


yeah I'd have to see it, any chance you can make a minimal test capx just showing what you are trying to do?


Don't know. I'm using a bit of some unofficial plugins. But can send you trough message.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
86
S
28
G
21
Posts: 1,976
Reputation: 19,306

Next

Return to Construct 2 General

Who is online

Users browsing this forum: R0J0hound, vikuserro and 1 guest