Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [GM7] Smashing pots  (Read 735 times)

0 Members and 1 Guest are viewing this topic.

skycloud

[GM7] Smashing pots
« on: April 03, 2007, 12:53:58 am »
Hi I want to add pots to my game, but I'm kind of puzzled for when I add them. I want them to be brakeable which I understand how to do it but, I want it to have a chance to spawn a heart and rupee so could anybody tell me how to do this, and maybe point me into the direction of a animated pot being broken.

Edit: I have pro gm7 if that changes anything I can do for this.
« Last Edit: May 18, 2007, 08:34:23 pm by 4Sword »
Logged

Goodnight

Once and future Captain
Re: [GM7] Smashing pots
« Reply #1 on: April 03, 2007, 01:40:53 am »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
Hey man, this is HTW from the sounds page.. I use a different name here.

First of all decide what the odds for getting a prize should be. Let's say you want a heart 20% of the time, a rupee 20%, 5 rupees 10%, and nothing 50%.

When the pot is destroyed, get a random number between 0 and 100 (or more precisely, 0 and 99.999). If it's 0 to 19.999, spawn a heart, 20 to 39.999, spawn a rupee, and so on.

So put this in the pot's Destroy event:
Code: [Select]
var rnd;
rnd = random(100);

if rnd<20 { instance_create(x,y,objHeart) }
else if rnd<40 { instance_create(x,y,objRupee) }
else if rnd<50 { instance_create(x,y,objRupee5) }

And to show the smashing, make a new object with the smashing animation as its sprite, and instance_create() it just after that code above in the same event. Give this new smashing object an Animation End event, and in that, the object destroys itself.

I wrote a more complicated example, if you want the odds for prizes to change during gameplay. For instance if you get a Bow, you'll want the prizes to then include arrows. If that interests you, it's here:
http://www.zfgc.com/index.php?topic=13011.0
Logged

skycloud

Re: [GM7] Smashing pots
« Reply #2 on: April 03, 2007, 04:01:11 am »
Thanks I'm going to try that out, just gotta play lttp until I get to a part to smash up some pots, and hopefully it will be perfect.  XD
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.119 seconds with 43 queries.

anything