chipmunk-Box2D Gideros framework-cocos2d-x recreations

Hello,

I am trying to recreate the following clips, as these concepts are exactly what I would like to recreate in my game (except the portals are movable and the slingshot has an elastic limit). The examples seen in the video were made with box2d and Gideros, I would like to make mine with chipmunk and Cocos2d-x, but unfortunately cannot seek help the chipmunk website forum due to their inability to accept new members, so I was hoping somebody here could shed some light on the fundamentals of the examples portrayed in the clips (in c++, chipmunk and cocos2d-x however)

Ray casting. Gravity. Mass.

Cpp-tests has a working example of almost what you need.

But in order to get started I need to make a slingshot just like the videos one, and I have no reference for that.

It seems you want tutorial how to make exactly your game :smile:

Maybe you have a friend that can draw you one?

? I have a slingshot in mind, EXACTLY like the videos one, I meant no reference/source in learning to program it. Sorry for the confusion

Not really, I mean how would I self educate myself to make a slingshot?

Ok, if you can’t find such tutorial try to think how to do the slingshot by self.

The idea is simple I think: apply force to a ball and it will move.

I took a few udemy courses and only learnt how to make a stylish animated UI, I could make a ball do collision actions but really, the elastic is rather gibberish to me and the key part of a slingshot game

I recommend you watch the video again and again and think how to solve it.
Here I help you by showing a pseudo-code:

onTouchScreenBegin
{
stopBallMoving();
}

onTouchScreenDuring
{
 dragBallInAngle(); 
 DrawRedLineInAngle();
}

onTouchScreenEnd
{
 applyForceToBallInAngle()
}

I recommend to use trigonometric functions for calculate the direction to apply the force.
For example, something like this:

float velocity = 2; //ball velocity
auto vec = Vec2(sin(angle), cos(angle)).getNormalized();
vec *= velocity;
Vec2 force = Vec2(vec.x, vec.y);
applyForce(force);

For calculate the angle maybe you can use std::atan2 sending the 2 points to calculate.

1 Like

Thank you Tranthor! I won’t mark it as solution just yet, I will see how far I can get with this

@anon97208230 This is what you want. I written it about 7 years ago and open sourced it. Written in JS/HTML5 and box2d. You can take the JS code to do the swing part. It should be very easy to translate it to cocos2d-x c++ or the JS version.

Try it out in chrome below.
http://vorun.com/ms/chrome/

Oops here is the code https://github.com/vkreal/MonkeySling

Hmm okay, js translations doesnt sound too hard, what about from box2d to chipmunk?

What’s wrong with box2d ?

It is just a nuisance to download thanks to sonar systems un-eventful tutorial, so I am just sticking with chipmunk as it is faster in integrated

box2d is also integrated to cocos2d

the #include header didn’t work for me

What error?

‘cannot open source file <Box2D/Box2D.h>’