Jump to content


Photo

GML question for Advanced users


  • Please log in to reply
3 replies to this topic

#1 Cybert9

Cybert9

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 26 January 2012 - 12:21 AM

I'm a professional computer game designer (for almost 30 years now) but I don't do my own programming. It IS helpful, however, for me to prototype design ideas and mechanics before I present new game concepts to my team. I'm currently using MMF2 for this task but as I have some rudimentary coding skills I find the interface and logic both physically taxing (clickclickclickclickclickclick) and a little obtuse, at times.

Okay, on to my question. I'm very new to Game Maker and I'd like to know if it is feasible to write a game *primarily* using GML. Will I wind up with lots of little script files (tied to different events) or one main script file? I'd love to be able to use the editor(s) to import/create my rooms and objects, and then use scripting for all the logic. Possible?




MODERATOR EDIT : This topic has been moved to the Novice Q&A section due to it not following the Advanced Section Rules and Guidlines. Please read the section rules of the forum before posting....

Edited by Nocturne, 26 January 2012 - 06:33 AM.

  • 0

#2 thegame

thegame

    Flying Penguin

  • GMC Member
  • 1405 posts
  • Version:GM:Studio

Posted 26 January 2012 - 12:30 AM

Well, really... in GM, games should have ALL of the logic in GML except for the 'Execute code' block... but yes, your code will (probably) be all spread out between a bunch of little code blocks - this is why one would use GM (other than the built-in functions)

There are advantages to this:
1. Little code to sort through when you need to find a specific thing.
2. If you know where you put the code and what to do with it, it can be very easy to find what you want to change.
The disadvantages:
1. If you can't find things, it takes a lot longer to get the little script you want - there is a 'Search in all scripts' function though. Very helpful in those situations.
2. When you want to change a variable name, it takes. so. long. - you can't 'Replace in all scripts'.

You could, somewhat easily, make a game all in one block of a controller object... but that would be not recommended as your code will get long and hard to read that way...
  • 0

#3 Hexenritter

Hexenritter

    GMC Member

  • GMC Member
  • 149 posts

Posted 26 January 2012 - 03:29 AM

It is possible to create and run everything out of the room script or one external script, you just need to set up a "global" variable to determine which step has been gone through.
Let's say global.step_id=0
0 can be the set_up and create procedure/block

so:
if !(variable_global_exists('step_id'))
{
global.step_id=0;
};

if global.step_id == 0
{
global.obj_new = object_add();
object_event_add(whatever events);

and so on...

global.step_id=1;
room_restart();
};

and then you put global.step_id = 1 in there and right after that room_restart,
and then you have another if loop for (global.step_id==1) and within in this block you can call your instances and such.
So doing that makes it not only possible to create new resources and set-up screen/display-setting, also it allows you to reuse/recall your one room how many you want just by, and if you wanna call and create scripts within your one script, you can use global.script1 = "object_add(); function_2()"; then execute_string(global.script1);
whatever.

So it is definitely possible, but like "the game" said it will be a very confusing resource-management.

cheers.

Edited by Hexenritter, 26 January 2012 - 03:34 AM.

  • 0

#4 paul23

paul23

    GMC Member

  • Global Moderators
  • 3360 posts
  • Version:GM8

Posted 26 January 2012 - 04:03 AM

You shouldn't want to do that.

Creating large cluster****s of code is something that's considerably frowned upon in the programming world. - I dare to say that gamemaker even encourages long functions/scripts compared to other languages. (Where a function is typically 10-20 lines, in GM you'll often see people creating scripts of 50+ lines).
The event system is what defines gamemaker, without it you're not really using GM's features. So yes you'll have to create an event, add code to it.


Importing rooms "is" possible - however you would have to write your own converter, to convert your externally created room to the correct XML format. - This hasn't been done, nor is there any plan to make it public. However it's quite frankly "easy" to implement yourself, just requires a bit of work. - The XML file is almost self explanatory.


That said, this question falls under "can gamemaker..." - which is always answered with "yes" (better question would be, is it easy with GM compared to ...). As such it doesn't really fall under the Q&A forums - just try GM lite and see for yourself.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users