Collecting enough "coins" to open new path

This forum is currently in read-only mode.
0 favourites
From the Asset Store
A game with 3D terrain, realistic water and various 3D objects.
  • 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.

    http://www.mediafire.com/?sharekey=0c61fdebdb549b505bf1f12f1ff3f30ae04e75f6e8ebb871

  • 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

  • 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.

    http://www.mediafire.com/?sharekey=91fb362c9fca8caea0f2f20c509059d9e04e75f6e8ebb871

  • yes there is actually

  • 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.

  • 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: http://www.box.net/shared/j83ip3ou6i

    I used 0.99.5 for this so you will need to upgrade to the latest version of Construct http://sourceforge.net/projects/construct/ to try it out or see below (added to Cavegems event sheet):

    <img src="http://i37.tinypic.com/289j13r.jpg">

  • 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.

  • Thanks man. Im still new so im learning.

    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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Wow that was fast hehe. Ur really great man. Thanks for all the help. Theres one problem still tho. They reappear still. When i leave the room they come back. I dont know what im doing wrong. Also, do i put the total amount of gems for the layout in the X or do i put the total amount in the entire game in the X? Sorry if i come off annoyig, im just really frustrated by this. I thought it would be easier since its been done in Metroid that was made in the late 80s hehe.

    Ill be sure to list u in the credz if im one of the lucky few that manages to finish their game

    Heres what i have so far...

    http://www.mediafire.com/?sharekey=3b4f5327563ac81b7432d3c9683f450ae04e75f6e8ebb871

  • I updated the .cap to show the changes. It seems that the array must exist in all levels the player walks through. This is kinda a "bug" in Construct since the array should be global to begin with and exists in all layouts.....

    Also the X will hold the destroyed items for all gems in all layouts. Because of this, the X should be a value higher than the sum of all gems. Another option is to have an array per layout (but still global). Then the X value could be smaller.

    http://www.box.net/shared/j83ip3ou6i

    I thought it would be easier since its been done in Metroid

    It's amazing just how complex the code for simple looking games can be.

  • I cant thank u enough for all ur help. I hate to tell u this but theres still something up in the game hehe. I added more Gems and cranked the number of Gems to 30. I also craned the overall number u can get to 100. I figure i have a high number so i can add as many as i want as long as dont go over 100. Well anyways, i added 1 gem to the secret room to the left in the starting room. But when i get that one, another disappears in room 5 on the left. I dont get it! So far ur the one thats been helping me the most so i thank u again. U have no idea how grateful i am. Thanks.

    http://www.mediafire.com/?sharekey=3b4f5327563ac81b7432d3c9683f450ae04e75f6e8ebb871

  • This sounds like a good problem for you to troubleshoot. Here are some tips/questions to help you out.

    1. What is the X and Y coordinate of the gem in the secret room? What is the X and Y coordinate of the gem in layout 5? Are they the same?

    2. What mechanism is used to determine if a gem should be destroyed? Can you think of a better way? For example, would using the UID of the object work? Would using the Layout of the object help to solve the problem?

    Once you answer these then you should be able to fix it.

  • Well I checked it and yeah, they are at the same X and Y. I moved it so it works now. The crate wont go away now so ill look into it. Im not sure about ur second question. Im new and still learning. Im not sure what ur asking. hehe, im sorry. Ill try to figure it out anyways.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)