Learning

Did you try “” for quotation marks? That’s one way to do it in Visual Basic. Another is Chr(32), but I doubt GameMaker even has a Chr() function.

Read the first non-commented line. <_<

You can use ‘single quotes’ inside “double quotes” for the first layer of strings inside strings. From there on it looks like you’ll have to go with the chr(34) thing though. After about three layers I started getting an error that looked like it was adding the quotes to the previous layer and unavoidably messing that string up, but I may have been doing something wrong.

I’m really surprised GM doesn’t have anything around this though, seeing as it’s a very string-based language, and every other language I can think of has something…

Good to know. Thanks :smiley:

EDIT: Oh, I figured it out as I posted this.
Woot.
The .exe was compiling onto my desktop.

Okay, scripts cannot be defined outside of the UI.
So, we’ll have to use scripts.
Give me a bit to figure out if this means I should reorganize the structure I’m currently using.

The code so far:

[code]/global constants/
global.qt = chr(34);
/******************/

global.title_room = room_add();
global.menu_room = room_add();
global.options_room = room_add();
global.battle_room = room_add();

/constants for all rooms/
size = 64;
aspect_x = 5;
aspect_y = 4;
def_bg = 1958430;
/*************************/

room_being_set = global.title_room;
room_set_width(room_being_set,sizeaspect_x);
room_set_height(room_being_set,size
aspect_y);
room_set_caption(room_being_set,“RTS”);
room_set_persistent(room_being_set,0);
room_set_background_color(room_being_set,def_bg,1);
room_set_view_enabled(room_being_set,0);

room_set_code(room_being_set,"
");

room_being_set = global.menu_room;
room_set_width(room_being_set,sizeaspect_x);
room_set_height(room_being_set,size
aspect_y);
room_set_caption(room_being_set,“Main Menu”);
room_set_persistent(room_being_set,0);
room_set_background_color(room_being_set,def_bg,1);
room_set_view_enabled(room_being_set,0);

room_set_code(room_being_set,“battle_room_button_sprite = sprite_add(”+global.qt+“battleroombutton.bmp”+global.qt+“,1,0,0,0,1,100,25);
options_button_sprite = sprite_add(”+global.qt+“optionsbutton.bmp”+global.qt+“,1,0,0,0,1,100,25);
battle_room_button_object = object_add();
options_button_object = object_add();
object_set_sprite(battle_room_button_object,battle_room_button_sprite);
object_set_sprite(options_button_object,options_button_sprite);
object_event_add(battle_room_button_object,ev_mouse,ev_left_button,”+global.qt+“room_goto(global.battle_room)”+global.qt+“);
object_event_add(options_button_object,ev_mouse,ev_left_button,”+global.qt+“room_goto(global.options_room)”+global.qt+");
instance_create(room_width/2,50,battle_room_button_object);
instance_create(room_width/2,room_height-50,options_button_object);
");

room_being_set = global.options_room;
room_set_width(room_being_set,sizeaspect_x);
room_set_height(room_being_set,size
aspect_y);
room_set_caption(room_being_set,“Options”);
room_set_persistent(room_being_set,0);
room_set_background_color(room_being_set,def_bg,1);
room_set_view_enabled(room_being_set,0);

room_set_code(room_being_set,"
");

room_being_set = global.battle_room;
room_set_width(room_being_set,sizeaspect_x);
room_set_height(room_being_set,size
aspect_y);
room_set_caption(room_being_set,“Battle!”);
room_set_persistent(room_being_set,1);
room_set_background_color(room_being_set,def_bg,1);
room_set_view_enabled(room_being_set,1);

room_set_code(room_being_set,"
");

room_goto(global.menu_room);[/code]
Today, we’re going to get rid of the idiotic quotation problem, with the clever use of scripts.
We’re then going to fill the title page with stuff, so that our game starts with a pretty animation.
We’re also going to start working on the options menu.

Part 1 - the idiotic quotation problem:
Teacher: What, Johnny, is a script?
Johnny: A script is a bunch of code that you can run at any time!
Teacher: That’s a stupid explanation, but I don’t have any better ideas, so sure.
Johnny: D=

So, if we’ve got a bunch of code (the creation code for a room) that we want to run at any time (at the room creation), we just have to put the code into a script.
Since we can’t define scripts except using the UI, create a script called menu_room_creation, and just copy/paste the creation code from earlier into the script.

battle_room_button_sprite = sprite_add("battleroombutton.bmp",1,0,0,0,1,100,25); options_button_sprite = sprite_add("optionsbutton.bmp",1,0,0,0,1,100,25); battle_room_button_object = object_add(); options_button_object = object_add(); object_set_sprite(battle_room_button_object,battle_room_button_sprite); object_set_sprite(options_button_object,options_button_sprite); object_event_add(battle_room_button_object,ev_mouse,ev_left_button,"room_goto(global.battle_room)"); object_event_add(options_button_object,ev_mouse,ev_left_button,"room_goto(global.options_room)"); instance_create(room_width/2,50,battle_room_button_object); instance_create(room_width/2,room_height-50,options_button_object);
Since we don’t have any nested quotations, we don’t have to use global.qt anymore.
We’ll keep the variable for now, in case it comes in handy later - we might not be able to replace EVERYTHING with a script.

Part 2 - the title page:
Start by changing the room in the last line to “title_room”, instead of “menu_room”. Keep the “global.”.
We want the title screen to be the FIRST THING that people see upon opening the game. Always.

Good components of a title room:

  1. an animation
  2. a way to skip the stupid animation, cause no one wants to see it

We’ll be working in the creation code of title_room. By this I mean a new script, entitled title_room_creation, and with this typed into it:

timmy_prods_sprite = sprite_add("timmy.bmp",1,0,0,0,1,0,0); slice_anim_sprite = sprite_add("slice.gif",1,0,1,0,1,0,0); timmy_prods_object = object_add(); slice_anim_object = object_add(); object_set_sprite(timmy_prods_object,timmy_prods_sprite); object_set_sprite(slice_anim_object,slice_anim_sprite); object_event_add(timmy_prods_object,ev_keypress,vk_escape,"room_goto(global.menu_room);"); object_event_add(slice_anim_object,ev_step,0,"if(self.x < 330){self.x += 5;}"); instance_create(1,1,timmy_prods_object); instance_create(1,1,slice_anim_object);
You’ll need the following files:
http://timaster.googlepages.com/slice.gif
http://timaster.googlepages.com/timmy.bmp
Feel free to change timmy.bmp to whatever you want.

Note that one of the values in slice.gif changed from the usual 0 to a 1. Slice.gif is partially transparent (the left side).

Now, go to edit>global game settings, and under other, turn all the “let some stupid key do something stupid that you don’t want it to” options off.

Now we are able to skip the intro animation with the escape key. We are not, however, able in any way to quit the stupid game. Let’s add a quit button to the main menu.
First, make the button.
http://timaster.googlepages.com/quitbutton.bmp
Oh, shit, I forgot to give you the smaller versions of the other buttons, I think.
Here they are:
http://timaster.googlepages.com/battleroombutton.bmp
http://timaster.googlepages.com/optionsbutton.bmp

Just in case, I’m going to start uploading the ongoing progress at the end of every few posts. I’ll also add the link in the first post.

Anyway, now we have the quit button. So change the creation code of the menu room to include the button.

battle_room_button_sprite = sprite_add("battleroombutton.bmp",1,0,0,0,1,100,25); options_button_sprite = sprite_add("optionsbutton.bmp",1,0,0,0,1,100,25); quit_button_sprite = sprite_add("quitbutton.bmp",1,0,0,0,1,100,25); battle_room_button_object = object_add(); options_button_object = object_add(); quit_button_object = object_add(); object_set_sprite(battle_room_button_object,battle_room_button_sprite); object_set_sprite(options_button_object,options_button_sprite); object_set_sprite(quit_button_object,quit_button_sprite); object_event_add(battle_room_button_object,ev_mouse,ev_left_button,"room_goto(global.battle_room);"); object_event_add(options_button_object,ev_mouse,ev_left_button,"room_goto(global.options_room);"); object_event_add(quit_button_object,ev_mouse,ev_left_button,"game_end();"); instance_create(room_width/2,50,battle_room_button_object); instance_create(room_width/2,room_height/2,options_button_object); instance_create(room_width/2,room_height-50,quit_button_object);

Now, I want to work on creating a piece of code for each room that clears the information from each room as we move between rooms.

We’ll make a new script for this, called “*_room_clear”, for each room.
So far, “menu_room_clear” and “title_room_clear”.
The script will have to run from somewhere, so in each room, we need to create a passive object, with no sprite or anything. We’ll also change our already written code around a bit, for the title room, and put this object (passive_object will be its name) in charge of skipping the intro animation.
This object we’ve created for each room will do everything that a tangible and/or visible object isn’t doing.

Now, frankly, I’m way too lazy/tired to explain and provide code for everything, or proofread this post, so I’ll quickly tell you what happened in debugging, and then you can go look at everything at the end of the post.

Debugging: Decided to place all of the variables set in the creation code inside the passive_object, and rename the passive object to “this”. Instead of having everything take place directly inside the room creation code, it will take place inside of passive_object, and the creation code will only directly initialize passive_object. This is a HUGE change, actually, since now the entire game will take place in a series of "passive_object"s. This makes it easy to create variables global only for the room. Which I want.

Here’s the link (the .exe inside is the right compiled .exe):
http://timaster.googlepages.com/RTS.rar

PS Please note that the battle room does and should look like crap. This is because I enabled the option of setting views for it, but did not set a view yet.

Alright well, no one really cared, but I think I’ll continue where I left off for my own sake after my graphics card fan arrives on Monday (assuming I can get it to work).

The new fan apparently doesn’t quite work.
By which I mean, it moves like 0 air. Though it only crashed the comp when I was playing WoW with all maxed settings, so maybe I can do regular stuff fine.

Ouch >_< Maybe you can get it to work all right with some tweaking? As unhealthy as it sounds for my computer, I had to mess with some stuff in my CPU fan to make it work right <_<

Edit: Also, I didn’t know you played WoW. Sucks for me, though <_< just one more person that probably doesn’t play guild wars >_<

No, the spec is 9 CFM of air, which I should have known isn’t nearly enough for my high-end card. I ordered a 4 dollar fan that does 28 CFM today, but it blows air forward instead of sideways, so it might be a bit weird to set up…
Regardless, it should be better than this =/

http://timaster.googlepages.com/rts.exe
Finally resumed work, decided to spice the graphics up a bit.
No source code this time cause screw you guys. I’ll post it if anyone actually wants it.

Now alt+f4 closes the program, so you can’t get stuck in any of the rooms and have to end process.

All the resources decompile into the folder with the game, so put it in its own folder before you run it. Feel free to steal things, as always.
All graphics and sounds were made by me, and probably will be for the whole game, with the possible exception of models if I decide to go 3D.
More on that later, when I start writing the actual game.

Next step: making a pretty main menu interface. Those buttons are just placeholders for now.
EDIT: Oh yeah, the program saves the state of the window you left it in on exit. So if you manage to get out of fullscreen (by switching the first number to a 0 in the .ini, for example) it will from then on save your stuff. Try it out, tell me if any errors pop up.
Don’t worry about the Fullscreen value if it’s a super long number starting with .99999. It’s just slightly innaccurate, but it reads it as a 1, so whatever…

EDIT2: Oh yeah, resources used so far are Adobe Photoshop CS3, sfxr.exe, registered GM6 (obviously), Notepad, and MS Paint.
Credits to Troid and CFX for a bit of help thus far, PizzaBoy for absolutely minimal help and a bit of bickering, and Daz for why not and huggle.

Cool. :smiley:

I haven’t had any problems with the window settings. A little confused about why it’s like, 99.99992710763, though.

No idea. That’s what get_fullscreen() returned though <_>

http://timaster.googlepages.com/GameofLife.exe
Whee, little project.

Dang it… It’s an exe… Macs SUCK BALLS!

Yeah they do.

http://timaster.googlepages.com/GameofLife2.exe
Nifty colored version. The rule is still binary, with black/white (slightly different rule, but the point is the calculation doesn’t depend on the colors), but now the color of each pixel is different depending on how the pixel was created. If it was created according to one rule, it’s red, another, it’s blue, another, it’s green. It’s all reds and blues, but sometimes, the blues clump together into lines that fall down… if they hit each other, they disappear, but they are never generated (except out of the sides, because those never change).
You probably have no idea what I’m talking about, since you don’t know what the program does, but it’s still cool.
EDIT:
http://timaster.googlepages.com/GameofLife3.exe
Wheeeeeeeeee
Okay I’m done. Back to better things.

I’m sorry dudes, it turns out it fails massively if you run it at a resolution that doesn’t perfectly match mine :frowning:
Thanks, Troid, for pointing that out. I fixed the resolution thing now, and now I’m working on a version that you can play with the rules of while it’s running. Then I’ll upload the fixed version.

000100
100100
100001
001100
001001
110001
100110
100101
011100
011001
010110
110110
110011
100111
011110
011011
110111

Elaboration tomorrow.