Tuesday, April 8, 2014

Week 4: Powerup Inverse

This week, instead of using my own tools, I'm tested out Gamemaker: Studio to test out its prototyping abilities.  This week I wanted to experiment with a modified handicap system.  I created a space shooter where the player is rewarded for killing by NOT giving him powerups.  Powerups will decrease the player's score if they get a kill, so when the player is doing well, it means he has no powerups and is getting the maximum score.  When the player dies, he receives a powerup making it easier to kill the enemy, but decreasing his score each kill.  When he gets a kill, the powerup level is decreased.It's basic, and I'm sorry for the random mouse cursor in the way!! I made a really simple and horrible AI for the enemy ship.  I might extend this game later.  This is the first time I have used GameMaker: Studio free edition, and after the video I will talk about it a bit.



Ship and nebula image were found with Google image search.  The ship came from someone on Stackoverflow: http://stackoverflow.com/questions/15342083/algorithm-to-make-a-polygon-from-transparent-png-sprite and

I used Gamemaker this week to make the game because I wanted to experiment with something different.  I've found that Gamemaker is amazing at allowing somoone to quickly create a prototype, but it definitely has some deficiencies which make it harder to use for full-scale games.  Perhaps some of those deficiencies arrose because I wanted more control, more power, or more programming language expressive power (I am a programming).  But all-in-all, I will probably end up purchasing the pro version of Gamemaker in the future for fast prototyping and iterating.  Once I use Gamemaker a bit more, I'll post a full review, but here are some things I've noticed that are lacking in it.

1. Organization
This is a primary concern.  I wish it would let you see relationships among objects and variables assigned to them, or let you quickly see which objects have what scripts attached to thim.
2. GML
The Gamemaker programming language is a fusion of scripting languages such as Javascript and C++.  While the syntax is mostly C++, the types and variable system are dynamic.  The biggest issue I have with the GML so far is organization.

The GML is a fusion between Javascript and C++.  While it does have the concept of objects, there is no way to create object methods or private obj data, or anything like that.  Also, there is no way to easily craft polymorphic objects (even though there is a parent-child component that can be used).  I wanted to create a gun class, then subclass this for the individual powerups and give it one virtual function: shoot.  This would have allowed me to encapsulate all my gun variables in the gun object and also prevent any powerup logic other than swapping out a new gun from being in my ship objects' code.  Well, this isn't quite possible.  In fact, if you do want to have object methods, you need to use the provided userevents instead and somehow trigger them.  I'll have to look into using the parent/child relationships a bit more.

Variables are a bit hectic. First, if you were to assign a variable like this:

This code will actually create a variable named shipSpeed (if it doesn't exist) and attach it to whatever object  instance the current script is running on.  As far as I can tell, there is no way to see the variables on an object, so if you declare some variable in another script, you will have to remember where you declared it, what it is named, which script it was named in, etc.  I kind of like more organization, like being able to see variables on an object or having some method to add variables to an object outside of the scripts so I can keep it organized, then if a variable is referenced in the script that doesn't exist, it throws an error.  Anyways, this is kind of like what Javascript does (and I don't like it there either).

To make a variable local to the current execution of the script, use the var keyword.  This will create a local variable that will be destroyed once the current script is done executing.  And finally, globalvar is used for global variables.

What would make the variable system a bit better?  Use this to explicitly say that you are accessing an instance variable.  That way I don't accidentally create one by leaving off the var keyword for a variable in a script execution.

The with keyword is a way to switch contextsand allow you to operate on another item's data structures.  The problem is it can get confusing if you are just reading somone's code.  For example:

The second assignment to x and y is done on the objShip object (or the instance that it finds), whereas the first x and y assignments are done on whatever object instance is executing the script.  You can see, this can get a bit confusing if you just want to read the code and you forget that the current block you are in is in some giant with statement.  This is a better way to do it:

Also, you can't really define pure programmatic structurs, such as classes or the like.  In fact, there isn't even a simple object that encapsulates a point (x, y variables).  All functions are essentially C-style in that they operate on one piece of data and return some output.

Built-in variables -- The color coding of built-in variables in the code is nice, but I would like to make sure I'm not accidentally assigning something to a built-in variable which is going to modify some substate of my game (such as the speed variable).

Again, I wish GM was a bit more organized in code structure and variables, and would at least have some GUI allowing my to view objects and their properties, but I guess it's not really too advanced (maybe later versions). Gamemaker does a lot of things well though: 1. Fast prototyping: It automates many of the subsystem routines you would have to manually create, such as effect loading, timestepping, etc. 2. Visual interface: The visual interface is fine for 2D games and I kind of like how easy it is to add rooms and such to correspond to levels. 3. Very very easy scripting and world building manipulation.

Takeaways:  Use tools like GameMaker or Unity 2D for quick prototyping.  I have been a programmer and have resisted the urge to use these tools because I wanted to do everything myself, but when you are the only programmer in a game team, building everything yourself, no matter how simple some of the things are, is very time consuming.  I would rather focus my time on designing and iterating on a game design to show the other developer instead of focusing on hours programming boilerplate code without anything to show for it.  Again, use tools like GameMaker for quick prototyping, even if you don't want to use them in the end.

No comments:

Post a Comment