How do I lose items after being hit by enemies?

0 favourites
  • 5 posts
From the Asset Store
Safaryx
$5 USD
The game ends when the player loses all their lives
  • First I'll say I apologize if this topic has already been discussed/solved. I have searched for a topic on this for quite some time and I find things that are close, but I need a more specified answer. I will also say I'm fairly new to Construct 2. I've used the free version off and on the past few years and I finally bought it a couple of weeks ago.

    Here is my issue:

    In my game you collect items and bring them back to a hoard. You can only store 10 items total in your "inventory" to bring back. If you are hit by any enemies you drop all your items just like Sonic's damage system. I somehow have a spawning system for bees (the enemies in my game) working exactly the way I want it too. Despite using similar compare variable system events I can't get the player to drop the amount of items that are counted in its "inventory". If anyone is able to help me with this problem I would be very grateful. I'll post the file if someone wants to see it. Only reason I haven't is because I want to learn what I am doing wrong and not just have someone hot fix it for me. Thanks in advance!

  • How does your inventory work? eg; Is it object-based? Is data held in an array? Is it just a set of ten variables?

    What behaviour is currently exhibited - do they drop one of their items, none of their items, do they drop items they don't have?

    Your games sounds fun by the way

  • Well on the bottom left corner (in game) It displays 2 boxes that fill up with five items each. When one inventory's instance variable is equal to 5. The second box will start filling up until its instance variable is equal to 5. I'd say its a mixture of both variables and object based since for each item that I collect it does display itself in my inventory. I have never used arrays.

    It's pretty random whats dropped. It's either more than ten is dropped or a few is dropped.

    Thanks! It was a fun little idea I came up with to help me learn the program a bit more.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You'll want to learn arrays - they're tricky at first, but the gateway to much more powerful stuff! And they're a lot simpler than you think - an array is essentially a basic spreadsheet (Imagine the 'Z' axis as being 'Sheets' on the spreadsheet).

    Back to your problem: you you could try

    on [player] collision with [enemy]

    for each [item]

    where [item] is overlapping [inventorybox]

    drop items (however that works)

    That should identify your items one-by-one for you, and make it easy to create the necessary logic to create the dropped items on the floor.

  • It's funny you recommended Arrays I am putting aside that game to work on learning Arrays and Functions. I will try your idea for my inventory problem, but like you said Arrays seem to be the answer to my problem. Are their any tutorials you would recommend?

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