Josh @ Dreamland
|
|
Posted on: November 06, 2010, 10:42:18 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
I see what you mean, Rusky. For a little bit I was thinking about doing something like that (C takes a lot of heat over the issues rising from copy-pasted macros, of course), but I don't think I should. The only reason I'm keeping any sort of macros is because of ENIGMA's C heritage. If it wasn't for that, they'd be expression based if they were in at all, but my reason for wanting preprocessors at all at this point isn't for macros. My number one concern is the #if directive. The rest are just kind of there. The reason I want #if is for altering behavior from platform to platform. I was discussing with marbs the other day the implications of ENIGMA compiling for iPhone, and he mentioned motion detecting devices.
Originally, I intended to offer controller_get_angle_x/y/z() and controller_get_shaken(). On Windows, they'd all return zero unless an applicable device was connected. On Wii, they'd all have an accurate return. On iPhone, _angle _x and _y would work, as well as _shaken (same for android). Issue is, what if that isn't enough? What if having a shake is a critical part of the game, and they would have to work around it with multiple lines of code (likely to test for a key combo instead)?
I like a number of features for Lisp's macros, but my focus is really more on preprocessors right now. Maybe we can pile on a new macro system as well, later. But for now I'm more concerned about being able to say
[[If Target_Device == eDev_iPhone]] if (controller_get_shaken()) earthquake(); [[else]] if (keyboard_check(vk_control) and keyboard_check_pressed(ord("E"))) earthquake(); [[fi]]
Granted, that's not a very good example, since a simple "or" could technically have sufficed with little overhead. But it conveys the basic idea.
Say we want our mobile game to always be oriented correctly, and which direction has the high resolution doesn't really matter.
Persistent Controller Step Event: [[if Target_Device == eDev_iPhone or Target_Device == eDev_Android]] int az = controller_get_angle_z(); if (az > 45 and az < 135 or az > 225 and az < 315) view_wview[0] = display_get_width(), view_wview[0] = display_get_height%
|
|
« Last Edit: November 06, 2010, 06:38:14 pm 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
|
|
|
|
Josh @ Dreamland
|
|
Reply #2 Posted on: November 06, 2010, 02:00:43 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
"__preproc__ int x = 2;" "Also, mandatory is official #pragma once support"
wat is this i dont even
|
|
|
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: November 06, 2010, 03:14:57 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
There's no point in using real types for macros... It's strictly interpreted... it'd just be more work. #pragma once won't help us; this is for EDL in objects and scripts, which are always included once manually (they can't be included by the user...) As for using ifdef and endif instead of {}, it's really a matter of preference. I like it text-based because you can always tell the preprocessor from the rest of the code. If we're going to be using [[]]. [[]]{} would look ugly. I'm opposed to so many _ in everything, but I suppose I'm not against using a word and {} instead of [[if]] [[fi]], if that's what everyone else wants.
Moreover, has anyone really been far as decided to use even go want to do look more like?
|
|
|
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 #7 Posted on: November 06, 2010, 06:36:47 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
I see what you mean, Rusky. For a little bit I was thinking about doing something like that (C takes a lot of heat over the issues rising from copy-pasted macros, of course), but I don't think I should. The only reason I'm keeping any sort of macros is because of ENIGMA's C heritage. If it wasn't for that, they'd be expression based if they were in at all, but my reason for wanting preprocessors at all at this point isn't for macros. My number one concern is the #if directive. The rest are just kind of there. The reason I want #if is for altering behavior from platform to platform. I was discussing with marbs the other day the implications of ENIGMA compiling for iPhone, and he mentioned motion detecting devices. Originally, I intended to offer controller_get_angle_x/y/z() and controller_get_shaken(). On Windows, they'd all return zero unless an applicable device was connected. On Wii, they'd all have an accurate return. On iPhone, _angle _x and _y would work, as well as _shaken (same for android). Issue is, what if that isn't enough? What if having a shake is a critical part of the game, and they would have to work around it with multiple lines of code (likely to test for a key combo instead)? I like a number of features for Lisp's macros, but my focus is really more on preprocessors right now. Maybe we can pile on a new macro system as well, later. But for now I'm more concerned about being able to say [[If Target_Device == eDev_iPhone]] if (controller_get_shaken()) earthquake(); [[else]] if (keyboard_check(vk_control) and keyboard_check_pressed(ord("E"))) earthquake(); [[fi]] Granted, that's not a very good example, since a simple "or" could technically have sufficed with little overhead. But it conveys the basic idea. Say we want our mobile game to always be oriented correctly, and which direction has the high resolution doesn't really matter. Persistent Controller Step Event: [[if Target_Device == eDev_iPhone or Target_Device == eDev_Android]] int az = controller_get_angle_z(); if (az > 45 and az < 135 or az > 225 and az < 315) view_wview[0] = display_get_width(), view_wview[0] = display_get_height(); else view_wview[0] = display_get_height(), view_wview[0] = display_get_width(); [[fi]] Granted, that code's kinda rough. But that's the kind of thing I'm talking about. You don't exactly want it doing that on Wii.
|
|
|
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 #9 Posted on: November 08, 2010, 05:13:05 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Well, yes, but I'd much prefer directives to be inside something other than ^#(.*)$. The [[ and ]] seem to make for prettier code. (Besides, I'm pretty much doing away with #include: I may steal require from other languages.)
|
|
|
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: November 09, 2010, 06:43:37 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Since ENIGMA is responsible for understanding those macros to correctly parse its engine file, I would have to go out of my way to stop users from accessing macros like TARGET_IPHONE_SIMULATOR from your example. I of course have no intention of doing so.
So yes.
|
|
|
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 #14 Posted on: November 09, 2010, 07:19:56 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Yep.
|
|
|
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
|
|
|
|