Jump to content


Photo

Piece of advice about code/actions organization


  • Please log in to reply
7 replies to this topic

#1 hexdump

hexdump

    GMC Member

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

Posted 06 May 2012 - 11:26 PM

Hi,

I would like to get some piece of advice for you, advanced GameMake users. It is all about code/actions (d&d) organization when creating a game in Game maker.

My first idea when I finished all tutorials, did some tests, etc... was to use as much d&d as I could anc complete the holes with scripting. This will allow me to work with designers that don't know how to program and still get flexibility through code.

What do you think about this aproach? Have you tried? Do you think it is better to go for much code as I can and forget about d&d? Or follow my first idea, as much d&d as I could and just use script when d&d can't do.

Another thing I need some help are ideas about how to organize code in this situation:

1) I have a button. When the button is pressed a list of items (this is a GM object) must scroll a position.
2) I have a script that inits the item list (instantiate sprites and position them accordling). This can be seen as the item list constructor.
3) When the button is pressed I could just hack through the item list and touch all its params, etc... and let it move the current selected item to the next. But I don't like this. It seems a mess. I like code organized and easy to follow. I would really prefer to call a script that do all this on the "Item list" object. But then I loose d&d.

My first idea was to create a user event in the item list and call it from the button on press event, but user evnets can just be invoked with an id wich makes dificult to remember wich to call if I have more than 1 user event. Yes, I'm trying to use user events as methods (C++/C#,etc..) for the object "item list".

Anyway, no solution satifies me. Could anyone bring some light? How do you accomplish things like this in a clean way?

Thanks in advance.

Edited by hexdump, 06 May 2012 - 11:30 PM.

  • 0

#2 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2736 posts
  • Version:Mac

Posted 07 May 2012 - 03:20 AM

Hi,

I would like to get some piece of advice for you, advanced GameMake users. It is all about code/actions (d&d) organization when creating a game in Game maker.

My first idea when I finished all tutorials, did some tests, etc... was to use as much d&d as I could anc complete the holes with scripting. This will allow me to work with designers that don't know how to program and still get flexibility through code.

What do you think about this aproach? Have you tried? Do you think it is better to go for much code as I can and forget about d&d? Or follow my first idea, as much d&d as I could and just use script when d&d can't do.

I think you should completely ignore Drag and Drop and use code for everything. Drag and Drop is never any better than code... even if you can use Drag and Drop then code is still better as it's easier to write (you don't have to enter all the values through the interface)... easier to edit (stuff can be copied, pasted, deleted, etc.)... and easier to ask for help (just copy and paste the code, as opposd to posting the Drag and Drop actions.
If the only reason you want to use Drag and Drop is to show the game designer (who doesn't know code)... don't do that. First off, if he doesn't know code he really shouldn't be involved in the programming aspect at all anyway... secondly you can put comments in the code to explain stuff so that he'll know what you're doing, even if he doesn't know code at all.

Another thing I need some help are ideas about how to organize code in this situation:

1) I have a button. When the button is pressed a list of items (this is a GM object) must scroll a position.
2) I have a script that inits the item list (instantiate sprites and position them accordling). This can be seen as the item list constructor.
3) When the button is pressed I could just hack through the item list and touch all its params, etc... and let it move the current selected item to the next. But I don't like this. It seems a mess. I like code organized and easy to follow. I would really prefer to call a script that do all this on the "Item list" object. But then I loose d&d.

My first idea was to create a user event in the item list and call it from the button on press event, but user evnets can just be invoked with an id wich makes dificult to remember wich to call if I have more than 1 user event. Yes, I'm trying to use user events as methods (C++/C#,etc..) for the object "item list".

Anyway, no solution satifies me. Could anyone bring some light? How do you accomplish things like this in a clean way?

Thanks in advance.

This I can't help you with. I know some C++ but I have no idea what a method even is. No idea what you're trying to do either... if you're trying to somehow write events in code (which I'm not even sure is possible), don't. Just use the interface to click on "mouse button on press event" and enter the code there... either that, or use the step event to check if the mouse is being pressed and put the code in an if statement.
  • 0

#3 kupo15

kupo15

    GMC Member

  • GMC Member
  • 584 posts
  • Version:GM8.1

Posted 07 May 2012 - 03:44 AM

Definitely use code for everything. I cannot fathom how its possible to keep organized while making a game in dnd not to mention that other programmers will laugh at you. You don't want that now do you haha :tongue:
  • 0

#4 hexdump

hexdump

    GMC Member

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

Posted 07 May 2012 - 09:24 AM

Thanks for the answer.

It is odd that having as powerful as GameMaker related to Game d&d creation that no one use it :D. I really preffer to use code, this is true, just wanted to short development cycles as much as I could. And I thought d&d would accomplish it.

If you use 100% code, how do you register to step, input, etc... events? OR you just use d&d for setting events and then write all the logic in script?.

Thanks in advance.
  • 0

#5 decroded

decroded

    GMC Member

  • GMC Member
  • 572 posts
  • Version:GM8

Posted 07 May 2012 - 10:24 AM

Thanks for the answer.

It is odd that having as powerful as GameMaker related to Game d&d creation that no one use it :D. I really preffer to use code, this is true, just wanted to short development cycles as much as I could. And I thought d&d would accomplish it.

If you use 100% code, how do you register to step, input, etc... events? OR you just use d&d for setting events and then write all the logic in script?.

Thanks in advance.

Use the object events such as Create, Step, Draw, Destroy.
Just don't put any Actions in them
Likewise don't create a Script resource for every bit of code.
Instead, simply use the Execute Code Action (in the control tab) and stick your code straight in there.

Reserve your Scripts (as in resources in the Scripts tree) for common code with arguments that are used by multiple objects.

I personally don't use the various Keyboard events, I do it all using keyboard_check (usually in Step event)

Get a firm grip on object parenting, event_inherited(), over-riding parent behaviour etc.

I'm not really experienced but I think a good way to shorten production cycle is to code from the outside in.
Don't waste any time on the content of these, but build the shell of a game with intro, menu, pause menu, load/save, a few rooms, very basic goals, let player die, respawn, have score, health, have a cutscene with dialog and player movement etc (and alot more!).
This way you can modify your template and hit the ground running by the time anyone else gets involved.
  • 0

#6 hexdump

hexdump

    GMC Member

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

Posted 07 May 2012 - 11:07 AM


Thanks for the answer.

It is odd that having as powerful as GameMaker related to Game d&d creation that no one use it :D. I really preffer to use code, this is true, just wanted to short development cycles as much as I could. And I thought d&d would accomplish it.

If you use 100% code, how do you register to step, input, etc... events? OR you just use d&d for setting events and then write all the logic in script?.

Thanks in advance.

Use the object events such as Create, Step, Draw, Destroy.
Just don't put any Actions in them
Likewise don't create a Script resource for every bit of code.
Instead, simply use the Execute Code Action (in the control tab) and stick your code straight in there.

Reserve your Scripts (as in resources in the Scripts tree) for common code with arguments that are used by multiple objects.

I personally don't use the various Keyboard events, I do it all using keyboard_check (usually in Step event)

Get a firm grip on object parenting, event_inherited(), over-riding parent behaviour etc.

I'm not really experienced but I think a good way to shorten production cycle is to code from the outside in.
Don't waste any time on the content of these, but build the shell of a game with intro, menu, pause menu, load/save, a few rooms, very basic goals, let player die, respawn, have score, health, have a cutscene with dialog and player movement etc (and alot more!).
This way you can modify your template and hit the ground running by the time anyone else gets involved.


Good points here decroded.

Are there any tutorials showing good programming practices for GML? Or examples to see how people link all GM systems (code/d&d) to create a game? It will be nice to have this. I'm not asking for a tutorial on how to program on GML just a tutorial to see how things fit, how people setup chunks of code to do things, how they call them, where they setup objects intitially, etc... etc... a showcase implementing GM/GML best practices.

Thanks.

Edited by hexdump, 07 May 2012 - 11:43 AM.

  • 0

#7 decroded

decroded

    GMC Member

  • GMC Member
  • 572 posts
  • Version:GM8

Posted 07 May 2012 - 12:23 PM



Thanks for the answer.

It is odd that having as powerful as GameMaker related to Game d&d creation that no one use it :D. I really preffer to use code, this is true, just wanted to short development cycles as much as I could. And I thought d&d would accomplish it.

If you use 100% code, how do you register to step, input, etc... events? OR you just use d&d for setting events and then write all the logic in script?.

Thanks in advance.

Use the object events such as Create, Step, Draw, Destroy.
Just don't put any Actions in them
Likewise don't create a Script resource for every bit of code.
Instead, simply use the Execute Code Action (in the control tab) and stick your code straight in there.

Reserve your Scripts (as in resources in the Scripts tree) for common code with arguments that are used by multiple objects.

I personally don't use the various Keyboard events, I do it all using keyboard_check (usually in Step event)

Get a firm grip on object parenting, event_inherited(), over-riding parent behaviour etc.

I'm not really experienced but I think a good way to shorten production cycle is to code from the outside in.
Don't waste any time on the content of these, but build the shell of a game with intro, menu, pause menu, load/save, a few rooms, very basic goals, let player die, respawn, have score, health, have a cutscene with dialog and player movement etc (and alot more!).
This way you can modify your template and hit the ground running by the time anyone else gets involved.


Good points here decroded.

Are there any tutorials showing good programming practices for GML? Or examples to see how people link all GM systems (code/d&d) to create a game? It will be nice to have this. I'm not asking for a tutorial on how to program on GML just a tutorial to see how things fit, how people setup chunks of code to do things, how they call them, where they setup objects intitially, etc... etc... a showcase implementing GM/GML best practices.

Thanks.

Hmmm well I don't know about "best" practice but here's an example Asteroids clone I'm working on.
Its 8MB download coz of sounds and graphics (mostly ripped content at this stage).
Its still in progress so its far from a complete example of what you need to build a game such as dialog boxes etc but if you can learn whats happening here you'll have a good head start.
Let me know if you want me to explain anything in particular.

Just excuse that the game is so easy since the ship has all the upgrades already and I haven't built the shop yet lol :biggrin:

Edited by decroded, 07 May 2012 - 12:24 PM.

  • 0

#8 hexdump

hexdump

    GMC Member

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

Posted 07 May 2012 - 12:40 PM




Thanks for the answer.

It is odd that having as powerful as GameMaker related to Game d&d creation that no one use it :D. I really preffer to use code, this is true, just wanted to short development cycles as much as I could. And I thought d&d would accomplish it.

If you use 100% code, how do you register to step, input, etc... events? OR you just use d&d for setting events and then write all the logic in script?.

Thanks in advance.

Use the object events such as Create, Step, Draw, Destroy.
Just don't put any Actions in them
Likewise don't create a Script resource for every bit of code.
Instead, simply use the Execute Code Action (in the control tab) and stick your code straight in there.

Reserve your Scripts (as in resources in the Scripts tree) for common code with arguments that are used by multiple objects.

I personally don't use the various Keyboard events, I do it all using keyboard_check (usually in Step event)

Get a firm grip on object parenting, event_inherited(), over-riding parent behaviour etc.

I'm not really experienced but I think a good way to shorten production cycle is to code from the outside in.
Don't waste any time on the content of these, but build the shell of a game with intro, menu, pause menu, load/save, a few rooms, very basic goals, let player die, respawn, have score, health, have a cutscene with dialog and player movement etc (and alot more!).
This way you can modify your template and hit the ground running by the time anyone else gets involved.


Good points here decroded.

Are there any tutorials showing good programming practices for GML? Or examples to see how people link all GM systems (code/d&d) to create a game? It will be nice to have this. I'm not asking for a tutorial on how to program on GML just a tutorial to see how things fit, how people setup chunks of code to do things, how they call them, where they setup objects intitially, etc... etc... a showcase implementing GM/GML best practices.

Thanks.

Hmmm well I don't know about "best" practice but here's an example Asteroids clone I'm working on.
Its 8MB download coz of sounds and graphics (mostly ripped content at this stage).
Its still in progress so its far from a complete example of what you need to build a game such as dialog boxes etc but if you can learn whats happening here you'll have a good head start.
Let me know if you want me to explain anything in particular.

Just excuse that the game is so easy since the ship has all the upgrades already and I haven't built the shop yet lol :biggrin:


I really apreciate this. WIll have a look at it later.

THanks.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users