Josh @ Dreamland
|
|
Posted on: June 09, 2010, 09:00:53 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Hardly. I've worked on Thank You cards to six million people. My cousin's graduation party is Sunday, which I will apparently be attending. Today I took a trip north with my dad, solely to visit my grandparents. Made the mistake of committing my code so I could work on ENIGMA there from my laptop. Didn't have much time to do so, ultimately. What's more, I came back to a certain someone informing me that the code I committed mid-sentence doesn't compile. <___<"
No, the instance system is not done. But I do have a surprise for you all.
I've seen questions going around of how GM handles events. Specifically, questions regarding the order in which they are executed. I myself used to wonder what exactly went on to implement hspeed and vspeed that ruined my first slope-using platformer. Well, that won't be a problem in ENIGMA.
I have implemented a file for R4 that contains a list of all events, the code executed in them, and some other details and trivia. I know a few are thinking right now, "great, another document for Josh to not maintain." Well, HAH. This one will always be current. Why? Because it's the file ENIGMA actually uses to determine what events were passed.
This is a beautiful thing for a number of reasons, one of the most important being that anyone can correct an event or add an event that a new version of GM implements. This is a snippet of the file, for demonstration purposes:
beginstep: 3 Group: Step Name: Begin Step Mode: Special Case: 1
alarm: 2 Group: Alarm Name: Alarm %1 Mode: Stacked Sub Check: { if ((alarm[%1] == -1) or (alarm[%1]--)) return 0; }
# Keyboard events. These are simple enough.
keyboard: 5 Group: Keyboard Name: Keyboard <%1> Type: Key Mode: Stacked Super Check: keyboard_check(%1)
#...
step: 3 Name: Step Mode: Special Case: 0 Constant: { x += hspeed, y += vspeed; speed -= friction; vspeed += sin(gravity_direction * pi/180), hspeed += cos(gravity_direction * pi/180); }
#...
collision: 4 Group: Collision Name: %1 Type: Object Mode: Stacked Super Check: instance_number(%1) Sub Check: place_meeting(x,y,%1)
That code will serve to bring an end to the hard-coded, undocumented GM method of event management.
Anyway, I'm back to work.
|
|
« Last Edit: June 10, 2010, 10:49:33 am by IsmAvatar »
|
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
|
|
|
|
|
|
Josh @ Dreamland
|
|
Reply #4 Posted on: June 10, 2010, 01:55:53 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Indeed. Kinda laughed.
Anyway. This new instance system is beautiful. What was 55 lines is now 17. This unified iterator thing didn't look half as powerful on paper. Damn, what an idea.
|
|
|
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
|
|
|
|
|
IsmAvatar
|
|
Reply #7 Posted on: June 10, 2010, 11:29:55 am |
|
|
LateralGM Developer
Location: Pennsylvania/USA Joined: Apr 2008
Posts: 877
|
[root] order = beginstep, alarm, keyboard, step, collision
[beginstep] name = Begin Step group_id = 3 case = 1 group = Step mode = Special
[alarm] name = Alarm %1 group_id = 2 group = Alarm mode = Stacked subCheck = { if ((alarm[%1] == -1) or (alarm[%1]--)) return 0; }
; Keyboard events. These are simple enough.
[keyboard] name = Keyboard <%1> group_id = 5 group = Keyboard type = Key mode = Stacked superCheck = keyboard_check(%1)
;...
[step] name = Step group_id = 3 case = 0 mode = Special constant = { x += hspeed, y += vspeed; speed -= friction; vspeed += sin(gravity_direction * pi/180), hspeed += cos(gravity_direction * pi/180); }
;...
[collision] name = %1 group_id = 4 group = Collision type = Object mode = Stacked superCheck = instance_number(%1) subCheck = place_meeting(x,y,%1) Although your format is already very much like YAML.
|
|
« Last Edit: June 10, 2010, 11:37:17 am by IsmAvatar »
|
Logged
|
|
|
|
IsmAvatar
|
|
Reply #8 Posted on: June 10, 2010, 12:23:52 pm |
|
|
LateralGM Developer
Location: Pennsylvania/USA Joined: Apr 2008
Posts: 877
|
To make it more accurate in YAML, a few changes: * Documents should begin with --- and may end with ... * Use - to indicate ordered lists. * a tree structure is achieved by starting the parent node's value with a newline, not a value * As such, the value should be given a variable, which I will call 'Group Id' * The linux-friendly id-name (e.g. 'beginstep') can either stay (in which case it'd be largely lost as simply an element) or become a scalar value belonging to a variable. * Multiline blocks should either use pipe or right angle bracket, depending on if you wish to preserve newlines and spacing, or replace newlines with spaces (e.g. a simple block of quoted text), respectively, and each line of the block should be indented * To avoid complications with [] and such in code, code should either use the multiline block mentioned above, or single quote the code, doubling any internal single quotes (that is, two single quotes, not a double quote): 'wtf''quote'
--- -beginstep: Group Id: 3 Group: Step Name: Begin Step Mode: Special Case: 1
-alarm: Group Id: 2 Group: Alarm Name: Alarm %1 Mode: Stacked Sub Check: '{ if ((alarm[%1] == -1) or (alarm[%1]--)) return 0; }'
# Keyboard events. These are simple enough.
-keyboard: Group Id: 5 Group: Keyboard Name: Keyboard <%1> Type: Key Mode: Stacked Super Check: keyboard_check(%1)
#...
-step: Group Id: 3 Name: Step Mode: Special Case: 0 Constant: | { x += hspeed, y += vspeed; speed -= friction; vspeed += sin(gravity_direction * pi/180), hspeed += cos(gravity_direction * pi/180); }
#...
-collision: Group Id: 4 Group: Collision Name: %1 Type: Object Mode: Stacked Super Check: instance_number(%1) Sub Check: place_meeting(x,y,%1) ...
|
|
« Last Edit: June 10, 2010, 02:08:40 pm by IsmAvatar »
|
Logged
|
|
|
|
Josh @ Dreamland
|
|
Reply #9 Posted on: June 10, 2010, 01:08:13 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
-Sigh- I like the format how it is. It's humanly readable now without the %YAML, ---, -, \nGroup ID:, and .... In fact, it's close enough to YAML that I'm comfortable calling it that anyway. Or at least YAML-like. I'll outline all six differences in the docs regarding the events file, if you like. YAML highlighters are grotesque at best; I'd get better highlighting if I named the file *.sh. I don't see much benefit to trying to comply...
|
|
|
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
|
|
|
|
|
Josh @ Dreamland
|
|
Reply #12 Posted on: June 15, 2010, 01:01:52 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
There are parsers for YAML taking thousands of lines and requiring several awkward symbols to be added to my file, which I think is beautiful as it is. The parser for it barely takes 200 lines. It's just not that complicated. YAML introduces what seems to be hundreds of features we don't use, requires symbols to make explicit what should be implied, and lacks (for sake of versatility on a scale not required here) a feature the current format uses. It would be easier for me (perhaps even at this point) to include some huge YAML nonsense, but I don't think I'll be doing so. If Ism, however, indicates in any way an intention to share this file with me, I will, via a simple regexp, make the file into YAML, and either revise my parser to use YAML's | and >, or perhaps even break habit and include some fucking huge thing and piss with its API to get the info I need. The question is whether I want the format to be YAML or to be YAML compliant, assuming I want it to be related to YAML at all (which I slightly do, since Ism reports that the format being YAML-ready would slightly improve her odds of working with it).
Ism: That's a bug, yes. Should work like GM. And yes, Shift wouldn't change anything; I get the keycode raw and convert it myself via large array. This array is -not- cross API, meaning it may work find on Winblows even though I screwed up on X. I'd prefer not to add checking for both at first glance due to the unfolding of code that would have to transpire (either unfolding an array by segment, keeping a second array, or just adding a special check), but I will look into doing so all the same. If I did, I would probably mandate that a correction be implemented just above the API level (as soon as I have a key code), so no additional checking is done each keyboard_check. Hoping this isn't the work of XLookupKeyCode, or whatever that function was.
|
|
« Last Edit: June 15, 2010, 11:04:56 am by Josh @ Dreamland »
|
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
|
|
|
|