| Welcome to the Game Maker Cookbook. We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Strafing in Top-Down View | |
|---|---|
| Tweet Topic Started: November 14, 2008, 7:34 pm (3,307 Views) | |
| Poris | November 14, 2008, 7:34 pm Post #1 |
|
Administrator
|
How to make an object strafe around the mouse in Top-Down View Made by Daniel Seabra Requires PRO version of Game Maker. Definition of Strafing:
Problem You want the player strafe when you press down the left (and right) key(s) (assuming the player is looking at your mouse) and your game is top-down. Solution The following code should take place in the step event:
Discussion This code takes advantage of the use of lenghtdir_x and lenghtdir_y, which are lamentably only be able to be used on the PRO version of Game Maker. These functions allow us to calculate where to strafe and how much distance. The variable speed should be replaced with your number for speed. [/code] Edited by Poris, November 14, 2008, 7:46 pm.
|
![]() |
|
| AndrewYY | July 31, 2009, 4:59 pm Post #2 |
|
the lengthdir functions convert polar coordinates into x,y coordinates. With a tiny bit of math, they can be emulated:
Edited by AndrewYY, July 31, 2009, 5:00 pm.
|
![]() |
|
| Snuffypot11 | September 2, 2011, 9:17 am Post #3 |
|
Ok so I'm new to GML as I've used D&D, but I have been working on my own top down game and this is the code I'm using in a step event on my character.
In addition to this of course:
|
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Intermediate · Next Topic » |






1:56 PM Jul 11