Jetstar Forever

Programming and Game Development

Archive for March, 2008

Zonerunners A.I. Test Video

Posted by jetstarforever on March 29, 2008

http://www.youtube.com/watch?v=3nqv21TfPB8

Sorry about the quality, but dialup dosen’t like large videos.

This is a small video of the A.I. doing it’s thing. The first half is of some nifty pathfinding, and the second is a small clan war. Don’t forget to comment and check my other videos, which is all Zonerunners stuff.

Posted in Zonerunners | Tagged: , , , , , , | Leave a Comment »

The module design

Posted by jetstarforever on March 28, 2008

    In C++ you can add “libraries” to your program, basically making harder things easier, and making the impossible possible. For example. you might find a library that makes drawing to the screen easier, or maybe even one designed to aid in the game development process. In Zonerunners I want the same control, maybe even more. But for any of this to happen I’d have to do some serious thinking.

So now I have to decide: Do I want the hassle of external script reading and the hassle of fixing things outside of the GameMaker GUI? Do I want to give the player some ability like importing their own script into the game? Or will that be too much of a risk?

All these are issues that must be addressed when approaching the idea of a module design, which is the ability to attach external “modules” of code onto the existing engine without recompiling it. The possibility of keeping the module design until the game is finished, upon which you make all the external scripts internal (inserting them into the Game Maker GUI), is also a good approach.

But like I said, I needed a way to code while actually PLAYING the game without handing over total control to the player. If you look back at my previous post called “The Introduction!” you’ll see my code for the in-game console towards the end. We’ll be using the same approach for this, so look it over!

Modules work this way in Zonerunners: An external script is loaded and parsed much like code is handled with the console. Only this time, the parser also runs through a list of blacklisted commands (commands I don’t want the user using), and are removed from the script. Wow, that was simple!

Posted in Zonerunners | Tagged: , , , , , | Leave a Comment »

Dynamic Level Loading

Posted by jetstarforever on March 27, 2008

    Probably one of the biggest challenges of Zonerunners is the fact that the game is one big level, meaning very little load times and little to no hiccups that normal games usally have upon loading the next section or level. For those familiar with Game Maker, there’s a handy script called instance_deactivate(), which takes the object out of the main game loop without deleting it. Meaning you can delete it, but bring it back with all it’s stats intact. Cool, huh?

Well, for Zonerunners I found that doing this would basically ruin the game code-wise. You see, for the game to work I have to have control over everything all of the time, because the A.I. itself must have the same control. Putting it simply: Deactivating the enviorment (which also plays a major role in speed) would render the A.I. useless since it can’t read what’s around it. The reason the game was coming to a hault on large maps was due to the intensive A.I. script running for every character EVERY frame. As you can imagine, this would slow the game down to a near 10fps on a large map, let alone a small one. I had to fix this fast, for the future of the game depended on it.

I was fully prepared for a one-hour coding spree when I somehow managed to make a simple script in under five minutes that solved the problem:

if x>level.xa and x<level.xb{return true}else{return false}

“What?” Yes, this solved my problem. What it does is check to see if the calling object is in the currently set level boundaries. If the object is not in the area, it’s not drawn to the screen, it’s STEP event does not run, but it’s still “there”. This way, depending on what I set the current boundaries as I can make small levels inside one big level.

Posted in Zonerunners | Tagged: , , , , , , | Leave a Comment »

The Introduction!

Posted by jetstarforever on March 27, 2008

Hello everyone! I’m a 15-year-old computer programmer from a small country town in Indiana. Normally, you’d think I’d be busy hauling hay or doing typical farm-stuff; not true! Although I do enjoy physical activity (unusual for computer nerds) I also enjoy wading knee deep in code and game development fury! I’m currently in between using C++ and Game Maker. Yes, I know, Game Maker is frowned upon as the evil of the entire programming world, but I swear to you, this time it’s different. For now on I will record my progress and post code snippits from my game Zonerunners, and small helpful hints on proper Game Maker usage.

Day 1: 7:34 PM 3/26/2008

It’s been awhile since I started Zonerunners, but it’s never too late to start showing people the guts of the game without confusing them! I’m currently on Prerelease Version 2, which may not seem like much, but is actually a huge step forward into the game engine and theory. Right now I guess you could say that I’m finishing the A.I., basically doing a lot of polish to make it like good enough to release.

One of the biggest problems I’ve had with Zonerunners is the fact that most of the engine was new territory. I had never really went in depth into a platform engine until now, okay, I had messed with a few before, but never really went all that far into them. So as you can see from some of these code snippits the code is still rough since the focus has been on the A.I. since the beginning.

if tar=false{
if _y<300 and scan=1 {_y+=10} if tar=false and scan=1 and _y>=300 {_y=-300;scan=1}
switch (clan){
case "TESTERTOASTER":
for (t=1; t<=test[0,0]; t+=1){if distance_to_object(test[0,t])<=viewdistance{tarid=test[0,t];tar=true}}
break;
case "QWERTY":
for (t=1; t<=null[0,0]; t+=1){if distance_to_object(null[0,t])<=viewdistance{tarid=null[0,t];tar=true}}
break;
}
}

The above is from the main A.I. script, called ai_seek(). What this does is check to see if the object calling has already targeted something, and if not, find one by searching a list of enemies that are stored in an array depending on which “clan” the object is in. Each clan has an array of enemies, which are added to the array once they engage in some form of combat with a member of the clan.

Next up is a very very simple “console”. If you’ve ever encountered a console in a game you know what I mean. For those who don’t: It’s basically a text box from which you can execute/modify values from.

exec=string_delete(argument0,string_pos("(",argument0),string_length(argument0))for (i=1;i<=com_array[0];i+=1){
if exec=com_array[i]{
execute_string(argument0)
}
}

This console is called con_exe() (short for Console Execute) . What this does is takes the argument and checks it against an array of valid commands. But since most arguments would be along the lines of “move_object_to(100,200)” I have the string_delete() command automatically cut everything after the first “(” at which point a FOR loop checks the modified command against the previously mentioned array of commands. If the FOR loop detects a valid entry the unmodified argument is executed with execute_string().That’s all for today!

Posted in Zonerunners | Tagged: | Leave a Comment »