CJacobsSA's Recent Forum Activity

  • Ah, I hadn't thought of that! I can see how to do it now that you've mentioned it! Thank you!

  • Hello, I've got a problem I can't quite figure out with my inventory system. I looked in the FAQ sticky and didn't find an answer to my issue. Basically, I'm using an array to store 2 values: The slot it is in, and its item ID. I'd like to be able to swap that second value with another elsewhere in the array when the player clicks on the item in their inventory and drags it to another spot. It's kind of hard to describe what I want to happen in words so here are some doodles:

    Here's a representation of the array. The first row is the item slot, the second row is the item's ID. Each column together makes one inventory slot.

    The player clicks and drags an item from one slot to another in the game (represented by picking it up from the slot and attaching it to the mouse) and lets go.

    As a result, the two values swap places on the array. In the game this is represented by the two items swapping slots.

    The problem is that I don't know how to do that in the code. I would greatly appreciate the help because this has proven to be a real headscratcher for me.

  • That's very helpful, thank you!

  • Hi, I am making a completely shameless Terraria/Starbound ripoff (eventually it will be less shameless, I promise) and something I can't figure out is how to make the player only able to place blocks on a grid. I've figured out how to constrain their reach using a line of sight behavior on the player's hitbox object, but they can still be placed anywhere in space instead of snapping to the same 32x32 grid the tiles are on. I'm sure there is a solution here but I need your help to find it!

  • Nice! Both great solutions, thanks folks.

  • If Paddle.X <= (Your Lower Bound) | Set Paddle.X to (Your Lower Bound)

    If Paddle.X >= (Your Upper Bound) | Set Paddle.X to (Your Upper Bound)

    Thank you! That is a relatively easy solution!

    Much appreciated.

  • Hi! I'm making a breakout clone (well, it's a breakout clone right now) and I'm having a bit of trouble. The paddle is controlled by the mouse, but unlike being controlled by keys, I can't figure out a way to keep it within the boundaries (the green boxes). Currently it's set to just always follow the mouse's X position, which obviously won't work. As is, it's fine with just going right past the boundaries and off the screen.

    I have also tried making a big sprite/tiled bg and making it so the paddle only follows the mouse when it's over the sprite, i.e. inside the boundaries. But that only kind of worked, because moving too fast from one end to the other causes the mouse to leave the sprite before the paddle catches up to it on the next frame.

    I'm probably just having a brain fart, but I really can't figure it out. Any advice?

  • Ah, thank you! I figured it was just an expression I was overlooking. I was searching 'pick' when I should've looked for 'choose'. Much appreciated.

  • Relatively simple question, I hope. I'm sure it can be done, but I just can't figure out what I need to type to make it so.

    Let's say for example that my enemy has 5 attacks that it can do at various ranges. At close range, it can do attacks 1, 3, and 5. But at long range it can do 2, 4, and 5. In these cases, doing round(random(1, 5)) wouldn't work, because that would include the possibility of the other ranges' attacks in the result. I also can't rearrange the animations themselves, because there'd be no way to include attack #5 in both besides duplicating it, which I'd rather avoid. Is there a value I can type in to just say "set the variable to 1, 3, or 5"? Or do I have to do a workaround of some kind?

  • Thank you all for the suggestions! They were all very informative and helpful.

  • In my game, the player will be able to purchase upgrades to objects on specific layouts that persist throughout the game. In this case, an item in the player's house increases the filling speed of their EXP bar. The codebox is a global object that keeps track of variables that are important such as what level the upgrade-able objects are at, and what bonuses to distribute. The upgrade itself works just fine, the problem is that it triggers lines 105 and 107 again every time the player changes to a different layout. So the +5 to mainbar_speed becomes +10 on changing layout, then +15, etc.

    What am I doing wrong here? I assumed trigger once meant only once, but it seems to mean once on the current layout.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • EDIT: Never mind, I realized just now that I had the enemy's attack animation set to repeat, so line 55 never triggered even though it appeared like it did thanks to line 56! Whoops!

    Hi, in my game I would like for enemies to follow through with their attacks, instead of aborting them when the player gets out of range. The problem I'm having has a lot to do with how I have my enemy's code and state changing set up, I think. Here is the code for my example enemy:

    As is, line 56 makes it so that when the player gets out of range, the enemy goes back to the 'active' state and stops attacking. I'd like to remove this line and replace whatever I need to in order to make it so that if the enemy is attacking, they don't change states until the current attack is done. But I can't figure out for the life of me how to change my code to make that happen!

CJacobsSA's avatar

CJacobsSA

Member since 26 Sep, 2014

None one is following CJacobsSA yet!

Trophy Case

  • 10-Year Club
  • Email Verified

Progress

11/44
How to earn trophies