Pages: 1
  Print  
Author Topic: Use Paths in ENIGMA.  (Read 31736 times)
Offline (Unknown gender) time-killer-games
Posted on: June 24, 2013, 09:35:58 pm
"Guest"


Email
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
« Last Edit: June 24, 2013, 09:50:42 pm by time-killer-games » Logged
Offline (Unknown gender) TheExDeus
Reply #1 Posted on: June 25, 2013, 02:27:53 am

Developer
Joined: Apr 2008
Posts: 1860

View Profile
You can manually use paths now too. Purely in ENIGMA. Create:
Code: [Select]
t=0;Draw (or step):
Code: [Select]
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).
« Last Edit: June 25, 2013, 02:30:28 am by TheExDeus » Logged
Offline (Unknown gender) time-killer-games
Reply #2 Posted on: June 25, 2013, 08:52:03 am
"Guest"


Email
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...
Logged
Offline (Male) Goombert
Reply #3 Posted on: June 25, 2013, 10:19:15 am

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2991

View Profile
Deus, you people that like to do that with one script frighten the shit out of me :P
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #4 Posted on: June 25, 2013, 01:32:57 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
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.
Logged
Offline (Unknown gender) time-killer-games
Reply #5 Posted on: June 29, 2013, 12:12:54 pm
"Guest"


Email
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.

Code: [Select]
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}
Logged
Offline (Unknown gender) TheExDeus
Reply #6 Posted on: June 29, 2013, 03:31:03 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
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.
Logged
Offline (Male) Josh @ Dreamland
Reply #7 Posted on: June 30, 2013, 06:58:43 am

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
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).
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) TheExDeus
Reply #8 Posted on: June 30, 2013, 07:09:51 am

Developer
Joined: Apr 2008
Posts: 1860

View Profile
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.
Logged
Pages: 1
  Print