dop2000's Forum Posts

  • [quote:2q55lmdp]May I ask, what does it mean to 'pass the item number to the function'? How would I do it?

    I thought you knew this.

    You can pass data to functions as parameters, for example:

    Call function without any parameters:

    Function call "AddToInvertory" ()

    Call function with one parameter:

    Function call "AddToInvertory" (itemNumber)

    Call function with three parameters:

    Function call "AddToInvertory" (itemNumber, inventoryType, quantity)

    Inside the function you can access these parameters using Function.Param(0), Function.Param(1) etc.

    By the way, functions can also return data. So you can have something like this:

    itemQuantity = Function.Call("GetNumberOfItemsInInventory", itemName)

    You pass itemName to the function, and the function returns quantity of this item in the inventory.

    [quote:2q55lmdp]Grab the note and select it from the inventory without going near Jim, and you can read it!

    I'm irrationally proud of myself right now.

    Yeah, I see it now. Pretty good!

    As for the inventory system, I can't tell you which one I prefer, because I don't have any RPG games with inventory

    If I ever need one, I'll probably create it from scratch. It may take more time, but at least it will be tailored to my needs and I'll have full understanding how it works.

  • Zion

    Again - in terms of performance it doesn't matter how many layouts or event sheets you have.

    Other things are much more important - the size of your images and animations, efficiency of your code etc.

    Large number of layouts will make it harder to manage your project. Imagine you have 100 layouts and decide to make a small change on all of them - this will take an hour! So if you can, you should minimize the number of layouts.

    If your code for 100 levels is basically the same, of course you should not make 100 identical event sheet.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • NN81, You are wrong. Performance depends on implementation and not on the number of layouts.

    Of course if you dump thousands of objects from all 100 levels onto one layout, this will be bad for performance. But obviously this is not a very good technique.

    Zion

    It depends on you game.

    I'm making a puzzle game with 200+ levels and I only have one layout for all of them. My layout contains all fixed interface elements like HUD, dialog windows etc. and an empty "Game" layer.

    On start of every level I read parameters for this level from a text file (which I made in Excel), and create required objects on the "Game" layer.

    And all this works really fast

  • I think IndexOf() only works with 1D arrays, as it can't return two values for X and Y axes.

    Array->Contains value can tell you if this value exists, but to find its coordinates in 2D array you need to loop through it using "For each XY".

  • Your function is never executed, because loopindex is always =0

    I suggest you add a large text field to your layout and use it for debugging.

    Try for yourself:

    DebugText->Append text "Loopindex:" & loopindex

  • You don't need animation frames for different angles. Just keep one frame with the ship facing to the right.

    Then use Enemy1->Set Angle action to rotate the ship to the same angle as your Bullet.AngleOfMotion

    Or you can set "Set Angle=Yes" in Bullet behavior properties and it will fly in the direction of the sprite, i.e. you will only need to change sprite angle. Bullet angle of motion will be changed automatically.

  • Your link is broken, try posting it without the "https://" part

  • luckyrawatlucky

    You mean having 2 spriter objects?

    This is what the OP was trying to avoid.

  • You have 2 instances of EF_Start.

    When you use "Pick by evaluate" event the system performs 2 steps:

    a) takes the first instance, compares if .stt=choose(1,2)

    b) takes the seconds instance, compares if .stt=choose(1,2)

    Because choose(1,2) expression generates a random number every time, this event works unpredictably. It may pick one instance, or both, or none.

  • Add Timer behavior to your Enemies and use it instead.

    On start of the layout - For all enemies start "shoot" timer for random(x) seconds (Once)

    On "shoot" timer event -> shoot weapon and schedule new "shoot" timer.

  • A ? B : C is called ternary operator.

    It basically means "if A is true, then B, else C"

    So this formula reads:

    chain.index* (IF loopindex("i")=1 THEN -dir ELSE dir)

  • I think what happens is that when you use one of the "Pick" events, the system actually loops through all instances and compares them one by one.

    So it takes the first instance, compares if .stt=choose(1,2)

    Then it takes the seconds instance, compares if .stt=choose(1,2)

    The problem is that the second time choose(1,2) may give a different number!

    Say for the first instance random number was 1 and for the second instance random number was 2. And as a result, both instances get selected and two bullets are fired!

    Here is an easy fix:

    rand=choose(1,2)

    System-> Pick EF_Start where stt=rand

    Or just use the Pick Random Instance event.

  • There may be errors in your .json file

    Could you share the project?

  • Maybe make them invisible or move off the screen on layouts where you don't need them?

  • 1. In line 80 you need to pass item number (item's position in the array, or InvCell.order number) to the "DropItem" function.

    For this you need to pick the correct cell, the one which is currently selected.

    Similar issue with "Use" function - you are passing Collectibles.AnimationFrame to the "SelectItem" function, which is incorrect, because by default Collectibles refers to all items. You need to first pick the correct instance of the Collectibles family first, the one which is selected.

    2. Same issue - you need to pass item number to the function.

    3. I tried that and it worked for me. The game didn't pause (because Wait doesn't actually pause the game), but the lines "Jim takes the note and reads it. etc...." appeared on the screen.

    4. If you pick up the note before the handkerchief, they end up in the same inventory slot. Not sure why.

    You can see it in debug mode - both sprites are in the second cell.

    I told you I don't like this inventory system. Integrating it into your game made it even more complex, it's now really hard to understand what's going on.