John Cutter's Forum Posts

  • Thanks ROJOhound, I think I'm starting to get it.

    Is there a difference between For Each mySprite and Pick All mySprite? (I know the latter allows me to check PickedCount...)

  • I've read some other posts on this subject but I'm still confused. Could someone explain it to me?

    Let's say I have a sprite called mySprite, with an instance variable called "big". There are multiple instances on the screen.

    This works:

    if mySprite.big = 1 then Set Size to 25x25.

    It's my understanding that "mysprite.big = 1" iterates through all the mySprite instances and "picks" the ones where big = 1. In that code block anything I do to mysprite will only affect the picked sprites. Is that correct?

    So when do I need to do this:

    For Each mySprite

    mySprite.big = 1

    Then [Do Something]

    Tagged:

  • Let's see the actual event sheet, and also is it actually loading i.e. is the key press condition correct and working?

    I'll take a look at dop2000's example next.

  • I thought this one would be easy. It's so straightforward I don't know why it's not working. The AI hasn't been helpful this time so I turn, once again, to the geniuses here in the forum!

    Just to get the basics of my one level Undo working I added:

    + Keyboard: On Space pressed

    -> System: Save game to slot "undo1"

    -> System: Create object fam_cards

    + Keyboard: On Z pressed

    + Keyboard: Ctrl is down

    -> System: Load game from slot "undo1"

    Why doesn't this work? I press space to create a sprite, then press CTRL+Z and the sprite is still there.

    Tagged:

  • I finally decided to snap single selected sprites directly to my grid. For multiple selected sprites, I now set an anchor pin on the lowest selected sprite, pin all selected cards to it, snap the anchor to the grid, and then unpin everything.

    At first, I was trying to do all of this in a single action, which wasn’t working. Adding small (0) waits seems to have fixed it, but it feels messy.

    Is there a better way to handle this in Construct 3, or is this standard practice?

  • Thanks, dop2000! I hadn't seen this tutorial!

  • I've been working on this problem for the last two days and I can't figure it out. Yesterday, I turned to the new Claude 3.7 LLM and it gave me some super helpful pseudocode that does everything perfectly... except my sprites don't align to the 32x32 grid in my level editor. (When I try to drag one sprite under another one, they are not left aligned.) I think this is due to sprite offsets from my pin anchor, but everything I've tried to do to fix this has failed.

    What the Code is Supposed to Do:

    - Allow me to select sprites using single click, or CTRL click

    (I have other events that do multi-select with a rectangle)

    - The sprites snap to my 32x32 grid while being dragged

    spr_card = my card sprite

    fam_cards = family with spr_card as only member (has selected variable, 1 = selected)

    spr_anchor = anchor for moving multiple cards

    (spr_card and spr_anchor have a center image point)

    My Code:

    ----+ System: Every tick

    -----> System: Set snapped_x to snap_enabled ? round(Mouse.X ÷ gridSize) × gridSize : Mouse.X

    -----> System: Set snapped_y to snap_enabled ? round(Mouse.Y ÷ gridSize) × gridSize : Mouse.Y

    -----> spr_anchor: Set position to (snapped_x, snapped_y)

    ----+ Mouse: On Left button Clicked on spr_card

    ----+ spr_card: Pick top instance

    --------+ Keyboard: Ctrl is down

    ---------> spr_card: Set selected to Self.selected = 0

    --------+ System: Else

    ------------+ spr_card: selected = 0

    -------------> fam_cards: Set selected to 0

    -------------> spr_card: Set selected to 1

    ------------+ fam_cards: selected = 1

    -------------> fam_cards: Pin_Edit Pin to spr_anchor (X: True, Y: True, angle: True, width: No, height: No, Z: False)

    ----+ Mouse: On Left button released

    -----> spr_card: Pin_Edit Unpin

    Tagged:

  • Just a quick follow-up.

    We had company for a few days so I was only able to try dop2000's suggestion yesterday. It works perfectly! I noticed that this only adds "CoveredBY" and not "Covering" but after a little thought, and AI confirmation, it became clear that I don't need to keep track of which cards the current card is covering.

    I had worked on this problem for two days and got help from ChatGPT, Claude Sonnet, Deepseek and several other AIs. Many couldn't give me working code at all, but after a lot of iteration I had something that *almost* worked. It was about 24 events and I still hadn't added extra code to get rid of the trailing "," in every string.

    The solution from dop2000 was only FOUR events, and there's no trailing comma.

    NOTE: I noticed that the solution included some strange question marks, so I uploaded a screenshot to ChatGPT and asked for an explanation. It provided me with a thorough and very understandable description of ternary operators and how they work!

    Thanks again, dop2000!!

  • Wouldn’t it be simpler to just save the type and position of each card?

    I'm already saving the positions, angles, and instance variables for each card. I need to know covering relationships between all the cards as I plan to write a simulator that randomly "plays" each level a thousand times, just using the data. This will give me stats like "average cards remaining" that I can use to help me test my 200+ levels.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you dop2000 and ROJOhound!!

    These are SO MUCH easier than the suggestions I was getting from ChatGPT. I spent two days iterating on this problem and it seems like the solution was pretty simple.

    Strangely, I asked ChatGPT to help me create a pretty complex interactive bezier feature for my editor, and this only took an hour or so!

    (I can add or remove cards on the fly, and they will space themselves, with the appropriate angles, along the curve. The three dark circles are handles and the cards adjust as I drag them around! Without the AI I wouldn't even have ATTEMPTED this feature.)

  • I'm working on a solitaire level editor. ChatGPT has been a TREMENDOUS help on this project but we're stuck on something that I thought would be fairly simple. I'm hoping one of you experts can help!

    What I'm Trying to Do:

    When I SAVE my layout I want to iterate through all the cards and, using zIndex, figure out which cards are Covering and which cards are CoveredBy the current card. These will then get saved in instance variables, like this:

    card_spr.Covering = "3, 5, 7" (this card is covering cards 3, 5, and 7)

    card_spr.CoveredBy = "" (this card isn't covered by any cards)

    ChatGPT suggested that I create 2 families with spr_card as the only member. fam_cards has all the instance variables. fam_cards2 is for the inner loop.

    This was working, but I stupidly used Construct 3's UID in my events. This doesn't work for SAVING and LOADING, so I created a new instance variable: fam_cards.CardID and I increment this every time I create a new sprite. (It gets saved with the level.)

    But if I put CardID in the sprite my families can't access it. And if I put it in fam_cards.CardID then I can't reach it with fam_cards2.CardID.

    Any suggestions? Is there an easier way to do this?

    Code Before I made my own "CardID"

    + System: For each fam_cards

    -> fam_cards: Set Covering to ""

    -> fam_cards: Set CoveredBy to ""

    ----+ System: For each fam_cards2

    --------+ fam_cards2: Is overlapping fam_cards

    ------------+ System: fam_cards2.ZIndex < fam_cards.ZIndex

    -------------> fam_cards: Set Covering to fam_cards.Covering & fam_cards2.UID & ","

    ------------+ System: Else

    -------------> fam_cards: Set CoveredBy to fam_cards.CoveredBy & fam_cards2.UID & ","

  • Thanks for the reply, envoys!

    I'm a longtime Construct user, but basically a 63 year old idiot. ;-) So I'm confused about what you mean by a "camera". I assume we are talking 2D and not 3D, right?

    Is your "camera" a block of code (or function) that controls the viewport?

  • Just a quick follow-up that might help someone else in the future...

    I solved this issue by rejiggering my array to put the zIndex values in the first column. Then, before pasting the cards, I do a sort. Unless I'm missing something, array sorts always happen on the first column only, hence the re-jiggering.

    This way the cards get created one-by-one with the appropriate z ordering.

  • For cutscenes and game events I ended up writing a camera with 23 active parameters - zoom and movement via tween or lerp with various curves, optional input blocking and types of hero tracking and forced scrolling. This saves a lot of time now.

    envoys: Can you describe your cutscene camera a little bit? The story I want to tell is pretty visual with lots of "sight gags". I can't afford to pay for all that animation so I'm thinking about using static comic panels and the timeline editor to scroll and zoom as needed. (Maybe with some limited animations here and there.)

  • Thanks for the reply, winkr7! I'm going to have to study up on templates. I've never used them and I have no idea what they even do!

    I wish I had some tips/tricks to share to return the favor. Hmmm. This might be one! On my last game I added two text files to my project and kept them on my UI. One was for bugs, and the other was a ToDo & Ideas list. It was nice to keep everything together and I never had to leave Construct!