Fruit ninja

DreamLabDreamLab Member Posts: 2,127
edited November -1 in Working with GS (Mac)
Out of my own boredom and curiosity I was looking at fruit ninja templates. Unlike the fruit ninja game, the templates only cut the fruit at a certain angle no matter how you cut them. I want to know how you would get the fruit to cut at whatever angle you swipe the blade at. PLEASE COMMENT
thanks
DL

Comments

  • HachikoHachiko Member Posts: 330
    You can cut fruit at different angles easily(check for the vector that is created first and before the collision with the sword, make an angle out of it, and spawn or recycle actors that have rotation fixed to simulate a nice cut), but you can't cut them at different "point". Meaning, the cut will always have to be at the center or at another fixed point of the fruit, no matter how the user cuts. Doing otherwise it's possible (checking where the sword is in relation to the fruit, and spawning a bigger half and a little half, things like that), but it's just too much work, it's good with cut at given point too :D
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    like Hachiko said, it should be possible to get the angle of your swipe and then adjust the rotation of the cut line through the fruit, but it would probably involve a ton of math that is over my head :)

    I think you could hire Orbz to take a crack at it, he was offering his services in Nov/Dec for a really good price, and he is incredible at math
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    I don't know, if I understand it right, but if you mean, that you want the fruit being actually cut at the same angle and spot, where the swipe occures, as it would happen in real life, you can't do that as long as you use images for the fruit art.

    I believe for that you would need to draw the fruits in real time by pixel. That would be hard even with coding in xcode and it is impossible in GS.
  • HachikoHachiko Member Posts: 330
    The math are simple:
    get the angle of the vector (in a rule if sword collide with fruit then startX = position.X, startY = position.y, otherwise endX = position.X, endY = position.y), then you do a vectorToAngle (startX-endX, startY-endY (or viceversa, endX - startX etc) and get the angle that the cut was at. you just make the fruit disappear, set or spawn two half of the fruit (to simplify things, do not draw the half in a separate image, draw it in a canvas the same size of the fruit, and put it like you must do a puzzle to set back the full fruit (can't really explain better xD)).
    Those two half, if are like I described, must be set to the same x and y position of the slashed fruit. Their rotation then, must be set to that of the vector to angle, a little adjusted (would have to test to sort it out perfectly), and you put some logic to make them "do that little jump" and fall towards the bottom.
    This is all theorically though, never tested xD So can't be 100% sure.
Sign In or Register to comment.