Pages: [1]
  Print  
Author Topic: Around the Clock  (Read 2735 times)
Offline (Male) Josh @ Dreamland
Posted on: June 09, 2010, 09:00:53 PM

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

View Profile Email
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:

Code: ( (Unknown Language)) [Select]
beginstep: 3 Group: Step Name: Begin Step Mode: Special Case: 1alarm: 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
Offline (Male) Rusky
Reply #1 Posted on: June 09, 2010, 09:52:08 PM

Resident Troll
Joined: Feb 2008
Posts: 960
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
"great, another document for Josh to not maintain parse." :P
Logged
Offline (Male) Josh @ Dreamland
Reply #2 Posted on: June 09, 2010, 10:03:31 PM

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

View Profile Email
:troll:

u toll
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 (Male) retep998
Reply #3 Posted on: June 09, 2010, 10:16:07 PM

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
Quote
What's more, I came back to a certain someone informing me that the code I committed mid-sentence doesn't compile.
I'm glad that someone isn't me :D
Quote
u toll
Logged
Offline (Male) Josh @ Dreamland
Reply #4 Posted on: June 10, 2010, 01:55:53 AM

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

View Profile Email
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
Offline (Male) notachair
Reply #5 Posted on: June 10, 2010, 07:02:35 AM

Definitely not a chair
Contributor
Joined: Feb 2008
Posts: 299

View Profile
What is that --> I see up top doing :raise:
Logged
Offline (Unknown gender) score_under
Reply #6 Posted on: June 10, 2010, 07:40:11 AM

Member
Joined: Aug 2008
Posts: 308

View Profile
:troll:

u toll

[tr. "Oh great."]
Logged
Offline (Female) IsmAvatar
Reply #7 Posted on: June 10, 2010, 11:29:55 AM

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 886

View Profile Email
Code: (INI) [Select]
[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
Offline (Female) IsmAvatar
Reply #8 Posted on: June 10, 2010, 12:23:52 PM

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 886

View Profile Email
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'

Code: (YAML) [Select]
---
-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
Offline (Male) Josh @ Dreamland
Reply #9 Posted on: June 10, 2010, 01:08:13 PM

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

View Profile Email
-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
Offline (Unknown gender) Micah
Reply #10 Posted on: June 12, 2010, 08:08:31 PM

Resident Troll
Joined: May 2008
Posts: 129

View Profile
I don't see much benefit to trying to comply...
There are good libraries for YAML written already. I'd say that's a pretty huge benefit.
Logged
Offline (Female) IsmAvatar
Reply #11 Posted on: June 14, 2010, 07:54:22 PM

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 886

View Profile Email
Bug:
While holding down the Z key, the following function calls give the following return values
//uppercase Z
keyboard_check(ord('Z')) = 0
keyboard_check(90) = 0
//lowercase Z
keyboard_check(ord('z')) = 1
keyboard_check(122) = 1

GM checks the uppercase ('Z' or 90). Enigma should probably emulate this behavior. I wouldn't object to both uppercase and lowercase returning true on key down, since the lowercase is never used, and can be a source of confusion.

Accompanying the key with the Shift key does not alter these results. (that is, shift+z does not trigger uppercase 'Z' to return true, although lowercase 'z' continues to return true.
Logged
Offline (Male) Josh @ Dreamland
Reply #12 Posted on: June 15, 2010, 01:01:52 AM

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

View Profile Email
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
Pages: [1]
  Print