Square movement path with rounded corners

0 favourites
  • 3 posts
From the Asset Store
Gravity Square is a game where I aim to reach the square at the polka dot door :)
  • I have a ship patrolling around in a square, with rounded corners. Is there a better way to do this than what I have here?


    I have tried to make a function to add 1 degree, repeat 90 times, but it only runs once because of the run once condition. The same problem occurred when I tried to use an OR block to save on events, but the OR block doesn't work with run once.

    If I don't use run once, my ship starts going in circles when it hits a corner.

    Also, I ran into a problem in Firefox and IE, it seems like the turn rate is tied to fps, so when fps drops the ship starts swimming off the edge of the screen.

    Live Demo: mbcoffice.com/construct/index.html

    Edit: Ack links don't work. Typing them out in plaintext

  • Use invisible sprites located right before the turns. When the ship collides with those sprites add 90 to an instance variable of the ship called "targetAngle". Then every tick rotate the ship toward the targetAngle.



  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks! Very clean solution.

    I found the tutorial on dt after looking at your capx, probably should have read that before I started.

    I stayed with 4 events that "trigger once" for the corners though. I wanted to avoid using extra objects and collision calculations (assuming that events require less overhead - please correct me if I'm wrong!). I guess if I had many ships with different paths, I should use collision objects.

    At least I got rid of the double location conditions as a side effect of using a variable target angle. By setting the variable start value to 90 less than my initial heading, the ship will start on the correct heading without turning right away when the layout starts.


    Thanks again for your input!

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