Pages: 1
Author Topic: Use Paths in ENIGMA.  (33,429 Views)
Offline (Unknown gender) time-killer-games
Guest


Email
Posted on: June 25, 2013, 02:35:58 AM
I created a small program in enigma that can allow you to use paths
in enigma.

screenshot - http://db.tt/zGozvsOn
download - http://db.tt/mfJQ10ag

1) Open your gm project then save it as an egm.

2) Open and extract the egm file with an archive viewer such as 7zip

3) Open the extracted paths folder. Notice you'll find PTH file(s) in there.

4) Run my converter exe or if you aren't on windows open and run the
converter's source gm81 from enigma/lgm.

5) Select the PTH file from the paths folder you extracted earlier and
open it in the Open File dialog.

6) When it's done processing your PTH file, a GML file should be generated.

7) Open, select all and copy the contents of that GML file in a raw text
editor i. e. notepad.

8) Paste the create event code in the create event of your object that
follows the path.

9) Paste the step event code into the step event of that object.

10) Done. Your object should now be following an absolute path while
continuing from its start position as its end action. If you want it to be
relative or have a different end action it can be done easily by editing the
output step event code.

Cheers!
~Samuel
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #1 Posted on: June 25, 2013, 07:27:53 AM
You can manually use paths now too. Purely in ENIGMA. Create:
t=0;Draw (or step):t+=0.01;
if (t>1) t=0;
x=path_get_x(path_0,t);
y=path_get_y(path_0,t);
draw_circle(x,y,20,0);
draw_path(path_0,x,y,true);
Good job though. Sadly you can't make curved paths work with this, but at least the speed is consistent (it is in linear paths in ENIGMA too, but curved paths speed up and slow down even when they shouldn't, that was a problem I and Josh never really solved).

edit: Also nice how you didn't use any objects and just room create code. Brought back good old days when in GMC there were competitions to make "one script games", in which you made a game as complex as possible using just one script (usually without using any object_add functions, so you made your own instance system and so on).
Offline (Unknown gender) time-killer-games
Guest


Email
Reply #2 Posted on: June 25, 2013, 01:52:03 PM
Thanks for the feedback. :) Though I could've sworn I've tried using path_get_x/y and it didn't work but I'll take your word for it. :) I'll use your code instead its much simpler...
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #3 Posted on: June 25, 2013, 03:19:15 PM
Deus, you people that like to do that with one script frighten the shit out of me :P
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #4 Posted on: June 25, 2013, 06:32:57 PM
We could create a competition like that. ENIGMA doesn't have resource manipulation functions (for objects that is) so can't cheat. You can create sprites by rendering on surfaces (you can't load sprites either, everything must be one script).

time-killer-games: I tested the functions before I posted. When you set the path to linear it works perfectly fine (even the speed parameter for points), but with curved paths it sadly doesn't have that constant speed.
Offline (Unknown gender) time-killer-games
Guest


Email
Reply #5 Posted on: June 29, 2013, 05:12:54 PM
Correct me if I'm wrong but this code works perfectly with curved paths. It's what I used in my isometric example which is on the enigma games page.

if (i>1)
{i=0
x=path_get_x(path_0,i)
y=path_get_y(path_0,i)}
if (point_distance(x,y,path_get_x(path_0,i),path_get_y(path_0,i))>=path_get_speed(path_0,i)/100*path_speed)
{move_towards_point(path_get_x(path_0,i),path_get_y(path_0,i),path_get_speed(path_0,i)/100*path_speed)}
else {i+=0.01}
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #6 Posted on: June 29, 2013, 08:31:03 PM
Well that will work as the speed will be controlled by move_towards_point. On the other hand the points from path_get_x/path_get_y will be closer or more separated depending on the place on the path. If it worked correctly then you wouldn't need that move_towards_point, it would work with the code I posted.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #7 Posted on: June 30, 2013, 11:58:43 AM
HaRRi, have you tried just defining an empty path_start() at the global scope, then defining an actual path_start inside the structure your path extension creates? The [snip]this[/snip] object will be the current instance cast to your structure; to get an object_basic/higher tier, you'll just need to access the instance event iterator.

It could be a temporary solution (since this damn compiler is taking so long).
Offline (Unknown gender) TheExDeus

Developer
Joined: Apr 2008
Posts: 1,860
View profile
Reply #8 Posted on: June 30, 2013, 12:09:51 PM
I haven't tried anything. I also don't really have problems with it doing it the way I do it now. So I can wait until the compiler is finished.
Pages: 1