Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Josh @ Dreamland

In that case, you would have to edit the controller I described to draw those two HUDs. Add those images you drew atop the chickens as backgrounds, and use draw_background to display them. Use the following to populate it, in the draw event as well of course:
Code: (GML) [Select]
global.list = "";
  global.list += object_get_name(object_index) + "#";
draw_text(<x coordinate of objective HUD> + 16, 16, global.list);

This code requires that the students enter an English name for each child object.

The inventory HUD will make the game more complicated. Game Maker does not allow for multiple inheritance (nor does ENIGMA at the moment). That being the case, in the destroy event for each findable inventory item (i.e., your skeleton key), you will need to execute a code. You will also need a sprite for them as they will appear in the inventory, including any borders. Keep them all the same dimensions so it looks presentable. Give them each three subimages; the first subimage will be drawn in the HUD when it isn't selected, and the second will be drawn there when it is, and the third will be drawn at the cursor.

You will need a Game Start event in the controller:
Code: (GML) [Select]
global.inventory = "";
global.inventory_sprite = -1;
global.inventory_selected = -1

Then, just after you draw the other HUD,
Code: (GML) [Select]
var i, xx, yy; xx = 16; yy = <HUD Y COORDINATE> + 16;
for (i = 0; global.inventory[i] != ""; i += 1)
  draw_sprite(global.inventory_sprite[i], global.inventory_selected = i, xx, yy);
  xx += sprite_get_width(global.inventory_sprite[i]) + 4;
  if (xx + sprite_get_width(global.inventory_sprite[i]) > room_width-16) {
    xx = 16; yy += sprite_get_height(global.inventory_sprite[i]) > room_width-16) + 4;

Add a Global Left Pressed event to the controller.
Code: (GML) [Select]
if (mouse_y > <HUD Y COORDINATE>)
  for (i = 0; global.inventory[i] != ""; i += 1)
    if (mouse_x > xx and mouse_x < xx+sprite_get_width(global.inventory_sprite[i])
        and mouse_y > yy and mouse_y < yy + prite_get_height(global.inventory_sprite[i]) > room_width-16)) {
      global.inventory_selected = i;
    xx += sprite_get_width(global.inventory_sprite[i]) + 4;
    if (xx + sprite_get_width(global.inventory_sprite[i]) > room_width-16) {
      xx = 16; yy += sprite_get_height(global.inventory_sprite[i]) > room_width-16) + 4;

Again in the controller's draw event,
Code: (GML) [Select]
if (global.inventory_selected != -1)
  draw_sprite(global.inventory_sprite(global.inventory_selected), 2, mouse_x, mouse_y); // Draw the selected item at the mouse

Again in the controller, on Global Mouse Release:
Code: (GML) [Select]
global.inventory_selected = -1; // Clear the selected item
The inventory collectibles, as I mentioned, need to have something special in them to add them to the inventory. This is a script that you will call in the destroy event of EACH collectible inventory object; call it inventory_add(name,sprite):
Code: (GML) [Select]
var i;
for (i = 0; global.inventory[i] != ""; i += 1) {}
global.inventory[i] = argument0;
global.inventory_sprite[i] = argument1;
global.inventory[i+1] = "";
global.inventory_sprite[i+1] = -1;
A sample call is inventory_add(object_get_name(object_index),spr_inv_skeleton_key);.

This next script is inventory_remove(name or id).
Code: (GML) [Select]
var i;
if (is_string(argument0))
  var found; found = false;
  for (i = 0; gobal.inventory[i] != ""; i++)
  if (gobal.inventory[i] == argument0) {
    found = true; break;
  if (!found) exit;
else i = argument0;
if (i == gobal.inventory_selected)
    gobal.inventory_selected = -1;
while (gobal.inventory[i] != "")
    gobal.inventory[i] = gobal.inventory[i+1];
    gobal.inventory_sprite[i] = gobal.inventory_sprite[i+1];

As an example, your treasure chest would make this check in its Mouse Press event:
Code: (GML) [Select]
if (gobal.inventory_selected != -1)
  if (gobal.inventory[gobal.inventory_selected] == "Skeleton Key")

I recommend that you provide the students with the two scripts, if they are not very good with code.
I've not tested any of the above code, but I have some confidence it will work if you put a little time into it.
You can send this to her as well, again with my regards. I can't continue abstract work on this game if it grows any more complicated, but I'm happy to answer questions. Peace.

Oh, the irony. Look, fede, you're an asset after all!

Anyway, no problem. Happy to help. I read over my post again, and I think I should clarify that the controller needs placed in each room with hidden objects, while the parent object doesn't need instantiated anywhere, except implicitly through the child objects the students will be placing.

Seems interest isn't very high, likely because most of us are C/Java programmers or are on Linux. Have you tried the 64Digits community? They're a good balance of intelligence and... well, free time or boredom, I guess. Whatever component is missing here.

The problem may also be that a hidden object game is essentially 2 percent programming, 95 percent graphics, and 3 percent level design. Assuming you can provide the graphics, the procedure is simple (I will describe a more redundant, less technical method). You can deliver it to her with my regards, or you can wait and see if someone will draft out a GM6 of it.

1) Create a sprite for each hidden object.
2) Create backgrounds that are full of clutter and scenery, such as a messy classroom or a busy city street, as I assume is in the game you mentioned.
3) Create an object with any name (have your students assign it a name of their choice, but give them an example). This will be the parent object. It will not have a sprite. This is the most difficult concept in the operation. It has but one event, "Mouse Press", in which a few simple calls are made: effect_create_above() with your choice of particle as a flashy effect, instance_destroy() to remove the object from play, and score += 1 to, well, add to the score.
4) Create a controller object. This object checks in the step event, if (!instance_exists(<the parent object's name>)) room_goto_next();. This will keep the game going once they've found them all.
5) Have the students create several objects, setting the parent of each to the first object and setting the sprite to a different hidden object sprite. Have them place the objects in a separate folder for each scene to teach them organization skills.
6) Create a room for each background scene they've made. Have them place the objects from that category in them. Add a room to the end, and in it, set the background to a big, "You Win!" image. Optionally, in the room start code, add show_message("You win! Score: " + string(score));. Of course, the score will always be the same, unless you have the controller keep track of time.

Game Maker should automatically display the score in the caption. If it doesn't, use room_caption = "Score: " + string(score); in the step event of the controller.

Out of curiosity, how did you find out about this board?

Proposals / Re: Obliterating "inst" from functions.
« on: March 13, 2011, 11:08:02 PM »
I guess the macro would be fine, but keeping a global just wouldn't work.

Function Peer Review / Re: move_wrap
« on: March 11, 2011, 09:01:49 AM »
His point is, if you have functions, post them here. I'm not going to do anything with them, and no one else gives a shit about your functions unless they're posted here. So post them, or drop them.

Proposals / Re: Welcome PM
« on: March 10, 2011, 09:34:58 AM »
Heh, don't worry, Griggs, I'm working on it. The coercer's a piece of shit, and so I'm replacing it before I can allow switching odd types.

Proposals / Re: globalvar
« on: March 10, 2011, 09:29:21 AM »
It'll work if the parser can read it. Hell, it'd work if you stuck it right into definitions. Just not in syntaxquirks.h; you'll notice an ifdef around it prevents the parser from reading it.

Proposals / Re: room_speed
« on: March 04, 2011, 02:21:16 PM »
rs = room_speed, polygone.

Sleep(1000/room_speed) assumes ideal framerate; it pretends that no time at all was consumed between the end of that frame and the frame before.

I realize now that it should be handled instead by a timer, at the beginning of the frame. Should the frame take longer than 1/room_speed seconds, the timer would fire before its completion, harmlessly posting an event in the queue to be handled. Upon completing that frame, the event code will be received, and the next frame will fire, immediately setting the timer to 1/room_speed again. I may need to use a thread for it on Linux, but on Windows, it's simple and the best way. Meaning I'm going to make someone else do it. Maybe.

Proposals / Re: Action functions plugin writing
« on: March 03, 2011, 09:23:35 AM »
Indeed. Even if it didn't, we could use && instead of the comma for true, and || instead of it for false, in the case of if().

Proposals / Re: Obliterating "inst" from functions.
« on: March 03, 2011, 12:06:41 AM »

Function Peer Review / Re: action_move_to
« on: March 03, 2011, 12:04:05 AM »
You can use that for now. Until TGMG commits his changes, which include an argument_relative. See the discussion in this thread.

Proposals / Re: Avatar Size
« on: March 02, 2011, 09:52:01 PM »
Er, all the avatars here are 96x96... Look at Fede's. And, well, everyone's who isn't you. :P

Proposals / Re: Action functions plugin writing
« on: March 02, 2011, 09:40:46 PM »
If I may bud in, we have plenty of solutions to this issue.

1. Encase everything in {}.
{ argument_relative = true; action_do_shit(); }
2. Comma.
argument_relative = true, action_do_shit();
3. Parentheses and comma. This will solve if().
if((argument_relative=true, action_if(fuck_you)))

You'll find this more accurately mimics GM's behavior. Particularly the last one. (argument_relative = false, do_shit()) is rather form-fitting, syntactically.

IsmAvatar: `int required` is the required parameter. Int was an example. He was implying that the function would be backwards compatible, but would allow LGM to set an argument relative. I object because the additional stack push and assignment is baloney.

Issues Help Desk / Re: Help with GM's instance ID system
« on: March 02, 2011, 09:29:54 PM »
Luis, your points are all correct. Rusky, your first point is correct. GM does not distinguish persistent instances from regular ones except in room start/end, during the former of which a check is done for an instance of that ID (exclusively for persistent instances) and during the latter of which persistent instances are not destroyed. I'll grant that it's possible, but unlikely, that Mark keeps a separate list of persistent instances, but a check for an existing ID is a likely O(1) operation and eliminates the need for a second container.

But yes, a counter is kept, and IDs are never re-used (except, of course, with instances placed in the room editor).

Proposals / Re: room_speed
« on: March 02, 2011, 09:16:56 PM »
It works sometimes. I can't seem to make it play nice on all computers. *shrug*