Sunday, October 13, 2013

Day Eight: The Idea!

Marketing:
I created a tumblr account. I'm not much of a tumblr guy but there is one major benefit of using tumblr. It makes it easy to link up all of your different social media accounts. Once they are linked you can simply post something on tumblr and it will post to all of your other accounts on twitter and facebook. I set it up and it works great! That was pretty much all I did for marketing.

Design:
I don't know how much you know about Game Maker but just to make sure you understand. Game Maker has a section for Scripts. A script is basically just a function that you can use inside of any object. Objects are basically just classes.

The idea is that you can use scripts to simplify the logic behind the coding and even the amount of coding that you have to do.

For example, let's say that you create a script named "rkey" and you put this code inside of it:

if(keyboard_check(vk_right)) { return true; } else { return false; } Now whenever you want to call to check and see if the right key is being pressed you can simply write:if(rkey()) {//Do something.}
Cool trick right? Now you might be thinking. That's nice Ben, but it really isn't that new.
Don't worry. It get's better. Let's say that each of these scripts is now called an event. Game Maker already uses this term but not usually in this context. Now, using scripts like I just showed you, let's say that you create different events based on your type of game. For my game I would have some events like these.

facing //returns the direction the player is facing.
attacking //returns whether or not the player is attacking.
attsprite //changes the sprite to an attacking sprite by taking direction the player is facing as an argument.

For the sake of this example I'll also say that the "ckey" is the key that triggers an attack. Now that we have some different events created you can combine these events in ways that make sense logically.

if(ckey() and !attacking()) { attsprite(facing()); } So basically, you just combine smaller events into larger events that would normally be complicated to code but because you broke them down into small events, they are easier to manage. The only trick to this is that you will have to plan what events are going to be important before you start programming. There are going to be basic events that will cross over to every game but some will take planning.

Coding:
Well, this is the idea that I had yesterday and I already started coding it into the game. I'm really excited about it.

4 comments:

  1. There's not much reason to do this. Just typing
    if (keyboard_check(key))

    Isn't that much longer at all, and it's still very readable, in fact, more readable to people checking out your code.

    ReplyDelete
    Replies
    1. Not to mention, more efficient, since there's less if{}else{} checks going on.

      Delete
  2. That is true. It is more efficient to simply write it that way.

    I'm not sure I was able to get across the big picture to you though. I was only using that as an example. The idea is that you create smaller events and combine them in ways that does make the code more readable. I guess I didn't explain it as well as I wanted to.

    ReplyDelete
  3. Totally agree, the "divide and conquer" strategy is the only way to keep larger projects manageable.

    Efficiency is not attained by eliminating a few if-then-else loops, people overestimate how long code takes to execute. Having functions with clear names makes a lot of difference.

    Also, imagine not working on a project for two years and coming back for a sequel. Will you still be able to read your code? That's important too :)

    ReplyDelete