Custom controls(see example)

Get help using Construct 2

Post » Wed Dec 21, 2011 12:42 pm

Hi, Im relatively new to construct and im trying to make a physics based game, But I want to replicate the controlls of this game - Game

What i have so far is,
On mouse down object.apply force (y = -15)

But in this game, If the mouse is down the character tilts upwards and then go's towards that direction, however you cannot completely go up in the air, gravity catches up with you..

Can someone help?

Thanks.
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Wed Dec 21, 2011 2:18 pm

Im not sure if that game in the link uses physics, doesnt look like it to me. But if you do wanna use physics, I would look at the "Apply force towards position" function instead, and use the Mouse.X and Mouse.Y as parameters.

I made this very simple example, where I dont use physics, but with the same thought as with the physics version. This version just rotate the object by the mouse position and move it forward, and it moves up and down depending on the forward vector.

I think with some tweeking it should work just as the youtube example you linked to.

http://dl.dropbox.com/u/52716812/MoveWithAngle.capxCodeMasterMike2011-12-21 14:20:11
B
38
S
13
G
9
Posts: 151
Reputation: 8,437

Post » Wed Dec 21, 2011 2:23 pm

Hmm Yeah it uses physics, And i cannot figure out how to replicate it using the physics object :(
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Wed Dec 21, 2011 5:33 pm

Basically when you touch the screen the whale tilt up and goes higher, when you don't touch the screen he tilts and goes down.
Other than that an autoscroll based on horizontal speed of the whale.

There's nothing about friction, damping, you don't have environmental elements that influence the whale's movement (Except for the speed burst but it's just speed...) it's just all about simple orientation of speed vector. Maybe some secondary element does use physics, but the whale is definitely not physics driven.

You can emulate the same kind of movement with a simple bullet behavior.Yann2011-12-21 17:35:57
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Dec 21, 2011 5:45 pm

@Yann

So something like:

On mouse down, player.rotate clockwise - 10 <--(How do you constantly rotate?)

on mouse released, Player... ?GingerBatMan2011-12-21 17:47:15
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Wed Dec 21, 2011 7:27 pm

like that whaleRip.capx
Last edited by Yann on Sun Sep 14, 2014 10:44 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Dec 21, 2011 8:39 pm

Legend!!! One more thing..

You see how if the players rotation is greater than 180 then when the mouse is released it carrys on following that angle,

I tried to implement this my self with:

Mouse: Left button is down(invert)
     System: compare 2 values(Player.angle - >= 180)
------> ???
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Wed Dec 21, 2011 9:53 pm

you want to do the looping thing?
I think it might be either an animation on the sprite itself, or an automatic rotation (once launched it will play until a certain angle)

For the first option it's juste sprite animation so let's go to the second one

Make an instance variable for the player object called "looping" with default false

and for events :
[code]System: a < -80
Mouse: [invert] Left button is down
    -> Player: set looping to true
Player: is looping
    -> System: substract 80*dt from a
System: a < -275
    -> System: set a to 85
    -> Player: set looping to false[/code]
It's all based on the capx I provided.
However you have to change something to shutdown the classic angle calculation ([invert] mouse down -> add rotationSpeed*dt)
Basically it would look like :
[code]Player: [invert] is looping
    Mouse: [invert] Left button is down
        -> set a to max(a-rotationSpeed*dt,-aMax)
    Mouse: Left button is down
        -> set a to min(a+rotationSpeed*dt,aMax)[/code]
I won't insure you that it will work 'cause I didn't test and I wrote all that from memory.

Well redownload the capx I updated it with all this sh*t, 'cause the values weren't right (rotation too slow, angle limit too high etc)Yann2011-12-21 22:07:48
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Dec 21, 2011 10:22 pm

@Yann i think i done something wrong,

Take a look Game

ThanksGingerBatMan2011-12-21 22:23:20
B
8
S
2
G
4
Posts: 55
Reputation: 2,555

Post » Thu Dec 22, 2011 12:34 am

redownload my capx above and compare the differencies, you should see, it's obvious.
(clue : in my explanation I did say "change something" not "add something")
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Next

Return to How do I....?

Who is online

Users browsing this forum: Matthew de, nexlove and 25 guests