Help Required in Collision Detection Using Box2d - iphone

After some sample projects, I have started with my first game in cocos 2d and box 2d where objects fall from a parachute and you kill them using slingshot. Now i'm stuck # couple of things for a while:
Collision Issue:
Using Box 2d i have made collision with objects. However when i add a counter to get a count of my collision i doesn't work. Counter increases even though the percentile is moved out of the screen.Don't know how to get rid of this.
I'm trying to get random rotation to my sprites which fall from above, Like a parachute experience. Now all of then rotate # a same angle.
Lastly i need to get rid of the surrounding sprites when collision happens. Ex: When the percentile collides with a falling object, in a radius of 2.5 cms the other sprites should also disappear.
I Badly need help and suggestions, hence all the 3 questions # once :-). I have provided the link for my project so that you can look # the source code. Desperately looking for your help guys!!!
Download Source Code:
http://jumbofiles.com/6fn5mmpnq1q8/Karthik.zip.html
Budding Developer,
Karthik

You have a pretty good tutorial here: http://www.raywenderlich.com/475/how-to-create-a-simple-breakout-game-with-box2d-and-cocos2d-tutorial-part-12
I think that one can solve your problems :)

You can get the best tutorial for the particular requirement you have described over here.....
The link for that is as follows
http://www.raywenderlich.com/606/how-to-use-box2d-for-just-collision-detection-with-cocos2d-iphone
The tutorial is of 2 parts and describes the code briefly.. The code of that is described and you can get good amount of help from there.

ques 1 + 3: you need read link which share by Mikael and Marine
ques 2: in cocos2d, if you want get random value, you can use support function (such as: rand(), random(), CCRANDOM_0_1() ....)... i think, you need set rotation value for object. i dont know your problem, you need explain it (link is "File Not Found or Deleted / Disabled due to inactivity or DMCA")

Related

Extra edges are generated between vertices when I move camera in game or in editor

I'm trying generate custom procedural landscape in unreal engine 4
To implement this I'm using this class https://docs.unrealengine.com/en-US/API/Plugins/ProceduralMeshComponent/UProceduralMeshComponent/index.html
and for nice noise generation on Z axis I'm using this plugin https://github.com/devdad/SimplexNoise from this library the only method I use is: USimplexNoiseBPLibrary::SimplexNoise2D
How to implement whole process I inspired from this video: https://www.youtube.com/watch?v=IKB1hWWedMk
I will try to describe flow of whole process:
define vertices count in row and column
iterate through row and column and create vertex vectors on (xscale, yscale, FMath::Lerp((-maxFallOff, maxHeight, USimplexNoiseBPLibrary::SimplexNoise2D(xperlinScale,yperlinScale)))
generate triangles using this method: https://docs.unrealengine.com/en-US/API/Plugins/ProceduralMeshComponent/UKismetProceduralMeshLibrary/ConvertQuadToTri-/index.html
generate UVs
That is all, at this point I can say everything works fine, but there is little issue, when I move camera in editor or in game on mesh appears extra edges. I also recorded video to show what I'm talking about.
https://youtube.com/watch?v=_B9Fxg5oZcE the edges I'm talking, appears on 00:05 second
Code is written in C++, I could post code here, but I think code is not problem here, I think something happens on runtime while I move camera something that I don't know...
I can say in advance if you interested that I'm not manipulating on mesh on Tick event
Problem solved...
Actually seems like I had bug in my code, I was passing too many triangle points to CreateMeshSection_LinearColor method that was the problem.
Anyway thanks for attention
Cheers

How do I make a Maze Generator on Scratch?

I am currently in High School, and I am in an APCSP (AP Computer Science Principles) class, which in my case is learning in Scratch programming. I am confused and have practically no idea what I'm doing. Scratch is very confusing and I feel like it's pointless to learn.
My question is this: Can anyone help me on how to make a Maze Generator on Scratch, as this is my project and it's giving me struggles.
Thank you.
It's actually possible to build with scratch but depends on what you are looking for. I assume you want to generate a simple maze like in old fashioned 8-bit games like boulder dash.
First decide on the size of your maze: for example 5 x 5 blocks.
If you want to create a maze, imagine drawing it on a grid on paper. Blocks are either "empty" or filled in. Our maze can be represented by numbers. The empty blocks are represented by a 0 and the filled blocks with a 1.
You could visualize that matrix like this if all blocks are empty:
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0
Adding a border wall while keeping the inside empty would look like:
1,1,1,1,1,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
1,1,1,1,1
Using a "list" variable to store this information would fit best within the possibilities of MIT Scratch.
In this case, you need to understand that each block in our maze is represented by a position in above matrix. You could draw numbers on a piece of paper in the shape and size of your grid / matrix as a reference to remember the position of each block if that makes it easier.
We also need to look at how our maze will relate to the Stage size. The width and height in pixels of a default scratch project is 480x360.
A 5 x 5 maze is divided in blocks of 480 / 5 = 96 width and 360 / 5 = 72 height. In other words, a block needs to be 96x72 pixels, based on a full screen maze.
Next step, is creating a sprite representing the visualization of the blocks of the maze. I would keep the first "costume" of our block sprite empty, and create a fully filled block to represent the walls of the maze.
After that, we need to programmatically create our maze. I made an example you can explore of random drawing of the blocks of a maze:
https://scratch.mit.edu/projects/278731659/
(You can change the rows & columns value to see it scale up, but remember the limit to the amount of clones the block sprite can have is 300)
This is just to get you started and by no means a complete solution. I just hope this helps you think in the right direction.
You can make this more advanced, by adding a function to explore and correct our randomly drawn grid to generate a walkable path from position x to position y. A rule you can program is for example: Every empty position in the grid should have at least two other empty positions in the spaces above, below, left and right of it.
There are many different ways to do this; whether this is with sprites and stamp or 2D lists and pen. Either way, the main component is the algorithm. This wikipedia page gives details on how maze generation works and few different algorithms. There is also a video series by The Coding Train here where he creates a maze generator with the 2D list method from above (this method is a bit harder on scratch, however). Either way, the best thing to do is to look at examples others have made, figure out how they work, and try to recreate them or make them better. Here's a good place to get started.
Scratch IS truly pointless! A simple maze generator would have you use the pen to draw predefined shapes (Such as a long hallway or intersection). You should also make (invisible) squares to separate everything and have the program draw in the squares.
I will put a link later that leads to a sample project that has the code.
Check out this video by griffpatch
https://www.youtube.com/watch?v=22Dpi5e9uz8
This was one of my projects, and the instructor provided this video for everyone to follow and expand from.

How should i make infinte ground ?

I'm trying to make a simplified version of crazy taxi . For the first step i need to make an infinite ground . I'VE searched online but couldn't find any examples .
Can i find any example of how to do this ?
https://www.youtube.com/watch?v=rhTPxrJICVg&list=PLLH3mUGkfFCXQcNBz_FZDpqJfQlupTznd
N3K makes an infinite runner in Subway Surfers style, meaning ground coming from the back and going towards the camera.
The above link is to his tutorial series.
This is a very broad question I try to give a very simplified answer to get you going.
To create endless road you need some sort of procedural function that generates corners for your track. If you do not need to backtrack you can cook something up yourself like (in X distance turn X degrees to the right). If you do need to backtrack you need something like perlin/simplex noise that always generates the same value based on 1 or more other values. You could use total distance to get the curve in the road.
You simply keep generating the world on the fly and unload pieces of the world you don't need any more. If the player can alter the world like destroying street furniture or leaving skitmarks you need to implement a chunk system. When you backtrack and generate a cerain part of the world with your procedural function you can have permanent changes the player made in that specific part by saving and loading to the chunk. Much like Minecraft does it actually.

obstacle avoidance implementation in matlab

This could be a really broad question, but if you can help me with ideas, it would be a great help to me.
I am trying to implement basic path finding algorithm in matlab. I have to create a map where the robot can navigate and also avoid obstacles and reach destination. I have the algorithm fine with me. But am struggling with the gui as I haven't used much of Gui in matlab.
This is the following idea I had.
I created a plot and just defined 4 coods for each obstacle, destination as a circle and a start point. But am stuck when I think how I can detect whether the robot has hit an obstacle or not. One way is to create the equation of line and try to see if the point ever comes to lie on it. But the movement is based ona random generated variable. Thus it is possible for the robot to cross the line and get inside the polygon.
My apologies for bein too elaborate, but can you please tell me the best way to implement this in matlab? It is mandatory to do this in matlab. Please suggest me a better and easy way to program it. Thanks in advance.
If your obstacles are all polygons you could try to use the ray casting algorithm described on the following wikipedia site.
Point in polygon algorithm
With this you should be able to determine if the robot position lies within an obstacle, or you could determine if the next movement will bring the robot into contact with the obstacle.
If you are looking for a simple algorithm that can take care of obstacles inherently i would suggest the potential fields algorithm (can get stuck in certain cases)
Potential Fields
else you can also try the A* algorithm, which is better in my opinion; Good description of A*

fruit ninja Blade effect

i want to make fruit ninja blade. i am using cocos2d and the MotionStreak is really ugly for this. Any other approach or better settings for MotionStreak? maybe particle system? any free great tools similar to ParticleDesigner?
I have my own implementation with OpenGL triangle strips mapped with texture. The blade is very smooth if the distances between adjacent points are small enough. I use linear interpolation to insert more points between two points which the distance is greater than a predefined constant. I'm thinking of use order 2 interpolation but the implementation is more difficult and the performance may reduces.
Source code is available here https://github.com/hiepnd/CCBlade
i don't know how much effort it will take but the thing is you can create and change shape of filter and just apply a white to gray gradient as it's texture, it'll give a very good looking results. i myself am working with cocos2d-x (it's just a c++ port of cocos2d) and it has samples for dynamic filters (it's just like you create and manipulate a mesh and all the things are done automaticaly), it uses CCActionGrid class but i just didn't used this class yet if you couln't solve your problem using that ask me to search deeper.
http://pixlatedstudios.com/2012/02/fruit-ninja-like-blade-effect/
Worth Checking out!!!! based on hiepnd CCBlade tutorial.