Collecting enough "coins" to open new path

For questions about using Classic.

Post » Sun Sep 27, 2009 8:56 am

Hey all. I have this problem. I want it so in my game, u collect enough "cave gems" to access new areas. When u collect a certain amount, it opens up a new path somewhere in the game. Its a Metroid like game with a few new ideas thrown in. If u look in my CAP, ull see i tried but failed... Please help. Much appreciated. Thanks.

[url:1muxd7hf]http://www.mediafire.com/?sharekey=0c61fdebdb549b505bf1f12f1ff3f30ae04e75f6e8ebb871[/url:1muxd7hf]
B
2
G
3
Posts: 21
Reputation: 892

Post » Sun Sep 27, 2009 9:48 am

set the player to have private variable, for this purpose we'll call the vairable "coins" and set an event to where when overlap between player and gem, increase private variable 'coins' by 1. have the access to the areas blocked off and set an event that compares a private variable, reaches cirtain amount, destroy object ubstructing the way
B
2
G
3
Posts: 33
Reputation: 916

Post » Mon Sep 28, 2009 9:15 am

Thanks. But heres the thing. I did what u said, and it works, but only in that room. If i leave that room it resets everything. I tried making the "coins" global, and they disappear when u leave the room, but the obscureity doesnt delete.

Only if i stay in the same room and collect all the ones i need it will work. I need it to be collecting "coins" throughout the games many levels, opens up the obscurity when u touch it. Please help. Ive tried everything. Theres no COMPARE GLOBAL VARIABLE button that i can see. Heres the CAP. Maybe someone can figure it out. Thanks.

[url:11w79xka]http://www.mediafire.com/?sharekey=91fb362c9fca8caea0f2f20c509059d9e04e75f6e8ebb871[/url:11w79xka]
B
2
G
3
Posts: 21
Reputation: 892

Post » Mon Sep 28, 2009 12:58 pm

yes there is actually
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Mon Sep 28, 2009 3:00 pm

not only do u put it in a global variable, but u can also play with the "for each object", and place individual, global variables, for each object will allow u to only have to do this once. i had to do this with my game cuz i had split levels, and when u entered a dungeoun layout, and came back to the normal game layout the monsters and the bosses would respawn

EDIT: sorry i couldnt help myself, i never stop thinking. u could also put all the coins from one level into a family, so u would have a family for coins in each level, set ALL the coins to be global objects, that would make the ones u destroyed in one layout destroyed in the next. but if u didnt destroy them they would show up in the next, to solve this problem u would set the family of coins for that particular level as the only ones that are visible, and of course u would have to add a second condition to your collision event that says that if u collide or overlap the coin, AND it is visible, then destroy, so on and so forth.
B
2
G
3
Posts: 33
Reputation: 916

Post » Wed Sep 30, 2009 1:12 am

You might have already solved this.... There are many ways to do this and SSG and Quazi have pointed out some good ways...

Some things to keep in mind:

1. When you physically place a items on a layout, even if you destroy it it will be recreated when you re-enter the layout.

2. Your player is not global so any private variables for him will only be useful in that layout.

I implemented something similar to what SSG was referring to for this. I used the X and Y location of the object, but you could do it several other ways. You use a global array to store the xandy location of the objects that have been detroyed and then on the start of layout redestroy them. You should add more meaningful names to your event sheets and layouts. Let me know if you have any questions.

.cap here: [url:gd7mag08]http://www.box.net/shared/j83ip3ou6i[/url:gd7mag08]
I used 0.99.5 for this so you will need to upgrade to the latest version of Construct [url:gd7mag08]http://sourceforge.net/projects/construct/[/url:gd7mag08] to try it out or see below (added to Cavegems event sheet):

B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Wed Sep 30, 2009 9:25 pm

Thanks man. Im still new so im learning. It worked fine until i added more and had another door that opened after collecting 2 more gems (to see if it would work. The ones i added reappeared while the ones u did didnt. Is there a way to add more and have them all work like urs did? Please let me know. Thanks again for all the help.
B
2
G
3
Posts: 21
Reputation: 892

Post » Thu Oct 01, 2009 12:14 am

[quote="SexyPoot":gvxo0qc8]Thanks man. Im still new so im learning.[/quote:gvxo0qc8]

No problem at all. This isn't the easiest problem to solve. I couldn't quite understand what you were trying to explain in your last post. Could you please try to explain it again and post a .cap so I can see what you mean?
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Thu Oct 01, 2009 3:01 am

[url:3bk9hyke]http://www.mediafire.com/?sharekey=3b4f5327563ac81b7432d3c9683f450ae04e75f6e8ebb871[/url:3bk9hyke]
B
2
G
3
Posts: 21
Reputation: 892

Post » Thu Oct 01, 2009 3:23 am

I see what you mean. You need to do two things:

1. In layout 5 there is an array "destroyed things". Change the X value from 20 to whatever value you think is needed to hold the gems and other items you will destroy. I put it at 50.

2. Copy the array to all layouts that have gems or other destroyable items in them.


That's it. Then it will work. :-)


If you want to add things like the wall to stay destroyed then just add the wall sprite to the destroyed family and add it to the destroyed array... like I did with the gems.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests