Break a Box (like angry birds)

sebmacflysebmacfly Member Posts: 1,018
edited November -1 in Working with GS (Mac)
Hi G-Saladers!

How can i break boxes like in the angry birds game?
Wood boxes, stones, etc...
What's the strategy for that?
I need to break it aith a ball in my game...

Any help please?

thanks so much guys!

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    you could use particles, or an animation, or even spawn new actors although that would be pretty rough on the memory.
  • sebmacflysebmacfly Member Posts: 1,018
    Hummmm... thanks...
    But i need to know how my ball will interact with the boxes... i mean if the ball come soft on the box it will not break it... But break it with faster velocity.

    I don't know how to explain it (i really need the box rules)
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Well you could have a game attribute that is constrained to Abs(Sqrt((self.motion.linearvelocity.x*self.motion.linearvelocity.x)+(self.motion.linearvelocity.y*self.motion.linearvelocity.y)))

    And then based on that number determine what happens The higher the number the faster its moving.

    BTW. That expression should give you a single positive number for the velocity of the object in case you where wondering what it all meant.

    Hope that helps.

    Aaron

    ___________________________________________________________________________________
    TEMPLATES AND PROJECT HELP BY TENRDRMER. CLICK HERE!!!

    AppSolute Entertainment on Facebook
    AppSolute Entertainment on iTunes
  • gamedivisiongamedivision Member Posts: 807
    so have three images one good another more broken and another broken more then have a self rule called self hit change number to 3 when actor collides with ball self hit to self hit -1
    then another rule when self hit = 2 change image to the broken image, so on and so forth then on your self hit = 0 make an image of a splinter of wood and use particles to spawn that splinter of wood or rock or whatever with rotation and size to give it that smashed feel,so then you get the deterioration of the damage cause by hitting it and then the explosion hope this helps,im far from good at using GS so someone else may have a better way of doing it
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    It really depends how realistic you want it to be. The trade off is that to make it realistic it will require some work. Here's what I came up with. You'll need to unlock al your blocks so that you can have direct access to the ball's attributes and the other block's attributes or otherwise you'll need constrains. Basically you want to know how fast the ball is moving when it collides as well as how hard the other blocks are traveling when they collide. Then use this info to determine hit points on the block. When the hit points of the block reaches a certain point you'll want to trigger an animation or change image. Then when hit points are high enough you'll want to destroy the block.

    Or just don't worry at all about blocks hitting other blocks (as fas as damage is concerned). Then you could constrain game.BallsVelocity (real) to magnitude(linear.motion.X,linear.motion.Y). This will give you the speed of the ball in any direction. Then use this value to determine if the block should be destroyed on collision.
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    scitunes said:
    Or just don't worry at all about blocks hitting other blocks (as fas as damage is concerned). Then you could constrain game.BallsVelocity (real) to magnitude(linear.motion.X,linear.motion.Y). This will give you the speed of the ball in any direction. Then use this value to determine if the block should be destroyed on collision.

    Well other than an easier way to go about obtaining the speed that is what I said a second ago. Never thought to use magnitude for that purpose. Very nice scitunes!!!
  • sebmacflysebmacfly Member Posts: 1,018
    Thanks guys... I'll try

    Maybe some of you have a demo for that?

    ;)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    tenrdrmer said:
    Well other than an easier way to go about obtaining the speed that is what I said a second ago. Never thought to use magnitude for that purpose. Very nice scitunes!!!

    In the first half of my response I was trying to throw out an idea for how to make hit points based on collisions with the ball AND with other blocks. That's where things getting really tricky (and require instances so you can access other actors directly). What I did, come to think of it, was set it up so that the falling blocks would effect the bad guys (i.e. green pigs) depending on how fast they were moving when they hit the pigs. This is what I did in my game angry zombie launch that I released last halloween. So the blocks are not effecting each other's hit points but they are affecting the bad guy's hit points.
  • sebmacflysebmacfly Member Posts: 1,018
    Thanks scitunes...

    Can you send me a little demo with some blocks please?
    (sebby_zzzz@hotmail.fr)

    Thank you ;)
  • FloridaGamesFloridaGames Member Posts: 328
    try this maybe.
    constrain attribute:
    game.Ballpower = self.motion.angular velocity

    If all:
    ball overlaps/collides with box.
    Game.ballpower > "some high number.idk"

    destory box.

    just a guess.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    here's the basic idea:

    in an unlocked block instance.

    Rule
    when collides with bad guy1
    change self.hitforce to magnitude(self.linear.velocity.X,linear.velocity.Y)
    change current.scene.layer1.abadguy1.hitpoint to current.scene.layer1.badguy1.hitpoint + self.hitforce

    Then in the bad guy. When hitpoint > ???? destroy

    you cannot use one global attribute because the bad guys are almost always overlapping or colliding with a block so the global attribute would not get set accurately. You would either need a game attribute for each block's hitforce (constrained to that magnitude formula above) or else unlock each block and add that rule for EACH bad guy.

    So here's a quick tip. Get one level working with a bunch of extra blocks. Then copy and paste this scene for each level you are going to make. Otherwise you are going to be unlocking instances for every level and you will go insane!

    good luck!
  • sebmacflysebmacfly Member Posts: 1,018
    :S
Sign In or Register to comment.