Lachlan's misadventures in games programming

Thursday, 23 February 2012

Nerdy Gentleman on Gamer Law

2/23/2012 03:46:00 pm Posted by Lachlan , , , No comments
I just my first article put up on Jas Purewel's fantastic blog GamerLaw.

In it, I discuss the current state of the R Rating for games in Australia. The introduction is reprinted below:
There is something rotten with the state of gaming in Australia. Unlike other entertainment mediums, games can not be given an R18+ rating or classification. This has two practical effects: Games that are deemed too mature (generally due to violence or sexual references) are banned, making their sale illegal, their importation illegal and in Western Australia, their possession illegal. Other games that have been generally rated R18+ equivalents in other markets (such as The Witcher 2) are downrated to MA15+ to get them through the system.
Find the full article on http://www.gamerlaw.co.uk/2012/02/australia-getting-grown-up-about-games.html

In other news, I got sick of my crappy GUI controls inside Jack's editor. So - I have written network support which can be compiled in or out to provide access to the command interface (which is all the GUI did anyway), and the current state of memory. Then I'll be able to write a fairly simple companion (read: symbiont) program to provide the functions of the editor. I'm thinking I'll probably do it in C# simply because the GUI is pretty easy to program.

Always remember: If you ever find yourself custom coding your own GUI from scratch, its time to step back and do something else. Most OSs provide a decent one. And I can guarantee it is a lot easier to maintain, and far less buggier.

Friday, 17 February 2012

Jack can walk!

2/17/2012 04:06:00 pm Posted by Lachlan No comments

I've added the ability to use sprites. Jack can now actually walk!

Wednesday, 15 February 2012

Working Borders

2/15/2012 03:13:00 pm Posted by Lachlan No comments
I've finally added borders. It took far longer then intended, but they work. Below is an actual (not mockup) screenshot. Click for more detail


I have a special script file called "styles" which I define each style. Then, the feature has a string identifying which style it uses.

I'm happy that this is slowly coming along!

Quick update on graphics

2/15/2012 01:46:00 am Posted by Lachlan No comments
Quick Jack is a fool update:
I've got tiled backgrounds working on features. I might add the ability to offset the image, but not necessary. I also have sprited backgrounds that display once (as I put in yesterday).

I'll be adding borders tomorrow.

Tuesday, 14 February 2012

Form Code, and Squishing

2/14/2012 12:52:00 am Posted by Lachlan , No comments

I got squishing working! The White box (which will soon be replaced with actual sprites) can now detect being squished vertically or horizontally, and call a script.

In other news, I've started implementing actual graphics for the levels. How I'm doing it, is each feature will have a string identifying its style. The styles are stored in structs like the following:

struct FeatureStyle
{
SDL_Surface* surface_;
FeatureStyleMode mode_;
SDL_Rect middle_;
SDL_Rect left_edge_;
SDL_Rect top_left_corner_;
SDL_Rect top_edge_;
SDL_Rect top_right_corner_;
SDL_Rect right_edge_;
SDL_Rect bottom_right_corner_;
SDL_Rect bottom_edge_;
SDL_Rect bottom_left_corner_;
};

The mode_  simply defined if its just one, tiles, or tiled with borders. The SDL_Rects define where each part of the image is. The problem is, that this has just led to the biggest piece of copy-paste form-code in my recent history. I've been discussing over at StackOverflow whether there is a better way . There is a good chance I'll implement Konrad Rudolf's excellent suggestion. You can find the discussion on http://stackoverflow.com/questions/9260911/avoiding-copy-paste-code-initialising-a-series-of-sdl-rects-in-a-struct/9261170#9261170 if you feel like contribution. It follows, unadulterated.


case M_AddFeatureStyle:
{
std::string descriptor = TrimQuotes(args[0]);
std::string file = TrimQuotes(args[1]);


FeatureStyleMode mode = (FeatureStyleMode)boost::lexical_cast<int>(args[2]);


SDL_Rect middle = RectZeroes;
if (args.size() >= 6 ) 
{
middle.x = boost::lexical_cast<int>(args[3]); 
middle.y = boost::lexical_cast<int>(args[4]);
middle.w = boost::lexical_cast<int>(args[5]);
middle.h = boost::lexical_cast<int>(args[6]);
}


SDL_Rect left_edge = RectZeroes;
if (args.size() >= 10 ) 
{
left_edge.x = boost::lexical_cast<int>(args[7]); 
left_edge.y = boost::lexical_cast<int>(args[8]);
left_edge.w = boost::lexical_cast<int>(args[9]);
left_edge.h = boost::lexical_cast<int>(args[10]);
}


SDL_Rect top_left_corner = RectZeroes;
if (args.size() >= 14 ) 
{
top_left_corner.x = boost::lexical_cast<int>(args[11]); 
top_left_corner.y = boost::lexical_cast<int>(args[12]);
top_left_corner.w = boost::lexical_cast<int>(args[13]);
top_left_corner.h = boost::lexical_cast<int>(args[14]);
}


SDL_Rect top_edge = RectZeroes;
if (args.size() >= 18 ) 
{
top_edge.x = boost::lexical_cast<int>(args[15]); 
top_edge.y = boost::lexical_cast<int>(args[16]);
top_edge.w = boost::lexical_cast<int>(args[17]);
top_edge.h = boost::lexical_cast<int>(args[18]);
}


SDL_Rect top_right_corner = RectZeroes;
if (args.size() >= 22 ) 
{
top_right_corner.x = boost::lexical_cast<int>(args[19]); 
top_right_corner.y = boost::lexical_cast<int>(args[20]);
top_right_corner.w = boost::lexical_cast<int>(args[21]);
top_right_corner.h = boost::lexical_cast<int>(args[22]);
}


SDL_Rect right_edge = RectZeroes;
if (args.size() >= 26 ) 
{
right_edge.x = boost::lexical_cast<int>(args[23]); 
right_edge.y = boost::lexical_cast<int>(args[24]);
right_edge.w = boost::lexical_cast<int>(args[25]);
right_edge.h = boost::lexical_cast<int>(args[26]);
}


SDL_Rect bottom_right_corner = RectZeroes;
if (args.size() >= 30 ) 
{
bottom_right_corner.x = boost::lexical_cast<int>(args[27]); 
bottom_right_corner.y = boost::lexical_cast<int>(args[28]);
bottom_right_corner.w = boost::lexical_cast<int>(args[29]);
bottom_right_corner.h = boost::lexical_cast<int>(args[30]);
}


SDL_Rect bottom_edge = RectZeroes;
if (args.size() >= 34 ) 
{
bottom_edge.x = boost::lexical_cast<int>(args[31]); 
bottom_edge.y = boost::lexical_cast<int>(args[32]);
bottom_edge.w = boost::lexical_cast<int>(args[33]);
bottom_edge.h = boost::lexical_cast<int>(args[34]);
}


SDL_Rect bottom_left_corner = RectZeroes;
if (args.size() >= 38 ) 
{
bottom_left_corner.x = boost::lexical_cast<int>(args[35]); 
bottom_left_corner.y = boost::lexical_cast<int>(args[36]);
bottom_left_corner.w = boost::lexical_cast<int>(args[37]);
bottom_left_corner.h = boost::lexical_cast<int>(args[38]);
}


t->AddFeatureStyle(
descriptor, 
file, 
mode, 
middle, 
left_edge, 
top_left_corner, 
top_edge, 
top_right_corner, 
right_edge, 
bottom_right_corner, 
bottom_edge, 
bottom_left_corner);

}
break;



Friday, 3 February 2012

Button Bar

2/03/2012 05:36:00 pm Posted by Lachlan No comments
Short post:
Logic on the button bar works! You can now click a button and it will execute a script from a file.

(Slightly later more info edit)
I've added else's to the script interpreter. I also added a couple of "status" user fields that I can store information about features on. So now, the blue button can make a platform go up and down by being attached to the following script file being called on button_down:



i 0
f_1 status1
if_equal
f_1 motion = "m -19 0 0 -1000"
f_1 status1 = 1
else
f_1 motion = "m -19 500 0 1000"
f_1 status1 = 0
end

Wednesday, 1 February 2012

Button Bar

2/01/2012 06:22:00 pm Posted by Lachlan No comments

I've added buttons. They can be programmed, and with tomorrow code will work.

There can be any number of them (well, up to 254 anyway). They can be created within the game with commands like
Game add_button "Button_Down_Pic.png" "Button_Up_Pic.png" "ButtonDownScript" "ButtonUpScript"
This is  important so I can make levels work.

But, in a bit of a rush - so expect update soon.