Proper Programming Methodology

Discussion and feedback on Construct 2

Post » Mon Aug 19, 2013 7:28 am

@Cipriux - okay I think understand this. Then answer me this, if dt is frame independent as well, then why, using this code, is the player moving much further at a lower fps (still above 10)?


B
38
S
12
G
1
Posts: 526
Reputation: 4,085

Post » Mon Aug 19, 2013 11:06 am

You should post the full capx. This lone excerpt is not enough to understand exactly what you're doing.

You also don't need the "Wait 0" actions.

Also remember how events work, every tick a condition is true, the actions will be executed.
Perhaps what you need is to set the platform vector to dt to have the effect you're looking for (I'm not sure as it depends on the rest of your project).Kyatric2013-08-19 11:06:58
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Mon Aug 19, 2013 12:37 pm

@ome6a1717 Is this event happening every x second, or everytick?

If is everytick is the correct loop.
I am afraid cannot help any further
B
78
S
21
G
23
Posts: 513
Reputation: 18,623

Post » Mon Aug 19, 2013 5:43 pm

@Cipriux - it's happening every tick. Dash is being set to 0.35 (because it should only last 0.35 seconds)

Here's a clean capx - click new game and then use right click to slide and jump right click to do the air dash to see what I'm talking about. Ideally I want to player to move this distance and then get pushed a bit in the direction he dashed.

https://dl.dropboxusercontent.com/u/28104568/v2.01%20CLEAN.capx

The code is in Movement > Air Dash (and Slide is doing something similar, but it would be easier to just look at air dash)
B
38
S
12
G
1
Posts: 526
Reputation: 4,085

Post » Tue Aug 20, 2013 10:22 am

@ome6a1717
things to try:
If subtracting 1 from instance variable every 0.1 seconds , to make sure it does not go below 0 (not to trigger "if variable=0") try using clamp Ex: clamp(var-1, 0 ,max), or use "if variable=0"
instead of dashing depending on time (0.35 sec) try dashing depending on distance.
For speed of 1500 pix/sec and 0.35 time the distance will be 1500*0.35= 525 px.
So: before dashing, save player position x1,x2, and while dashing check the moved distance , if is above 525 make it stop and return to 525 (imagine a circle with a radius of 525 px and the player has to go back inside )
If the movement is depending on time, than is depending on dt which for 20fps and a speed of 1500 px/sec the movement error will be 75 px. 1/20*1500=75
Your project is overwhelming for me to try modifying myself.
In programming math is your best friend.

By the way, nice game.
Cipriux2013-08-20 10:24:58
B
78
S
21
G
23
Posts: 513
Reputation: 18,623

Post » Tue Aug 20, 2013 5:18 pm

@Cipriux - thanks for taking the time to look at it. Would using the timer behavior be easier and have the same result?
B
38
S
12
G
1
Posts: 526
Reputation: 4,085

Post » Wed Aug 21, 2013 1:54 pm

Never used, so I don't know.
B
78
S
21
G
23
Posts: 513
Reputation: 18,623

Post » Wed Aug 21, 2013 11:42 pm

It doesn't work with timer either. It must be an issue with the "move at 1500*dt" event. I'll try doing what you suggested with setting the end location to snap, but since the camera keeps to the player position, it might look strange. Still no indication as to why yields random results...
B
38
S
12
G
1
Posts: 526
Reputation: 4,085

Post » Thu Aug 22, 2013 12:54 am

I've never used (or seen a need to use) the "else" condition. In that picture what is the point of having the "else" there, would it function the same without it?
B
147
S
73
G
20
Posts: 1,785
Reputation: 22,420

Post » Thu Aug 22, 2013 3:33 am

@alspal - I actually haven't tried without else; it's really just habit.
B
38
S
12
G
1
Posts: 526
Reputation: 4,085

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests