chipmunk-Box2D Gideros framework-cocos2d-x recreations

chipmunk-Box2D Gideros framework-cocos2d-x recreations
0

#1

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)


#2

Ray casting. Gravity. Mass.

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


#3

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


#4

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


#5

Maybe you have a friend that can draw you one?


#6

? 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


#7

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


#8

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.


#9

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


#10

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.


#11

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


#12

@Rascake 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/


#13

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


#14

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


#15

What’s wrong with box2d ?


#16

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


#17

box2d is also integrated to cocos2d


#18

the #include header didn’t work for me


#19

What error?


#20

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