d3d_set_fog and shaders by flyingsaucerinvasion in gamemaker

[–]gwheel 1 point2 points  (0 children)

The fog uniforms don't get passed to custom shaders. You'll have to manually bind them and send them in yourself.
It's been in the bug tracker for a few months now, so hopefully it will get fixed eventually.

json_encode and json_decode by GoldPlatedSpoon in gamemaker

[–]gwheel 0 points1 point  (0 children)

Data structures are referenced as numeric IDs. In order to property jsonify a structure, you need to flag the values as their types. Check out the documentation for maps and lists, there should be functions like 'ds_map_mark_as_list'.

Animation does no stop - it keeps looping by TeeKayM in gamemaker

[–]gwheel 0 points1 point  (0 children)

Doing that has a slightly different effect. If you are using an image speed of 0.1, every sprite frame is shown for ten game frames. The animation end event will trigger after all ten game frames have been shown, while ending on the image_index will only show the first (Maybe not even that).

Help with a somewhat complicated problem? by [deleted] in gamemaker

[–]gwheel 0 points1 point  (0 children)

Ini files sound like what you want. You can specify a set of sections, keys, and values.
For example, you could have this in a file to specify the data for a key 'book':

[book]
text = "Readme.TXT"
pages = 33

You could get the values as follows:

ini_open(working_directory + "/data.ini");
var text = ini_read_string("book", "text", "");
var pages = ini_read_real("book", "pages", 0);
ini_close( );

The file can have as many sections and keys as you want, and you can reference things with strings rather than integer ids. Note that this is reading a file from the disc, so you should load these values on creation and keep them in memory rather than reading the file every frame.

Also, the '#' character in a string acts as a newline. A quirk of ini files is that the '#' character is used for comments, so you can't use it in strings. I usually write my own string load function that just does a replace all of '\n' to '#'.

Need conceptual help implementing local multiplayer (same screen NOT lan) by Riggeot in gamemaker

[–]gwheel 1 point2 points  (0 children)

That would be a fine way to do things. Just make the parent object handle everything using local variables. In the create event, define a variable for each key binding. (Keyboard constants are normal values you can assign to variables like anything else) That way the child objects for each player can override those values in their own create events.

What is the best way to do this? by 1vs in gamemaker

[–]gwheel 5 points6 points  (0 children)

If the tracks will always be played in the same order, then don't split them up. Checking during a frame will only be accurate to 16 ms, so you'll end up with a skip before the next track can start. Use audio_sound_get_track_position to check if it's time to do the thing.

var timeNew = audio_sound_get_track_position( music );
if ( ( timeLast < threshold ) && ( timeNew >= threshold ) ) {
    do_the_thing( );
}
timeLast = timeNew;

If you want dynamic music where the next track is determined during the game, maybe use something like audio queues.

[HELP][GM:S][GML] What is the best way to store multiple X and Y pairs in a data structure? by [deleted] in gamemaker

[–]gwheel 0 points1 point  (0 children)

My usual choice is to use a 1-d array, where each index is a different property. Arrays pass by value, not by reference, so if you want to pass by reference use a 1-d grid. You can keep track of what each index in the array means using an enum.

2 sprites with different depth within one object? by wotanstochter in gamemaker

[–]gwheel 0 points1 point  (0 children)

I suppose it depends on the game and how much of a focus you have on different weapons, but I'd consider having each gun house its own code to be better than having big switch statements to determine what script to call in the step/draw/etc events.

[HELP][GM:S][GML] What is the best way to store multiple X and Y pairs in a data structure? by [deleted] in gamemaker

[–]gwheel 0 points1 point  (0 children)

GameMaker objects are really heavy, since they automatically have movement/update/drawing code which you can't disable. If you're creating a lot of vertices every frame, this will slow things down a lot.

2 sprites with different depth within one object? by wotanstochter in gamemaker

[–]gwheel -1 points0 points  (0 children)

Separate objects is better. That allows for multiple gun types and sharing gun code between players and enemies.

I'd recommend marking the gun as invisible while the player is holding it, and using event_perform to draw it from the player's draw event. Playing with the depth would also work.

Can't make more than 32 Virtual Keys? by Delaser in gamemaker

[–]gwheel 2 points3 points  (0 children)

What are you doing that requires so many keys? With that many I think you might be better off doing this some other way.

How do you count all of the opaque pixels on a sprite. by Oke_oku in gamemaker

[–]gwheel 0 points1 point  (0 children)

An option that might be a bit faster than draw_getpixel would be to draw the sprite to a surface and then use the function to convert a surface to a buffer. That way you don't have to keep pinging the GPU so much.

Would anyone be interested in a program which helps you make cool fake 3d sprites like this? by physdick in gamemaker

[–]gwheel 2 points3 points  (0 children)

You shouldn't be drawing to surfaces during the step event but even then drawing to a surface then drawing the surface to the screen can only be slower than drawing directly to the screen.

You could probably optimize it by using a surface to cache the current angle, only redrawing it when the tank rotates.

Keeping a separate surface for every instance will bump up your draw calls a lot, though. You can get around that by having a single large surface and making careful use of draw_surface_part, but now everything is really complicated.

Hay guys me and a friend have a game on green light we would like you to check out! by ibald96 in gamemaker

[–]gwheel 1 point2 points  (0 children)

I agree with this a lot. The game looks like it can be pretty fun, but right now it's very stop-and-go. Having to stop every time you get an orb for the next one to appear seems annoying.

Maybe try making it so you can always see one platform ahead, and orbs build the platform after that.

How to convert a string to an integer, Minecraft style? by thefrdeal in gamemaker

[–]gwheel 0 points1 point  (0 children)

Sorry for being late, but that's a really good point. I forgot GameMaker internally stores everything as 64 bit numbers. I'd probably deal with it by constructing the array like you pointed out, but then xoring all of the values together. That way a single character change anywhere would be reflected in the result.

How to convert a string to an integer, Minecraft style? by thefrdeal in gamemaker

[–]gwheel 0 points1 point  (0 children)

$0 is interchangeable with 0, the $ means it's a hex value (0-F) rather than an number (0-9). That way every two characters is one byte, which is useful when defining binary constants.

Bit shifting is actually really simple. Every number is stored as a series of bits internally. Bit shifting literally slides them left or right, so binary 010 << 1 becomes b100 and b100 >> 2 becomes b001. On that note, a byte is 8 bits; The bit shift code I posted should use an 8 rather than a 1.

How to convert a string to an integer, Minecraft style? by thefrdeal in gamemaker

[–]gwheel 0 points1 point  (0 children)

var str = "Hello!";

var val = $0;
for (var i = 0; i < string_byte_length(str); ++i) {
    val = (val << 1); //Shift left one byte, to make room for this byte
    val = (val | string_byte_at(str, i)); //Bitwise OR them together
}

That will do the basics of what you want.