Problems with porting events from Classic

Get help using Construct 2

Post » Mon Mar 12, 2012 8:23 am

LATEST UPDATE: The below problems are more or less out of the way mainly because of r86, except for number (2), for a particular reason.

I've isolated the angle problem that this engine is having, to TWO main possible factors. It can only be one or the other, not both, I presume.

a) The anglelerp(a, b, x) expression. It's supposed to replace the RotateAngle() expression from Classic, but I have a feeling it's not working right. I'm gonna ask Ashley about it via PM.

b) The collision detection system might not be working properly in this instance, though I can't see how it would cause spontaneous and virtually random changes in angle.


------

I've been trying to port a Sonic engine someone else made from Construct Classic to Construct 2, but there's been a few issues that has halted progress. Three main issues:

(1) I'm pretty sure the "While" condition is completely redundant, but if not, how do you create a work-around for them?

(2) Construct 2 doesn't have the "RotateAngle" expression, resulting in the player unable to rotate properly.



(3) Construct 2 doesn't have the "Sign" expression... Whatever the hell that is.



I'll provide the caps here:

Classic .cap (Version r2, requires the MagiCam and Slgor's input system plugins.)

Construct 2 .capx, release 86, requires Standard license (requires the Function Plugin)

Go to the "Player_Code" event sheet on both, and open up two groups:

- Motion Management -> Tools (Whole group, for (1) and (2), I'm going to replace the "Parameter" function with a variable to get around the "Else" problem)
- Movement Routines -> Movement (look at the "Calculate Sub-Step" events for (3))

If anyone has any idea on how to work around these issues, I'd be grateful.Candescence2012-04-14 16:34:49
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Mon Mar 12, 2012 10:14 am

(1) While loop
To do a while loop do a for loop with a insane amount of loop and stop it once "what would be the while condition" is false

(2) RotateAngle() ? what does that do?

(3) Sign()
sign(negative number) = -1
sign(positive number) = 1
sign(0) = 0
What I usually do instead of sign(number) is either

number/abs(number)
but you have to check that number isn't equal to 0

or

cos(angle(0,0,number,0))

Yann2012-03-12 10:15:19
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Mar 12, 2012 10:34 am

1) Hmm. Insane amount of loop, huh? How much do you reccomend?

2) RotateAngle() comes out as "RotateAngle(Start, End, Step)" when you pick it out from system expressions, so I assume it's meant to 'rotate' the value from start to end, using the "step" parameter for how much per step. Of course, this obviously means having to re-work the event.

3) Ah, I see, now. Though, I'm not sure what the bottom one does exactly.
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Mon Mar 12, 2012 11:03 am

1) well that doesn really matter, as long as you're sure you get the work done but you can always do a
repeat 10000000000 times
As long as you stop it when the condition becomes false you just need to be greater than the greatest possible loop you need.

2) Yeah it looks like C2's angleLerp although I didn't know there were this action in CC

3) haha the bottom one it a little trigo trick, really simple actually
if number is positive the angle(0,0,number,0) is just a flat 0 degree angle (imagine a line between (0,0) and (number,0)
and cos(0) = 1
if number is negative, it's a 180 degree angle
and cos(180) = -1
if number = 0... hmmmm now that I think about it you might get 0 and then cos(0) = 1 so it won't be exactly the same as the sign() function but hehe... it might not be a problem.Yann2012-03-12 11:03:47
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Mar 12, 2012 11:28 am

1) Ah, so you mean like this, or am I getting it wrong? Because I'm causing my game to freeze when I try this method:



2) Yeah, I just checked out angleLerp and it does pretty much the same thing, it seems, haha. Must go by a different name. It works, however, so, yeah.

3) Oh, yeah, I see what you mean, and it seems to be making a huge difference so far.

B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Mon Mar 12, 2012 11:36 am

your [invert] collision = 1 isn't inside the loop so yeah you are running the full iterations congrats :D

Also [invert] collision = 1 is the same as collision not equal to 1... there's the operator... Well as it's the same it's not an issue, just wonder what is better practice.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Mar 12, 2012 11:49 am

Well, shoving it inside the loop doesn't seem to have any discernible effect either, but I decided to lower the 'repeat' count to 1000, which makes it run much faster for the time being.

edit: Nevermind, there's still a problem with full iterations.Candescence2012-03-12 11:57:45
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Mon Mar 12, 2012 11:03 pm

You need to re-structure your events so that "collision=0" is also a sub-event of the loop.
[code]+------+------------------+
|System| Repeat 1000 times|
+-+----+------------------+
+------+----------------+
--|player| collision = 0 | Actions...
+-+----+----------------+
    +---------------------+
+------+----------------+
--|player| collision != 0 | System | Stop loop
+-+----+----------------+
    +---------------------+[/code]R0J0hound2012-03-12 23:04:40
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Tue Mar 13, 2012 2:47 am

Tried that, it doesn't seem to work.
B
94
S
37
G
11
Posts: 404
Reputation: 11,275

Post » Tue Mar 13, 2012 2:54 am

To implement "while", try this plugin.
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests