InDWrekt's Recent Forum Activity

  • Also, if you could post the error message you are getting when trying to open the project I might be able to figure out how to solve it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I built the project in the current stable release (r218) of C3. Is that what you are using to try to open it? There are no plugins so there shouldn't be anything preventing you from opening it.

    Yes, I was able to open yours but I didn't really take any time examining it. I wanted a clean example so the code would be clear.

    I understand that you want the "Enemy" to move but that doesn't change anything. "Player" or "Enemy" are just semantics and the code is all the same.

  • I'm not sure if the is the BEST way to do this because I have never taken the time to build a hex-based game in Construct but since I noticed this topic has been here for a while without an answer, I figured I would try my hand at it. The attached example uses a dummy object with the path finding behavior to set the path of the red character. The hexagon object has the solid behavior but it is disabled where the player is allowed to travel. To Ensure the character can only land on empty spots, you need to enable the solid behavior of occupied spots and regenerate the obstacle map.

    Also, you will notice a bunch of disabled events/actions. If you enable them, the player movement will be restricted to a set number of moves.

    drive.google.com/file/d/1N3yvrCkc3uxw74kD5VYxARlXavN7sUqE/view

  • If you can attach your project, I can take a look at it for you.

  • drive.google.com/file/d/1bFw9URYwNhyfiG_TbDdZSrYoPcnlwzZX/view

    Take a look at this example. There are 2 layouts. One that has very minimal actions. All you do is click the red ball to kill it but each time it is clicked, it becomes invulnerable for 5 seconds.

    The other uses an 8 direction controlled player that will trigger the ball to be invulnerable. It also causes the ball to flash when it is invulnerable.

  • GamerDude96, a Boolean variable as mentioned by Maverick1912 is a good way to handle this issue but requires you to code when to disable it. I prefer to use an integer variable that stores the time to end invulnerability. When the character becomes invulnerable, you would set:

    invulnerableUntilTime = time + X seconds

    Then, when damage would be dealt to the character, you would check if:

    time > invulnerableUntilTime

    With a Boolean, you still have to set the value and check it but this completely removes the need to set the Boolean value to false. By nature of the passage of time, the invulnerability will be remove.

  • the.sand, Don't think of it as an array. Think of it as a stack. You are adding and removing actions from the stack. Only the action on top of the stack is active. The others activate as the top action is removed and the next is uncovered.

    Also, if you do take a look at the example by calminthenight, you will notice without the stack, more events and variables are required just to get 2 directions to work. To get the other 2 directions, you would have to double both the variables and events. That makes the code more difficult to work with and debug when something goes wrong. It is a fine example if you don't want to make use of the stack but, you can see the event sheet can very quickly become hard to follow.

  • calminthenight The built in movement controls don't allow for overriding one direction when another is pressed in the way the OP describes. If you try it you will see, that up and down will override left and right but left and right won't override up and down. Also, opposing directions cancel each other out. The OP wants the most recent pressed directional key to move the character even if another key is still pressed.

  • I don't really understand the need for the individual Booleans you are defining. In every place you would use your Boolean, you can just reference if the key is down. The added Boolean value just bloats the system and makes it harder to read/debug.

    As for the question about keeping track of what is the last key pressed, you could implement a stack which stores key press information and check the last key on the stack when trying to move. See the attached example. The stack is built using an array and when an arrow key is pressed, the direction is added to the front of the stack. When the key is released, the direction is removed. Then, to determine the direction the player will move, the front item is checked.

    If you really do need the Boolean values, just replace the "is down" conditions with your Booleans.

    drive.google.com/file/d/1unE5jG0C7lq8iU_Lrji5ltvD616Wq9H-/view

  • drive.google.com/file/d/11KwhVVbjS2fB_KaTPDuKY-CLArBW6Wf6/view

    Hopefully this example gets you what you need. Just click the card and it will flip over.

  • I don't have an answer to solve your problem but I do think you uncovered a bug. See the 2 attached pictures.

    I debugged your project to see if I could see what was going on and this is what I found:

    I stretched the bottom left corner of the mesh to the left until it was nearly touching the left side of the screen. I then rotated it until the 2 left sides were aligned with each other. In the debugger, I took screenshots of the oleft and sprite2(0).x values.

    The first image shows the x coordinate of the Sprite2 object on the far left side which should be your sprites bboxleft value. The second image shows the the value that was stored in the oleft variable. This should be the same as the first value but they definitely aren't. I am not an expert with the mesh object but from all I can see, your events should work fine, the system is just not getting the correct bounding box values from a mesh that has been deformed and then rotated.

    I would suggest you submit this as a bug.

  • First thing I am going to say is, you may want to take a step back and work through a few more basic tutorials before trying this project. You may not be ready yet. Each answer seems to lead to more questions which means you really could use some more experience with the engine (and game design in general). This isn't meant to discourage you. In fact, struggling with a bigger project than you are ready to complete is the more discouraging thing here and after getting some more knowhow first will lead to a better project in the end.

    That being said, Here is an example file that I hope can show you how to solve these problems.

    drive.google.com/file/d/1vXpKAC46NGnCxcb4O7n_P8i31WQ1m9dB/view

    The game freezing is caused by an endless loop. This means the while loop used to draw your ray is never finding an end point so it is continuing off into infinity. The events that happen after the loop are never reached and eventually the computer will run out of memory. This is solved simply by guaranteeing the ray stops growing at some point. In the example, I give it a max length as one of the conditions for the while loop. Any time you are using a while loop in your game, if the game freezes, the first thing to check is if there is an endless loop.

    Again, for the angle of the arrow, I will have to make some assumptions. I assume you are using the orbit behavior. This would seem to make sense because you want it to orbit the heart. However, some of the functionality of the orbit behavior (the way it rotates the object for example) is not compatible with the result you are looking for. For my example, I found it better to use the rotate behavior and set the origin of the arrow a little to the left of the sprite. To see this, edit the sprite and look at the position of the origin. If you then set the position of the arrow to the position of the heart, the rotate behavior will rotate the arrow around the arrows origin causing it to appear to orbit the heart. I then pinned the arrow to the heart, without allowing the pin to set the rotation, to ensure the arrow stays with the heart.

    There are of course other ways to fix the angle. For example, you could disable the orbit functions rotate property and use events to manually set the angle. But I'm lazy so I would rather not do that extra work.

    You'll notice the player uses a variable to ensure the teleport isn't automatically triggered on arrival at the end destination.

InDWrekt's avatar

InDWrekt

Member since 19 Sep, 2011

Twitter
InDWrekt has 7 followers

Trophy Case

  • 13-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies