Friday, September 28, 2012

More Game Maker and GML

Learning a new programming language at this point in my academic career is not that hard. If the language has great documentation (I'll usually just settle for documentation), and a forum  of developer for that language that discuss the language and syntax I can get the language down and making programs beyond that of a Hello World or Linked List within a week. If that language is a scripting language, even faster.

I have however came across some languages that have poor documentation, and the forum that discusses them is lucky to get any traffic. This is usually rare since the languages worth programming in have great support and a great community that helps those in need. Game Maker has neither.

For those of you who don't know, Game Maker is a drag and drop (with a "scripting language" attached to it). It greatly speeds up development since you can get a prototype of a typical flash game that you can find on Kongregate in just a week. This is if you use the drag and drop. Game Maker does have its own language called GML. If I were to compare it to another scripting language, its syntax is similar to Javascript. I decided to play around with GML and get the basics so that I can get into development without too many bumps as possible.

When writing code for GML. you just write a snippet of code (a script) and attach it an object to perform that script. Unity has a very similar design to this (that's where the similarities end) where their scripting language you can choose between C# or Javascript. This is a bit strange to get a grasp of since I'm more use to programming using objects like in C# or C++. Thinking about it, it is very similar to that type of programming. You can make an object (foo.cpp) where you can attach events to that object, i.e. the create event (the constructor) and a destroy event (the destructor), where they will initiate the script that you've written. That's not bad, in fact I could actually learn to use it. It's what happens in the script where the problems lie.

My biggest problem lies with collision detection and general physics. The way to detect a collision detection is place_free(x,y). It will tell if the object collides with another object. It is however really buggy. Half the time, my object goes through half another object (mostly the floor), where the character can move around and still jump. I've checked the hit rectangles and they seem to be fine. I've tried looking online, but an unhelpful community and poor documentation doesn't reveal anything. When my character jumps and goes into a wall, he sticks to the wall and will release if you move away from the wall. This has cost me more unnecessary time on debugging and figuring out what GML is actually saying.

The thing is I've done all of those things successfully without too much error in openGL c++ and actionscript 3.0. With a little math and some built in functions, it is all possible without too much headaches, it just takes a little more time. I've tried doing what I would normally do in actionscript or c++, but GML complains even more when you do what it doesn't want you to do. When I want the character to move horizontally I have to specify hspeed and not x += velocity. When I do use x += velocity, it creates a jigging effect where the character moves forward by 5, stops for a moment then moves forward by 5 again.

One of my teammates, who practiced with Game Maker using the drag and drop commands replacing the script found it easier and did more in the same amount of time. I would use do that except for that of my pride, and there are some things you have to do using GML to make the best game (comparatively) that you can using such a primitive tool from hell that rivals that of Fortran.

I'll get it eventually, fighting a language is like fighting any other language; just give it enough time and the battle with always be won. Then the cycle repeats itself when I have to find a better physics engine for Game Maker. I am looking  at two right now (GMPhysics and Extreme Physics). Both of which require use of GML.

No comments:

Post a Comment