Josh @ Dreamland
|
|
Posted on: September 09, 2010, 12:40:21 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Some functions need to interface with the current instance or with all instances. The new instance system I was singing praises about for so long offers a simple interface to do this.
To fetch the currently active instance, use enigma::instance_event_iterator . Example:
int instance_destroy() { enigma::instance_event_iterator->inst->unlink(); return 0; } Iterating instances is about as easy. As I've said, ENIGMA uses a unified iterator class. The class contains two members of concern; a pointer to the instance (guaranteeing only id and object_index members) and a pointer to the next iterator. If at any point the pointer is NULL, iteration is over.
An iterator can be fetched by an integer just like in EDL by using enigma::fetch_inst_iter_by_int(obj).
Example:
int instance_find(int obj, int num) { int nth=0; for (enigma::inst_iter *it = enigma::fetch_inst_iter_by_int(obj); it != NULL; it = it->next) { nth++; if (nth>num) return (int) it->inst->id; } return noone; } A system has not yet been added to manipulate locals that are not guaranteed (such as health). Variables that are key parts of the system (such as x and y) are included in different tiers of ENIGMA's instance system. The lowest tier is collisions, implementing bbox_* variables, and solid. The graphics tier implements such variables as sprite_index and image_index (which may eventually be removed as its use seems to indicate that placing it in system tiers is unnecessary). x,y, speed, direction, hspeed, and vspeed are implemented in the tier below that. Variables id and object_index are implemented in the bottommost tier.
|
|
|
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
|
|
|
TheExDeus
|
|
Reply #1 Posted on: September 09, 2010, 03:52:48 pm |
|
|
Joined: Apr 2008
Posts: 1860
|
How to interface with rooms? I am trying to make sprite_tiled, but I need to know room_width/room_height, or even better would be view_width and view_height, as that would make sprites tile only in view, and thus eliminate call when outside the screen. I tried including roomsystem.h and then just use room_width and room_height, but it trows: ../../Universal_System/roomsystem.h:46: error: `string' does not name a type ../../Universal_System/roomsystem.h:85: error: `string' does not name a type ../../Universal_System/roomsystem.h:86: error: `string' does not name a type So I guess its not what I want to include? I saw that there are file like GMinstance.h and another file instance.h, which looks similar in function, so are some files redundant?
|
|
« Last Edit: September 09, 2010, 03:56:18 pm by HaRRiKiRi »
|
Logged
|
|
|
|
Josh @ Dreamland
|
|
Reply #2 Posted on: September 09, 2010, 04:05:39 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
HaRRiKiRi: You should just be able to use them as-is. The resource is included after the rest of the variables.
|
|
|
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: September 10, 2010, 12:41:20 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
If you feel you can, go for it. I forget where I left off with backgrounds; they may or may not be loaded properly. See backgroundinit.cpp.
Looks like I left off after checking how many backgrounds there are. I can finish that file later today.
If you are operating from "Stable," I suggest you unzip and run again, marking "Trunk" and "I'm a dev, don't touch my changes."
If you check out from the trunk, you'll be informed of an update every time I commit something new.
|
|
|
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 #8 Posted on: September 27, 2010, 08:04:12 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
*slightly scared about new system he has no knowledge of* TGMG: In the events of the object, sprite_index = spritep will suffice. If called from the create event, I understand the problem. I'll fix that ASAP.
|
|
|
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
|
|
|
TheExDeus
|
|
Reply #9 Posted on: September 28, 2010, 02:43:36 am |
|
|
Joined: Apr 2008
Posts: 1860
|
Try now (remember to recompile the compiler, so delete the .dll file, lgm will compile it for you when the dll file is missing), atm its still quite basic. Great work. I will make those functions when I get home.
|
|
|
Logged
|
|
|
|
TGMG
|
|
Reply #10 Posted on: September 28, 2010, 04:16:00 am |
|
|
Joined: Jun 2008
Posts: 107
|
*slightly scared about new system he has no knowledge of* TGMG: In the events of the object, sprite_index = spritep will suffice. If called from the create event, I understand the problem. I'll fix that ASAP.
aye sorry about that, but its very similar to the way sprites are done. well i was implementing the action functions and then realised that they always segfault in the create event, so I was using: (enigma::object_graphics*)enigma::instance_event_iterator->inst)->sprite_index=spritep; to access it
|
|
|
Logged
|
meGMbed 2.0 :: Embed you gm games in websites.
|
|
|
Josh @ Dreamland
|
|
Reply #11 Posted on: September 28, 2010, 12:00:45 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
I see. Yeah, syntax checker doesn't like macros at the moment, but when I have that fixed, #define action_set_sprite(X) sprite_index = (X); is really the way to go.
|
|
|
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
|
|
|
TGMG
|
|
Reply #12 Posted on: September 29, 2010, 05:58:44 am |
|
|
Joined: Jun 2008
Posts: 107
|
Ah thanks Yeah I was going to implement them as functions then convert to macros when the parser can detect them but I just realised that this works: void action_sprite_set(double spritep,double subimage, double speed); #define action_sprite_set(spritep, subimage, speed) sprite_index=(spritep); image_index=(subimage); So i can implement them that way for now Although multi line macros don't work, when writing out the code to the event it includes the \ like so: variant enigma::OBJ_obj_0::myevent_create() { sprite_index =(spr_1); \ image_index =(0); ; return 0; }
|
|
|
Logged
|
meGMbed 2.0 :: Embed you gm games in websites.
|
|
|
Josh @ Dreamland
|
|
Reply #13 Posted on: September 29, 2010, 07:03:47 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Hm. Does that cause a compile error? It shouldn't. Either way, I'll take care of it.
|
|
|
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
|
|
|
|