• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Trouble creating instances of node/tile objects via create code of another object

Dsharp

Member
I'm using GM2, following a tutorial that was made for GM1. I've run into a few little differences already, but I'm stumped on what's going on here. I've got 2 objects right now. The first is a node object that acts as the tiles that comprise the game map. The nodes aren't placed themselves, though - instead, they're placed in the create code of my second object, obj_game, which acts as a sort of controller object:

GML:
globalvar map;

mapWidth = room_width/GRID_SIZE;
mapHeight = room_height/GRID_SIZE;

for (xx = 0; xx << mapWidth; xx += 1) {
    for (yy = 0; yy << mapHeight; yy += 1) {
        map[xx,yy] = instance_create_depth(xx * GRID_SIZE, yy * GRID_SIZE, 0, obj_node);
    }
}
GRID_SIZE is defined as a macro in a script file and I've got debug text running that proves that mapWidth and mapHeight aren't 0, so the loop ought to be iterating. But without fail, I don't see any of my obj_nodes being created, even though they ought to be covering most of the screen.

I've tried manually placing obj_nodes into the room, and that works just fine. And my background has a depth of 100, so it shouldn't be obscuring anything.

Here's the draw code for my obj_nodes:

GML:
draw_self();
draw_set_color(c_black);
draw_text(x+4, y+4, string(ds_list_size(neighbors)));
draw_set_color(c_white);
Removed youtube link to see if that will skip the approval process. Didn't realize how long it'd take. It's Sergeant Indie's Turn-based Strategy 101, episode 1, Creating a Game Grid. Around 11 minutes in is the most relevant part, although I don't know if it's really necessary to see that anyway.

And lastly, here's an image of what's being displayed:
Error May 17.PNG
The blue circle is just a sprite I added to confirm my obj_game was there. The text is the map width/height. And the white square with 0 in it is my obj_node, which should be tiling over the entire screen but isn't.
 
Last edited:

Nidoking

Member
While == is the equality operator to distinguish it from the = assignment operator, the comparison operators are < and >. << and >> are bit shifts.
 

Dsharp

Member
Yeah I figured out the problem last night, oops. Sorry, this thread's been stuck in approval purgatory for a while and I couldn't seem to get rid of it. Thanks for your reply, though!
 
Top